CodeIgniter icon indicating copy to clipboard operation
CodeIgniter copied to clipboard

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

Open tenzap opened this issue 3 years ago • 1 comments

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 avatar Mar 21 '22 07:03 tenzap

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))

pyerro avatar Mar 21 '22 17:03 pyerro

Fixed via 3e5d109.

gxgpet avatar Mar 22 '23 00:03 gxgpet