Page MenuHomePhabricator

MediaWiki 1.31 : Error from line 4829 of /var/lib/mediawiki/languages/Language.php
Open, Needs TriagePublic

Description

I encountered this exception when trying to use the Html2Wiki extension after upgrading to MediaWiki 1.31 :

[e51f192c19e9217fef6b5ed5] /mediawiki/index.php?title=Special:Html2Wiki&action=submit Error from line 4829 of /var/lib/mediawiki/languages/Language.php: Using $this when not in object context

Backtrace:

#0 /var/lib/mediawiki/extensions/Html2Wiki/specials/SpecialHtml2Wiki.php(814): Language::formatSize(integer)

#1 /var/lib/mediawiki/extensions/Html2Wiki/specials/SpecialHtml2Wiki.php(857): SpecialHtml2Wiki->formatValue(integer)

#2 /var/lib/mediawiki/extensions/Html2Wiki/specials/SpecialHtml2Wiki.php(964): SpecialHtml2Wiki->addFileToResults()

#3 /var/lib/mediawiki/extensions/Html2Wiki/specials/SpecialHtml2Wiki.php(655): SpecialHtml2Wiki->processFile()

#4 /var/lib/mediawiki/extensions/Html2Wiki/specials/SpecialHtml2Wiki.php(519): SpecialHtml2Wiki->doUpload()

#5 /var/lib/mediawiki/extensions/Html2Wiki/specials/SpecialHtml2Wiki.php(220): SpecialHtml2Wiki->doImport()

#6 /var/lib/mediawiki/includes/specialpage/SpecialPage.php(522): SpecialHtml2Wiki->execute(NULL)

#7 /var/lib/mediawiki/includes/specialpage/SpecialPageFactory.php(568): SpecialPage->run(NULL)

#8 /var/lib/mediawiki/includes/MediaWiki.php(288): SpecialPageFactory::executePath(Title, RequestContext)

#9 /var/lib/mediawiki/includes/MediaWiki.php(861): MediaWiki->performRequest()

#10 /var/lib/mediawiki/includes/MediaWiki.php(524): MediaWiki->main()

#11 /var/lib/mediawiki/index.php(42): MediaWiki->run()

#12 {main}

I managed getting rid of it by editing line 814 in /path_to_my_wiki/extensions/Html2Wiki/specials/SpecialHtml2Wiki.php

I commented out the faulty line and replaced it as bellow :

//        return htmlspecialchars( $this->getLanguage()->formatSize( Language::formatSize( $value ) ) );
   return htmlspecialchars( $this->getLanguage()->formatSize( $value ) );

Html2Wiki is now working fine.

Just for the record, as mentioned in the error message, the "formatsize" function is defined into /path_to_my_wiki/languages/Language.php from line 4828 to 4830 :

function formatSize( $size ) {
           return $this->formatComputingNumbers( $size, 1024, "size-$1bytes" );
   }

Hope this helps.