Skip to content

Commit

Permalink
Merge branch 'release/1.7.15'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed May 19, 2021
2 parents 668f8cc + 5621f5c commit b693ed4
Show file tree
Hide file tree
Showing 16 changed files with 148 additions and 63 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Extract Tag
run: echo "PACKAGE_VERSION=${{ github.ref }}" >> $GITHUB_ENV

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -38,13 +41,14 @@ jobs:
run: |
bash ./build-grav.sh
- name: Upload Grav Release Assets
id: upload-release-asset
uses: alexellis/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GLOBAL_TOKEN }}
- name: Upload packages to release
uses: svenstaro/upload-release-action@v2
with:
asset_paths: '["./grav-dist/*.zip"]'
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.PACKAGE_VERSION }}
file: ./grav-dist/*.zip
overwrite: true
file_glob: true

slack:
name: Slack
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# v1.7.15
## 05/19/2021

1. [](#improved)
* Allow optional start date in page collections [#3350](https://github.com/getgrav/grav/pull/3350)
* Added `page` and `output` properties to `onOutputGenerated` and `onOutputRendered` events
1. [](#bugfix)
* Fixed twig deprecated TwigFilter messages [#3348](https://github.com/getgrav/grav/issues/3348)
* Fixed fatal error with some markdown links [getgrav/grav-premium-issues#95](https://github.com/getgrav/grav-premium-issues/issues/95)
* Fixed markdown media operations not working when using `image://` stream [#3333](https://github.com/getgrav/grav/issues/3333) [#3349](https://github.com/getgrav/grav/issues/3349)
* Fixed copying page without changing the slug [getgrav/grav-plugin-admin#2135](https://github.com/getgrav/grav-plugin-admin/issues/2139)
* Fixed missing and commonly used methods when using `system.twig.undefined_functions = false` [getgrav/grav-plugin-admin#2138](https://github.com/getgrav/grav-plugin-admin/issues/2138)
* Fixed uploading images into Flex Object if field destination is not set

# v1.7.14
## 04/29/2021

Expand Down
2 changes: 1 addition & 1 deletion system/defines.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// Some standard defines
define('GRAV', true);
define('GRAV_VERSION', '1.7.14');
define('GRAV_VERSION', '1.7.15');
define('GRAV_SCHEMA', '1.7.0_2020-11-20_1');
define('GRAV_TESTING', false);

Expand Down
16 changes: 8 additions & 8 deletions system/src/Grav/Common/Flex/Types/Pages/PageCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,20 +426,20 @@ public function all()

/**
* Returns the items between a set of date ranges of either the page date field (default) or
* an arbitrary datetime page field where end date is optional
* Dates can be passed in as text that strtotime() can process
* an arbitrary datetime page field where start date and end date are optional
* Dates must be passed in as text that strtotime() can process
* http://php.net/manual/en/function.strtotime.php
*
* @param string $startDate
* @param string|false $endDate
* @param string|null $startDate
* @param string|null $endDate
* @param string|null $field
* @return static
* @throws Exception
*/
public function dateRange($startDate, $endDate = false, $field = null)
public function dateRange($startDate = null, $endDate = null, $field = null)
{
$start = Utils::date2timestamp($startDate);
$end = $endDate ? Utils::date2timestamp($endDate) : false;
$start = $startDate ? Utils::date2timestamp($startDate) : null;
$end = $endDate ? Utils::date2timestamp($endDate) : null;

$entries = [];
foreach ($this as $key => $object) {
Expand All @@ -449,7 +449,7 @@ public function dateRange($startDate, $endDate = false, $field = null)

$date = $field ? strtotime($object->getNestedProperty($field)) : $object->date();

if ($date >= $start && (!$end || $date <= $end)) {
if ((!$start || $date >= $start) && (!$end || $date <= $end)) {
$entries[$key] = $object;
}
}
Expand Down
10 changes: 5 additions & 5 deletions system/src/Grav/Common/Flex/Types/Pages/PageIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -949,17 +949,17 @@ public function currentPosition($path): ?int

/**
* Returns the items between a set of date ranges of either the page date field (default) or
* an arbitrary datetime page field where end date is optional
* Dates can be passed in as text that strtotime() can process
* an arbitrary datetime page field where start date and end date are optional
* Dates must be passed in as text that strtotime() can process
* http://php.net/manual/en/function.strtotime.php
*
* @param string $startDate
* @param bool $endDate
* @param string|null $startDate
* @param string|null $endDate
* @param string|null $field
* @return static
* @throws Exception
*/
public function dateRange($startDate, $endDate = false, $field = null)
public function dateRange($startDate = null, $endDate = null, $field = null)
{
$collection = $this->__call('dateRange', [$startDate, $endDate, $field]);

Expand Down
8 changes: 6 additions & 2 deletions system/src/Grav/Common/Flex/Types/Users/UserObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,9 @@ protected function setUpdatedMedia(array $files): void
$locator = Grav::instance()['locator'];

$media = $this->getMedia();
if (!$media instanceof MediaUploadInterface) {
return;
}

$list = [];
$list_original = [];
Expand All @@ -707,7 +710,6 @@ protected function setUpdatedMedia(array $files): void

// Load settings for the field.
$settings = $this->getMediaFieldSettings($field);

foreach ($group as $filename => $file) {
if ($file) {
// File upload.
Expand All @@ -723,7 +725,7 @@ protected function setUpdatedMedia(array $files): void

if ($file) {
// Check file upload against media limits.
$filename = $media->checkUploadedFile($file, $filename, $settings);
$filename = $media->checkUploadedFile($file, $filename, ['filesize' => 0] + $settings);
}

$self = $settings['self'];
Expand Down Expand Up @@ -759,6 +761,8 @@ protected function setUpdatedMedia(array $files): void
}
}

$this->clearMediaCache();

$this->_uploads = $list;
$this->_uploads_original = $list_original;
}
Expand Down
26 changes: 14 additions & 12 deletions system/src/Grav/Common/Page/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,30 +319,32 @@ public function currentPosition($path): ?int

/**
* Returns the items between a set of date ranges of either the page date field (default) or
* an arbitrary datetime page field where end date is optional
* Dates can be passed in as text that strtotime() can process
* an arbitrary datetime page field where start date and end date are optional
* Dates must be passed in as text that strtotime() can process
* http://php.net/manual/en/function.strtotime.php
*
* @param string $startDate
* @param bool $endDate
* @param string|null $startDate
* @param string|null $endDate
* @param string|null $field
* @return $this
* @throws Exception
*/
public function dateRange($startDate, $endDate = false, $field = null)
public function dateRange($startDate = null, $endDate = null, $field = null)
{
$start = Utils::date2timestamp($startDate);
$end = $endDate ? Utils::date2timestamp($endDate) : false;
$start = $startDate ? Utils::date2timestamp($startDate) : null;
$end = $endDate ? Utils::date2timestamp($endDate) : null;

$date_range = [];
foreach ($this->items as $path => $slug) {
$page = $this->pages->get($path);
if ($page !== null) {
$date = $field ? strtotime($page->value($field)) : $page->date();
if (!$page) {
continue;
}

if ($date >= $start && (!$end || $date <= $end)) {
$date_range[$path] = $slug;
}
$date = $field ? strtotime($page->value($field)) : $page->date();

if ((!$start || $date >= $start) && (!$end || $date <= $end)) {
$date_range[$path] = $slug;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,17 @@ public function currentPosition($path): ?int;

/**
* Returns the items between a set of date ranges of either the page date field (default) or
* an arbitrary datetime page field where end date is optional
* Dates can be passed in as text that strtotime() can process
* an arbitrary datetime page field where start date and end date are optional
* Dates must be passed in as text that strtotime() can process
* http://php.net/manual/en/function.strtotime.php
*
* @param string $startDate
* @param bool $endDate
* @param string|null $startDate
* @param string|null $endDate
* @param string|null $field
* @return PageCollectionInterface
* @throws Exception
*/
public function dateRange($startDate, $endDate = false, $field = null);
public function dateRange($startDate = null, $endDate = null, $field = null);

/**
* Creates new collection with only visible pages
Expand Down
2 changes: 1 addition & 1 deletion system/src/Grav/Common/Page/Markdown/Excerpts.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static function ($carry, $item) {
// Handle custom streams.
/** @var UniformResourceLocator $locator */
$locator = $grav['locator'];
if ($locator->isStream($url)) {
if ($type === 'link' && $locator->isStream($url)) {
$path = $locator->findResource($url, false) ?: $locator->findResource($url, false, true);
$url_parts['path'] = $grav['base_url_relative'] . '/' . $path;
unset($url_parts['stream'], $url_parts['scheme']);
Expand Down
17 changes: 10 additions & 7 deletions system/src/Grav/Common/Page/Medium/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ public function __construct(array $attributes, MediaObjectInterface $medium)
$this->attributes = $attributes;

$source = $medium->reset()->thumbnail('auto')->display('thumbnail');

// FIXME: Thumbnail can be null, maybe we should not allow that?
if (null === $source) {
if (!$source instanceof MediaObjectInterface) {
throw new RuntimeException('Media has no thumbnail set');
}

Expand Down Expand Up @@ -89,10 +87,15 @@ public function __call($method, $args)
throw new BadMethodCallException(get_class($object) . '::' . $method . '() not found.');
}

$this->source = call_user_func_array($callable, $args);
$object = call_user_func_array($callable, $args);
if (!$object instanceof MediaLinkInterface) {
// Don't start nesting links, if user has multiple link calls in his
// actions, we will drop the previous links.
return $this;
}

$this->source = $object;

// Don't start nesting links, if user has multiple link calls in his
// actions, we will drop the previous links.
return $this->source instanceof MediaLinkInterface ? $this->source : $this;
return $object;
}
}
6 changes: 3 additions & 3 deletions system/src/Grav/Common/Page/Pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,9 @@ public function getCollection(array $params = [], array $context = [])
}

if (isset($params['dateRange'])) {
$start = $params['dateRange']['start'] ?? 0;
$end = $params['dateRange']['end'] ?? false;
$field = $params['dateRange']['field'] ?? false;
$start = $params['dateRange']['start'] ?? null;
$end = $params['dateRange']['end'] ?? null;
$field = $params['dateRange']['field'] ?? null;
$collection = $collection->dateRange($start, $end, $field);
}

Expand Down
19 changes: 12 additions & 7 deletions system/src/Grav/Common/Processors/RenderProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use RocketTheme\Toolbox\Event\Event;

/**
* Class RenderProcessor
Expand Down Expand Up @@ -42,23 +43,27 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
return $output;
}

ob_start();
/** @var PageInterface $page */
$page = $this->container['page'];

// Use internal Grav output.
$container->output = $output;
$container->fireEvent('onOutputGenerated');

ob_start();

$event = new Event(['page' => $page, 'output' => &$container->output]);
$container->fireEvent('onOutputGenerated', $event);

echo $container->output;

$html = ob_get_clean();

// remove any output
$container->output = '';

$this->container->fireEvent('onOutputRendered');

$html = ob_get_clean();
$event = new Event(['page' => $page, 'output' => $html]);
$this->container->fireEvent('onOutputRendered', $event);

/** @var PageInterface $page */
$page = $this->container['page'];
$this->stopTimer();

return new Response($page->httpResponseCode(), $page->httpHeaders(), $html);
Expand Down
40 changes: 38 additions & 2 deletions system/src/Grav/Common/Twig/Extension/FilesystemExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Grav\Common\Utils;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;

/**
Expand All @@ -30,11 +31,35 @@ public function __construct()
}

/**
* @return TwigFunction[]
* @return TwigFilter[]
*/
public function getFilters()
{
return $this->getFunctions();
return [
new TwigFilter('file_exists', [$this, 'file_exists']),
new TwigFilter('fileatime', [$this, 'fileatime']),
new TwigFilter('filectime', [$this, 'filectime']),
new TwigFilter('filemtime', [$this, 'filemtime']),
new TwigFilter('filesize', [$this, 'filesize']),
new TwigFilter('filetype', [$this, 'filetype']),
new TwigFilter('is_dir', [$this, 'is_dir']),
new TwigFilter('is_file', [$this, 'is_file']),
new TwigFilter('is_link', [$this, 'is_link']),
new TwigFilter('is_readable', [$this, 'is_readable']),
new TwigFilter('is_writable', [$this, 'is_writable']),
new TwigFilter('is_writeable', [$this, 'is_writable']),
new TwigFilter('lstat', [$this, 'lstat']),
new TwigFilter('getimagesize', [$this, 'getimagesize']),
new TwigFilter('exif_read_data', [$this, 'exif_read_data']),
new TwigFilter('read_exif_data', [$this, 'exif_read_data']),
new TwigFilter('exif_imagetype', [$this, 'exif_imagetype']),
new TwigFilter('hash_file', [$this, 'hash_file']),
new TwigFilter('hash_hmac_file', [$this, 'hash_hmac_file']),
new TwigFilter('md5_file', [$this, 'md5_file']),
new TwigFilter('sha1_file', [$this, 'sha1_file']),
new TwigFilter('get_meta_tags', [$this, 'get_meta_tags']),
new TwigFilter('pathinfo', [$this, 'pathinfo']),
];
}

/**
Expand Down Expand Up @@ -67,6 +92,7 @@ public function getFunctions()
new TwigFunction('md5_file', [$this, 'md5_file']),
new TwigFunction('sha1_file', [$this, 'sha1_file']),
new TwigFunction('get_meta_tags', [$this, 'get_meta_tags']),
new TwigFunction('pathinfo', [$this, 'pathinfo']),
];
}

Expand Down Expand Up @@ -340,6 +366,16 @@ public function get_meta_tags($filename)
return get_meta_tags($filename);
}

/**
* @param string $path
* @param int $flags
* @return string|string[]
*/
public function pathinfo($path, $flags = PATHINFO_ALL)
{
return pathinfo($path);
}

/**
* @param string $filename
* @return bool
Expand Down
Loading

0 comments on commit b693ed4

Please sign in to comment.