Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination & PHP 8.1: ctype_digit(): Argument of type null will be interpreted as string in the future #6119

Closed
tenzap opened this issue Mar 21, 2022 · 2 comments

Comments

@tenzap
Copy link
Contributor

tenzap commented Mar 21, 2022

With CI 3.1.13 on PHP 8.1, I get this error on this call:

$this->pagination->create_links();

There is no such problem on PHP 7.4

An uncaught Exception was encountered

Type: ErrorException

Message: ctype_digit(): Argument of type null will be interpreted as string in the future

Filename: vendor/codeigniter/framework/system/libraries/Pagination.php

Line Number: 526

PHP doc states:

Warning

As of PHP 8.1.0, passing a non-string argument is deprecated. In the future,
the argument will be interpreted as a string instead of an ASCII codepoint.
Depending on the intended behavior, the argument should either be cast to 
string or an explicit call to [chr()](https://www.php.net/manual/en/function.chr.php)
should be made.
@tenzap tenzap changed the title Pagniation & PHP 8.1: ctype_digit(): Argument of type null will be interpreted as string in the future Pagination & PHP 8.1: ctype_digit(): Argument of type null will be interpreted as string in the future Mar 21, 2022
@pyerro
Copy link

pyerro commented Mar 21, 2022

Original line 526:
if ( ! ctype_digit($this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0))

Possible fix for PHP 8.1:
if ( ! ctype_digit((string)$this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0))

@gxgpet
Copy link
Contributor

gxgpet commented Mar 22, 2023

Fixed via 3e5d109.

@gxgpet gxgpet closed this as completed Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants