CodeIgniter
CodeIgniter copied to clipboard
Pagination & PHP 8.1: ctype_digit(): Argument of type null will be interpreted as string in the future
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.
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))
Fixed via 3e5d109.