Page MenuHomePhabricator

[wiki.wikimedia.it] [Upgrade error from 1.26.4 to 1.35.6] Error from line 1073 in includes/resourceloader/ResourceLoader.php: "Unsupported operand types"
Closed, ResolvedPublic

Description

We have found an error trying an update from MediaWiki 1.26.4 to 1.35.6 of https://wiki.wikimedia.it/ on our server wmit-intreccio.

After the upgrade, the page was displayed without any style and CSS.

[b7e60374c6d8bd6e7ff3ab20] /load.php?lang=it&modules=skins.vector.styles.legacy%2Cresponsive&only=styles&skin=vector Error from line 1073 of includes/resourceloader/ResourceLoader.php: Unsupported operand types

Backtrace:

#0 includes/resourceloader/ResourceLoader.php(891): ResourceLoader->tryRespondFromFileCache(ResourceFileCache, ResourceLoaderContext, string)
#1 load.php(51): ResourceLoader->respond(ResourceLoaderContext)
#2 load.php(38): wfLoadMain()
#3 {main}

In short if you find this error, see this page:

https://www.mediawiki.org/wiki/Manual:$wgResourceLoaderMaxage

Troubleshooting

Here the relevant piece of source code:

includes/resourceloader/ResourceLoader.php
<?php
...
	/**
	 * Send out code for a response from file cache if possible.
	 *
	 * @param ResourceFileCache $fileCache Cache object for this request URL
	 * @param ResourceLoaderContext $context Context in which to generate a response
	 * @param string $etag ETag header value
	 * @return bool If this found a cache file and handled the response
	 */
	protected function tryRespondFromFileCache(
		ResourceFileCache $fileCache,
		ResourceLoaderContext $context,
		$etag
	) {
		$rlMaxage = $this->config->get( 'ResourceLoaderMaxage' );
		// Buffer output to catch warnings.
		ob_start();
		// Get the maximum age the cache can be
		$maxage = $context->getVersion() === null
			? $rlMaxage['unversioned']
			: $rlMaxage['versioned'];
		// Minimum timestamp the cache file must have
		$minTime = time() - $maxage;

See the problematic operation:

$minTime = time() - $maxage;

If you inspect $maxage you will find an array and so it fails doing a minus operation between an integer and an array.

The actual value of $maxage could be something as:

array(2) {
  ["server"]=>
  int(2592000)
  ["client"]=>
  int(2592000)
}

That is assigned by your local $wgResourceLoaderMaxage.

Hoping to be useful.

Related Objects