mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-06-05 14:23:36 +00:00
Only allow sort fields that match the current object alias.
Instead of modifying aliases that do not match, only allow aliases that do match. Refs #3803
This commit is contained in:
parent
fab5a6f4d9
commit
37ce6dfc81
2 changed files with 28 additions and 3 deletions
lib/Cake/Controller/Component
|
@ -384,10 +384,11 @@ class PaginatorComponent extends Component {
|
|||
if (strpos($key, '.') !== false) {
|
||||
list($alias, $field) = explode('.', $key);
|
||||
}
|
||||
$correctAlias = ($object->alias == $alias);
|
||||
|
||||
if ($object->hasField($field)) {
|
||||
if ($correctAlias && $object->hasField($field)) {
|
||||
$order[$object->alias . '.' . $field] = $value;
|
||||
} elseif ($object->hasField($key, true)) {
|
||||
} elseif ($correctAlias && $object->hasField($key, true)) {
|
||||
$order[$field] = $value;
|
||||
} elseif (isset($object->{$alias}) && $object->{$alias}->hasField($field, true)) {
|
||||
$order[$alias . '.' . $field] = $value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue