I’ve tested version 1.0.8 of RottenLinks and the CLI script has some issues with PHP 7.2 + MediaWiki 1.34.0:
- PHP Fatal error: Uncaught Error: Class 'MediaWiki\MediaWikiServices' not found in /var/www/mediawiki/1.34.0/extensions/RottenLinks/maintenance/updateExternalLinks.php:12
- Error from line 15 of /var/www/mediawiki/1.34.0/extensions/RottenLinks/includes/RottenLinks.php: Using $this when not in object context
- few PHP Notice: Undefined offset: 2 in /var/www/mediawiki/1.34.0/extensions/RottenLinks/maintenance/updateExternalLinks.php on line 55 when running the script
Fixes:
- declare $config = MediaWikiServices... in execute() → because in [mediawiki]/maintenance/doMaintenance.php, the object of the maintenance script is constructed before Setup.php is called (which is the only way to included the list of classes declared in [mediawiki]/autoload.php
- declare $config = MediaWikiServices... in getResponse() → $this cannot be used in a static function
- this is very vicious and occurs on URL like //tools.wmflabs.org/geohack/geohack.php?language=sv&pagename=Illagilshn%C3%BAkur¶ms=65.68065_N_-14.54465_E_type:mountain_region:IS
- the first explode( ':', $url ) gives 3 parts: //tools.wmflabs.org/geohack/geohack.php?language=sv&pagename=Illagilshn%C3%BAkur¶ms=65.68065_N_-14.54465_E_type AND mountain_region AND IS, hence it is not detected as a protocol-independant URL
- $mainSite = explode( '/', $urlexp[1] ); is tested against mountain_region and there is no slash
To fix it, I find it is easier to add a condition if ( substr( $url, 0, 2 ) === '//' ) { $url = 'https:' . $url; } at the beginning, I have not detected exceptions with this code.