Page MenuHomePhabricator

strlen(): Passing null to parameter #1 ($string) of type string is deprecated in ConfirmAccount/includes/backend/UserAccountRequest.php:93
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Go to Special:RequestAccount page
  • Complete and submit the following form to request a user account then click "Request Account" button

What happens?:

On the Special:RequestAccount confirmation page the following deprecated warning pops up:

Deprecated:  strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/ConfirmAccount/includes/backend/UserAccountRequest.php on line 93
Request account
Your account request has been sent and is now pending review. A confirmation email has been sent to your email address.

Return to Main Page.

What should have happened instead?:

No deprecated warnings should show up.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

  • MW 1.43.1 + MySQL 8.4.5
  • Confirm User Accounts (412aa12) 08:10, 21 January 2025

Other information (browser name/version, screenshots, etc.):

Event Timeline

Aklapper renamed this task from ConfirmAccount. Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/ConfirmAccount/includes/backend/UserAccountRequest.php on line 93 to strlen(): Passing null to parameter #1 ($string) of type string is deprecated in ConfirmAccount/includes/backend/UserAccountRequest.php:93.Apr 26 2025, 6:13 PM

This is about PHP 8.1.32 (MW 1.39 and MW 1.43)

The point of this message is to say that I found some instances of nulls coming into the parser from an extension (SMW - fixed) and that it still could be a good idea to defensively null coalesce the $text parameter in public function preprocessToObj( $text, $flags = 0 ) { on about line 129 of ./includes/parser/Preprocessor_Hash.php like this:

	public function preprocessToObj( $text, $flags = 0 ) {
		$text ??= '';
		if ( $this->disableLangConversion ) {
ProductVersion
MediaWiki1.43.6 (1e92393) 2026-03-16T17:30:14
PHP8.1.34 (fpm-fcgi)
ICU74.2
MariaDB10.3.39-MariaDB-log
Elasticsearch7.10.2
Lua5.1.5
Pygments2.2.0

Passing null to parameter #1 ($string) of type string is deprecated can happen when using maintenance/refreshLinks.php (which invokes includes/parser/Preprocessor_Hash.php)

From carefully examining the stack traces in my log file, I was able to see that the nulls were coming to MW core from the SMW extension - which I fixed here

Aside: my log file was complaining about these PHP functions receiving null (but I had to carefully review the entire stack trace to really see what the source of the problem was.

  • strcspn():
  • strlen():
  • strrev():
  • strspn():

A typical stack trace is pretty huge and looks like this:

PHP Deprecated:  strrev(): Passing null to parameter #1 ($string) of type string is deprecated in /opt/htdocs/mediawiki/includes/parser/Preprocessor_Hash.php on line 202
PHP Stack trace:
PHP   1. {main}() /opt/htdocs/mediawiki/maintenance/run:0
PHP   2. require() /opt/htdocs/mediawiki/maintenance/run:3
PHP   3. MediaWiki\Maintenance\MaintenanceRunner->run() /opt/htdocs/mediawiki/maintenance/run.php:51
PHP   4. RefreshLinks->execute() /opt/htdocs/mediawiki/maintenance/includes/MaintenanceRunner.php:703
PHP   5. RefreshLinks->doRefreshLinks($builder = class Wikimedia\Rdbms\SelectQueryBuilder { protected $tables = [0 => 'page']; protected $joinConds = []; protected $lastAlias = 'page'; private $fields = []; private $conds = [0 => class Wikimedia\Rdbms\Expression { ... }]; private $caller = 'RefreshLinks::doRefreshLinks'; protected $options = ['LIMIT' => 100]; private $nextAutoAlias = 1; private $isCallerOverridden = TRUE; protected Wikimedia\Rdbms\IReadableDatabase $db = class Wikimedia\Rdbms\DBConnRef { private $lb = class Wikimedia\Rdbms\LoadBalancer { ... }; private $conn = class Wikimedia\Rdbms\DatabaseMySQL { ... }; private $params = [...]; private $role = -1; private $modCountRef = 0; private $modCountFix = 0 } }, $redirectsOnly = FALSE, $indexFields = *uninitialized*) /opt/htdocs/mediawiki/maintenance/refreshLinks.php:122
PHP   6. RefreshLinks::fixLinksFromArticle($id = '4598') /opt/htdocs/mediawiki/maintenance/refreshLinks.php:173
PHP   7. WikiPage->doSecondaryDataUpdates($options = ['defer' => 2, 'causeAction' => 'refresh-links-maintenance', 'recursive' => FALSE]) /opt/htdocs/mediawiki/maintenance/refreshLinks.php:254
PHP   8. MediaWiki\Storage\DerivedPageDataUpdater->doSecondaryDataUpdates($options = ['defer' => 2, 'causeAction' => 'refresh-links-maintenance', 'recursive' => FALSE]) /opt/htdocs/mediawiki/includes/page/WikiPage.php:1915

[OMITTED FOR BREVITY]

PHP  39. MediaWiki\Parser\Parser->preprocessToDom($text = NULL, $flags = 0) /opt/htdocs/mediawiki/includes/parser/Parser.php:1588
PHP  40. MediaWiki\Parser\Preprocessor_Hash->preprocessToObj($text = NULL, $flags = 0) /opt/htdocs/mediawiki/includes/parser/Parser.php:2900
PHP  41. MediaWiki\Parser\Preprocessor_Hash->buildDomTreeArrayFromText($text = NULL, $flags = 0) /opt/htdocs/mediawiki/includes/parser/Preprocessor_Hash.php:158
PHP  42. strrev($string = NULL) /opt/htdocs/mediawiki/includes/parser/Preprocessor_Hash.php:202