Skip to content

pdoPage: pagination links with pageVarKey not working anymore (PHP 8) #390

@achterbahn

Description

@achterbahn

Pagination from pdoPage is not working on PHP 8

Summary

when using pdoPage the pagination is not working as expected, due to a change in the PHP function preg_quote

Шаг для воспроизведения / Step to play

Example:

[[!pdoPage?
                        &tplWrapper=`WTpl`
                        &wrapIfEmpty=`1`
                        &tpl=`Tpl`
                        &pageLinkScheme=`[[+pageVarKey]]-[[+page]]`
                        &pageVarKey=`page`
                    ]]

the link is not generated properly

Наблюдаемое поведение / Observed behavior

described above.

Ожидаемое поведение / Expected behavior

The generated links should always be https://domain.com/page-X

Environment

All Version.

Solution

in pdoTools function makePageLink there is the PHP function preg_quote used in a regex.

preg_replace('#' . preg_quote($pcre, '#') . '#', '', $url)

this PHP function does escape "#" as of PHP Version 8 and thus breaks the preg_replace.

remove it and get:
preg_replace('#' . $pcre . '#', '', $url)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions