You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
discards $options['finder']['recentActivity']['limit'], preventing it from being applied to the query. This is because in PaginatorComponent::_extractFinder(), the line
$options = $options + (array)current($type);
is allowing any options with a key in PaginatorComponent::_defaultConfig (page, limit, maxlimit, or whitelist) to overwrite options set inside the finder definition (e.g. $this->paginate['finder']['recentActivity']['limit']) with the value set outside of the finder definition (e.g. $this->paginate['limit']) or with the default value.
It seems like either
that line in _extractFinder() should be flipped around to (array)current($type) + $options so that finder options aren't overwritten,
or the docs should be updated to say something like "most query modifiers like fields and conditions can be included in $options, but limit will be ignored".
Since the docs don't explicitly say whether or not things like limit should be used as options for a custom pagination finder, I wasn't sure if this was intentional or if a pull request is in order. Would allowing the use of $this->paginate['finder']['finderName']['limit'] cause any unintended consequences?
I'm using CakePHP 3.0.0-RC1.
The text was updated successfully, but these errors were encountered:
I don't think letting limit be defined in the paginate settings would be a problem. I think your proposal of flipping how the arrays are merged sounds like a good idea.
The docs say that options can be set for a custom finder (e.g.
$this->paginate['finder']['tagged']['tags'] = $tags
) and José Lorenzo's answer to a StackOverflow question suggests thatlimit
can be part of these options.However, the following code
results in a limit of 20 (the default) being used.
In
PaginatorComponent::paginate()
, the linediscards
$options['finder']['recentActivity']['limit']
, preventing it from being applied to the query. This is because inPaginatorComponent::_extractFinder()
, the lineis allowing any options with a key in
PaginatorComponent::_defaultConfig
(page
,limit
,maxlimit
, orwhitelist
) to overwrite options set inside the finder definition (e.g.$this->paginate['finder']['recentActivity']['limit']
) with the value set outside of the finder definition (e.g.$this->paginate['limit']
) or with the default value.It seems like either
_extractFinder()
should be flipped around to(array)current($type) + $options
so that finder options aren't overwritten,fields
andconditions
can be included in$options
, butlimit
will be ignored".Since the docs don't explicitly say whether or not things like
limit
should be used as options for a custom pagination finder, I wasn't sure if this was intentional or if a pull request is in order. Would allowing the use of$this->paginate['finder']['finderName']['limit']
cause any unintended consequences?I'm using CakePHP 3.0.0-RC1.
The text was updated successfully, but these errors were encountered: