What is the purpose of the pagination number? If there are multiple components with pagination on the page, the parameter for the first component will be PAGEN1, the second component will have PAGEN2, and so on. This allows each component to maintain its own results when switching pages.
We noticed a problem: on the catalog page, when we choose a page number, everything works correctly. But when we choose a different number, the pagination stops working. It's inconsistent - sometimes it works, sometimes it doesn't.
The template and the system.pagenavigation component are both standard.
We checked the $arResult array, and the NavNum (the pagination number) is 4. We refreshed the page, and NavNum is still 4. We refreshed again, and suddenly NavNum becomes 2.
We reviewed all the components above the catalog, and none of them use pagination.
(Strange, it always seemed like the pagination number was based on the component number on the page that uses pagination)
We delved into the core and examined where and how this NavNum is determined. It turns out that every time the InitNavStartVars() method is called, the NavNum parameter is simply incremented. Okay, it's incremented, but on our page, only one component uses pagination. So where does the number 4 come from?
We inserted debugbacktrace() into the function and examined the call stack.
It turns out that there are agents on the site that use CIBlockElement::GetList(), and if you pass the nPageSize parameter, it triggers the call to InitNavStartVars() and increments the NavNum. Since the agent doesn't run on every hit, the NavNum changes periodically, causing the pagination to fail.
So, if you encounter a similar problem, pay attention to the parts of the code that use CIBlockElement::GetList() with the nPageSize parameter first.