Jump to content

Topic on Project:Support desk

Internal error - Mediawiki

13
FrViPofm (talkcontribs)

Hi,

I'm re-installing Mediawiki 1.37 on a fresh Ubuntu 22.04, Apache, PHP 8.1. I get the first config screen (lang), I click for the following step, and... fail!

/w/mw-config/index.php?page=Language Error: Class "FormatJson" not found

Backtrace:
from /var/www/wiki/w/includes/exception/MWExceptionHandler.php(754)
 #0 /var/www/wiki/w/includes/exception/MWExceptionHandler.php(291): MWExceptionHandler::logError()
 #1 /var/www/wiki/w/includes/AutoLoader.php(117): MWExceptionHandler::handleError()
 #2 /var/www/wiki/w/includes/AutoLoader.php(117): require(string)
 #3 /var/www/wiki/w/includes/cache/localisation/LocalisationCache.php(594): AutoLoader::autoload()
 #4 /var/www/wiki/w/includes/cache/localisation/LocalisationCache.php(929): LocalisationCache->readJSONFile()
 #5 /var/www/wiki/w/includes/cache/localisation/LocalisationCache.php(496): LocalisationCache->recache()
 #6 /var/www/wiki/w/includes/cache/localisation/LocalisationCache.php(370): LocalisationCache->initLanguage()
 #7 /var/www/wiki/w/includes/cache/localisation/LocalisationCache.php(311): LocalisationCache->loadItem()
 #8 /var/www/wiki/w/includes/language/LanguageFallback.php(106): LocalisationCache->getItem()
 #9 /var/www/wiki/w/includes/language/LanguageFactory.php(158): MediaWiki\Languages\LanguageFallback->getAll()
 #10 /var/www/wiki/w/includes/language/LanguageFactory.php(116): MediaWiki\Languages\LanguageFactory->newFromCode()
 #11 /var/www/wiki/w/mw-config/index.php(75): MediaWiki\Languages\LanguageFactory->getLanguage()
 #12 /var/www/wiki/w/mw-config/index.php(40): wfInstallerMain()
 #13 {main}

What is wrong ?

Bawolff (talkcontribs)

You are missing MediaWiki files or your install is corrupt. I would suggest re-installing.

FrViPofm (talkcontribs)

I tried the installation several times from the 1.37.2 .zip or tar.gz archive. I moves the files in place together with a <code>cp -r /path/to/source/* /path/to/target</code> and changed the owner with a <code>chown -R www-data:www-data /path/to/target</code> I doubt I forgot a file each time, and always the same to get the same error. Maybe a php file. But witch ? My phpinfo says that JSON is enabled.

Bawolff (talkcontribs)

The missing file would be includes/json/FormatJson.php

FrViPofm (talkcontribs)

<code>ls /var/www/wiki/w/includes/json/</code>

returns :

<code>

FormatJson.php     JsonSerializer.php           JsonUnserializer.php

JsonCodec.php      JsonUnserializable.php

JsonConstants.php  JsonUnserializableTrait.php

</code>

The FormatJson.php file is here.

Bawolff (talkcontribs)

Check it has the same contents as https://github.com/wikimedia/mediawiki/blob/REL1_37/includes/json/FormatJson.php (especially line 1 and 26, but whole thing should be the same) and also check line 539 of autoload.php is the same as https://github.com/wikimedia/mediawiki/blob/REL1_37/autoload.php#L539

Php 8.1 isn't officially supported by mediawiki 1.37, but it feels really unlikely that any incompatibility would manifest like this. However it seems like some other people have the same error https://phabricator.wikimedia.org/T307816 which is very weird (edit: i didnt realize you were same person)

Bawolff (talkcontribs)
FrViPofm (talkcontribs)
FrViPofm (talkcontribs)

OK. WIki installed.

Thanks.

Bawolff (talkcontribs)

Thats still super weird as an empty line at end should affect nothing. Maybe some sort of opcode cache issue and editing the file forced a cache clear.

217.132.25.116 (talkcontribs)

FYI - happened to me also, adding a newline at the end of FormatJson solves the issue.

188.141.20.253 (talkcontribs)

thanks, that did the trick for me. just add new line

FrViPofm (talkcontribs)
Reply to "Internal error - Mediawiki"