Skip to content

Conversation

midlan
Copy link
Contributor

@midlan midlan commented Nov 12, 2019

Community, what do you think?

When the $this->_curPage is 1 the $this->getLastPageNumber() is called. In eav collection it is slow operation, because $this->getSize() is called inside.

@midlan midlan mentioned this pull request Nov 12, 2019
@colinmollenhour
Copy link
Member

Very nice optimization!

@midlan
Copy link
Contributor Author

midlan commented Nov 15, 2019

I've got feedback that it may break some category listing. At this moment I don't see the reason, I will try to research.

@Flyingmana
Copy link
Contributor

@midlan did you find anything out?

@midlan
Copy link
Contributor Author

midlan commented Feb 6, 2020

@Flyingmana I didn't, my Magento instance is pretty modified and I am not what broken the category listing. Can someone try it on yours Magento?

@colinmollenhour colinmollenhour added the performance Performance related label Apr 23, 2020
@sreichel
Copy link
Contributor

Just played bit with ... no real usage, but if $displacement is something below -1 (yes, negative ints here) it could break custom code ....

@sreichel sreichel added the review needed Problem should be verified label May 22, 2020
@colinmollenhour
Copy link
Member

I've been running this since April 23 on a project with tons of custom code and had no issues.

MySQL doesn't support negative limits: "LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants". So, I don't see any reason anyone would ever use a negative $displacement argument.

@tmotyl tmotyl merged commit 58daa28 into OpenMage:1.9.4.x Jun 4, 2020
@sreichel
Copy link
Contributor

sreichel commented Jun 4, 2020

FYI $displacement with -1 is used in core. @midlan mentioned problems w/ category listings, that i cant reproduce .... maybe related to custom code?

@midlan
Copy link
Contributor Author

midlan commented Jun 4, 2020

@sreichel
Yes I think it is related to some custom/community code. Did someone tested that in combination with Lesti_Fpc?

@sreichel sreichel added the Component: lib/Varien Relates to lib/Varien label Jun 4, 2020
@tmotyl
Copy link
Contributor

tmotyl commented Jun 5, 2020

I have tested the change and it works here.

The only place in the core where negative displacement is used is:
https://github.com/OpenMage/magento-lts/blob/performance_tuning/app/code/core/Mage/Page/Block/Html/Pager.php#L284-L284

This change could break 3rd party code, if the code depends on the side effect - assumes that collection is loaded after calling getCurPage(). Or do you see a different possibility @sreichel ?

btw, in Magento2 the getLastPageNumber was removed from the function

    public function getCurPage($displacement = 0)
    {
        if ($this->_curPage + $displacement < 1) {
            return 1;
        }

        return $this->_curPage + $displacement;
    }

@sreichel
Copy link
Contributor

sreichel commented Jun 5, 2020

This change could break 3rd party code, if the code depends on the side effect

This it is. I also tested with vanilla install and it did work, but it could break 3rd-party code ...

@sreichel sreichel added this to the Release 19.4.4 milestone Jun 26, 2020
edannenberg pushed a commit to edannenberg/magento-lts that referenced this pull request Aug 20, 2020
edannenberg pushed a commit to edannenberg/magento-lts that referenced this pull request Aug 24, 2020
@midlan midlan mentioned this pull request Dec 1, 2021
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: lib/Varien Relates to lib/Varien performance Performance related review needed Problem should be verified
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants