Page MenuHomePhabricator

File: includes/objectcache/SqlBagOStuff.php: "PHP Warning: Undefined array key 1 @1090"
Closed, DeclinedPublicBUG REPORT

Description

2022/03/11 17:58:34 [error] 1835#1835: *22 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key 1 in /usr/share/MediaWiki/mediawiki-1.37.1/includes/objectcache/SqlBagOStuff.php on line 1090" while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: christ-wiki.de, request: "GET /index.php?title=Holographie&action=edit&redlink=1 HTTP/1.1", upstream: "fast*

Permenent warning MW-1.37.1

php --version
PHP 8.0.16 (cli) (built: Feb 21 2022 14:47:25) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.16, Copyright (c) Zend Technologies
with Zend OPcache v8.0.16, Copyright (c), by Zend Technologies

OS: Debian Buster (10)

Event Timeline

Umherirrender subscribed.

It is a explode call for the modification token which seems to have not the correct format.

1083	private function makeTimestampedModificationToken( $mtime, IDatabase $db ) {
1084			// We have reserved space for upto 6 digits in the microsecond portion of the token.
1085			// This is for future use only (maybe CAS tokens) and not currently used.
1086			// It is currently populated by the microsecond portion returned by microtime,
1087			// which generally has fewer than 6 digits of meaningful precision but can still be useful
1088			// in debugging (to see the token continuously change even during rapid testing).
1089			$seconds = (int)$mtime;
1090			list( , $microseconds ) = explode( '.', sprintf( '%.6f', $mtime ) );

That is everything new in REL1.37 (from https://gerrit.wikimedia.org/r/c/mediawiki/core/+/713925

But even for an interger the call to sprintf returns a "." which should be correct for the next code

> var_export( sprintf( '%.6f', 0 ) );
'0.000000'

No idea what happens exactly

Change 770619 had a related patch set uploaded (by Aaron Schulz; author: Aaron Schulz):

[mediawiki/core@master] objectcache: add makeTimestampedModificationToken() type hint

https://gerrit.wikimedia.org/r/770619

I don't really see how this is possible either. I'm curious what the type of the $mtime variable is in this case (should be float).

Change 770619 merged by jenkins-bot:

[mediawiki/core@master] objectcache: add makeTimestampedModificationToken() type hint

https://gerrit.wikimedia.org/r/770619

@Joerg.Bernau What locale are you using (LC_*)? I think the sprintf() should use "F" instead of "f".

aaron@SpectreX360:~/PhpstormProjects/mediawiki/core$ sudo locale-gen es_ES
[sudo] Mot de passe de aaron : 
Generating locales (this might take a while)...
  es_ES.ISO-8859-1... done
Generation complete.
aaron@SpectreX360:~/PhpstormProjects/mediawiki/core$ sudo locale-gen es_ES.utf8
Generating locales (this might take a while)...
  es_ES.UTF-8... done
Generation complete.
aaron@SpectreX360:~/PhpstormProjects/mediawiki/core$ sudo update-locale
aaron@SpectreX360:~/PhpstormProjects/mediawiki/core$ wphp maintenance/shell.php 
Psy Shell v0.11.2 (PHP 8.0.8 — cli) by Justin Hileman
>>> setlocale(LC_ALL, 'es_ES.UTF-8');
=> "es_ES.UTF-8"
>>> explode( '.', sprintf( '%.6F', 14.4 ) );
=> [
     "14",
     "400000",
   ]
>>> explode( '.', sprintf( '%.6f', 14.446 ) );
=> [
     "14,446000",
   ]
>>>

Change 772548 had a related patch set uploaded (by Aaron Schulz; author: Aaron Schulz):

[mediawiki/core@master] Use local-unaware floats in sprintf() calls

https://gerrit.wikimedia.org/r/772548

@Joerg.Bernau For MediaWiki <= 1.37 (before 65b1b6b56afd5b533a9213813ce9e6984c443ce4 ), you have to set $wgShellLocale to "C.UTF-8" .

Hi aaron,

as you may notice I installed 1.37.1:

2022/03/23 22:02:50 [error] 22583#22583: *70871 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key 1 in /usr/share/MediaWiki/mediawiki-1.37.1/includes/objectcache/SqlBagOStuff.php on line 1090PHP message: PHP Warning: Undefined array key 1 in /usr/share/MediaWiki/mediawiki-1.37.1/includes/objectcache/SqlBagOStuff.php on line 1090" while reading response header from upstream, client: 2001:16b8:17c7:a400:a075:34ac:e022:fe59, server: christ-wiki.de, request: "GET /index.php?title=Hauptseite HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php-fpm.sock:", host: "christ-wiki.de"
2022/03/23 22:02:50 [error] 22583#22583: *70871 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key 1 in /usr/share/MediaWiki/mediawiki-1.37.1/includes/objectcache/SqlBagOStuff.php on line 1090" while reading response header from upstream, client: 2001:16b8:17c7:a400:a075:34ac:e022:fe59, server: christ-wiki.de, request: "GET /load.php?lang=de&modules=ext.visualEditor.desktopArticleTarget.noscript%7Cskins.timeless&only=styles&skin=timeless HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php-fpm.sock:", host: "christ-wiki.de", referrer: "https://christ-wiki.de/index.php?title=Hauptseite"
2022/03/23 22:02:51 [error] 22583#22583: *70871 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key 1 in /usr/share/MediaWiki/mediawiki-1.37.1/includes/objectcache/SqlBagOStuff.php on line 1090" while reading response header from upstream, client: 2001:16b8:17c7:a400:a075:34ac:e022:fe59, server: christ-wiki.de, request: "GET /load.php?lang=de&modules=startup&only=scripts&raw=1&skin=timeless HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php-fpm.sock:", host: "christ-wiki.de", referrer: "https://christ-wiki.de/index.php?title=Hauptseite"
2022/03/23 22:02:57 [error] 22583#22583: *70871 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key 1 in /usr/share/MediaWiki/mediawiki-1.37.1/includes/objectcache/SqlBagOStuff.php on line 1090" while reading response header from upstream, client: 2001:16b8:17c7:a400:a075:34ac:e022:fe59, server: christ-wiki.de, request: "GET /load.php?lang=de&modules=jquery%2Csite%7Cjquery.client%2Ccookie%2CtextSelection%7Cmediawiki.String%2CTitle%2CUri%2Capi%2Cbase%2Ccldr%2Ccookie%2CjqueryMsg%2Clanguage%2Cstorage%2Ctoc%2Cuser%2Cutil%7Cmediawiki.editfont.styles%7Cmediawiki.libs.pluralruleparser%7Cmediawiki.page.ready%7Cmediawiki.page.watch.ajax%7Cskins.timeless.js%7Cuser.defaults&skin=timeless&version=1inyf HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php-fpm.sock:", host: "christ-wiki.de", referrer: "https://christ-wiki.de/index.php?title=Hauptseite"

@Joerg.Bernau When using using 1.37 or older (including 1.37.x), you have to set $wgShellLocale = "C.UTF-8"; in LocalSettings.php on your web server.

This problem has been fixed in the development version already and will become part of 1.38.0 in a few weeks. In the next version, wgShellLocale will no longer be needed, and MediaWiki will always set its internal locale correctly.

Change 772548 merged by jenkins-bot:

[mediawiki/core@master] http,objectcache: Use local-unaware floats in sprintf() calls

https://gerrit.wikimedia.org/r/772548