Steps to replicate the issue (include links if applicable):
- Using PHP 8.2 and 8.3, I get an error when using Page Forms.
- Edit the page with form and a error message is displayed at the top of the page
- After inserting multiple instance templates, when saving I get the error message after using the same template either four or five times.
What happens?:
I get the error:
Deprecated: ord(): Passing null to parameter #1 ($character) of type string is deprecated in /mnt/data/html/wiki/includes/language/Language.php on line 2588
This is displayed at the top of the page when you first edit a page with a page form and when you save it if you have included more than four or five template instances in the page. Sometimes the content is saved, sometimes it isn't
What should have happened instead?:
I would expect the page to save and display the page.
Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):
- MediaWiki 1.43.3
- PHP 8.3.6 and 8.2.29
Other information (browser name/version, screenshots, etc.):
I have fixed this by updating:
public function ucfirst( $str ) { $octetCode = ord( $str ); // See https://en.wikipedia.org/wiki/ASCII#Printable_characters if ( $octetCode < 96 ) { // Assume this is an uppercase/uncased ASCII character return (string)$str; } elseif ( $octetCode < 128 ) { // Assume this is a lowercase/uncased ASCII character return ucfirst( $str ); } $first = mb_substr( $str, 0, 1 ); if ( strlen( $first ) === 1 ) { // Broken UTF-8? return ucfirst( $str ); }
The issue is surrounding:
$octetCode = ord( $str );
I have modified the code above to:
public function ucfirst( $str ) { // Temp fix for the ord() issue if ( !is_string( $str ) || $str === '' ) { return ''; } $octetCode = ord( $str ); // See https://en.wikipedia.org/wiki/ASCII#Printable_characters if ( $octetCode < 96 ) { // Assume this is an uppercase/uncased ASCII character return (string)$str; } elseif ( $octetCode < 128 ) { // Assume this is a lowercase/uncased ASCII character return ucfirst( $str ); } $first = mb_substr( $str, 0, 1 ); if ( strlen( $first ) === 1 ) { // Broken UTF-8? return ucfirst( $str ); }