Minor bug fixes

This commit is contained in:
Matias Griese
2019-11-15 09:04:44 +02:00
parent 6b3b6106bf
commit 7e5d58f94b
5 changed files with 18 additions and 10 deletions

View File

@@ -43,7 +43,7 @@ class Excerpts
$this->config = $config;
}
public function getPage(): PageInterface
public function getPage(): ?PageInterface
{
return $this->page;
}

View File

@@ -258,14 +258,14 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface
*/
public function randomizeFilter($original, $offset = 0)
{
if (!\is_array($original)) {
return $original;
}
if ($original instanceof \Traversable) {
$original = iterator_to_array($original, false);
}
if (!\is_array($original)) {
return $original;
}
$sorted = [];
$random = array_slice($original, $offset);
shuffle($random);

View File

@@ -81,8 +81,16 @@ class UserCollection implements UserCollectionInterface
{
$fields = (array)$fields;
$account_dir = Grav::instance()['locator']->findResource('account://');
$files = $account_dir ? array_diff(scandir($account_dir), ['.', '..']) : [];
$grav = Grav::instance();
/** @var UniformResourceLocator $locator */
$locator = $grav['locator'];
$account_dir = $locator->findResource('account://');
if (!is_string($account_dir)) {
return $this->load('');
}
$files = array_diff(scandir($account_dir) ?: [], ['.', '..']);
// Try with username first, you never know!
if (in_array('username', $fields, true)) {

View File

@@ -362,7 +362,7 @@ class User extends FlexObject implements UserInterface, MediaManipulationInterfa
$old = $this->get($name, null, $separator);
if ($old !== null) {
$value = $this->getBlueprint()->mergeData($value, $old, $name, $separator);
$value = $this->getBlueprint()->mergeData($value, $old, $name, $separator ?? '.');
}
$this->setNestedProperty($name, $value, $separator);
@@ -399,7 +399,7 @@ class User extends FlexObject implements UserInterface, MediaManipulationInterfa
}
// Return joined data.
return $this->getBlueprint()->mergeData($old, $value, $name, $separator);
return $this->getBlueprint()->mergeData($old, $value, $name, $separator ?? '.');
}
/**

View File

@@ -133,7 +133,7 @@ class FlexPageCollection extends FlexCollection
}
}
return null;
return false;
}
/**