Skip to content

Commit

Permalink
Fixed the list of pages not showing up in admin [#3280]
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Mar 19, 2021
1 parent 9082cd5 commit 3926a61
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Fixed `Page::activeChild()` throwing an error [#3276](https://github.com/getgrav/grav/issues/3276)
* Fixed `Flex Page` CRUD ACL when creating a new page (needs Flex Objects plugin update) [grav-plugin-flex-objects#115](https://github.com/trilbymedia/grav-plugin-flex-objects/issues/115)
* Fixed the list of pages not showing up in admin [#3280](https://github.com/getgrav/grav/issues/3280)
* Fixed text field min/max validation for UTF8 characters [#3281](https://github.com/getgrav/grav/issues/3281)

# v1.7.8
## 03/17/2021
Expand Down
23 changes: 14 additions & 9 deletions system/src/Grav/Common/Data/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use function is_float;
use function is_int;
use function is_string;
use function strlen;

/**
* Class Validation
Expand Down Expand Up @@ -239,16 +238,20 @@ public static function typeText($value, array $params, array $field)
$value = trim($value);
}

if (isset($params['min']) && strlen($value) < $params['min']) {
$len = mb_strlen($value);

$min = (int)($params['min'] ?? 0);
if ($min && $len < $min) {
return false;
}

if (isset($params['max']) && strlen($value) > $params['max']) {
$max = (int)($params['max'] ?? 0);
if ($max && $len > $max) {
return false;
}

$min = $params['min'] ?? 0;
if (isset($params['step']) && (strlen($value) - $min) % $params['step'] === 0) {
$step = (int)($params['step'] ?? 0);
if ($step && ($len - $min) % $step === 0) {
return false;
}

Expand All @@ -271,11 +274,13 @@ protected static function filterText($value, array $params, array $field)
return '';
}

$value = (string)$value;

if (!empty($params['trim'])) {
$value = trim($value);
}

return (string) $value;
return $value;
}

/**
Expand Down Expand Up @@ -332,7 +337,7 @@ protected static function filterLines($value, array $params, array $field)
*/
protected static function filterLower($value, array $params)
{
return strtolower($value);
return mb_strtolower($value);
}

/**
Expand All @@ -342,7 +347,7 @@ protected static function filterLower($value, array $params)
*/
protected static function filterUpper($value, array $params)
{
return strtoupper($value);
return mb_strtoupper($value);
}


Expand Down Expand Up @@ -534,7 +539,7 @@ public static function typeNumber($value, array $params, array $field)
*/
protected static function filterNumber($value, array $params, array $field)
{
return (string)(int)$value !== (string)(float)$value ? (float) $value : (int) $value;
return (string)(int)$value !== (string)(float)$value ? (float)$value : (int)$value;
}

/**
Expand Down

0 comments on commit 3926a61

Please sign in to comment.