Page MenuHomeMiraheze

Issues with version 1.0.8
Closed, ResolvedPublic

Description

I’ve tested version 1.0.8 of RottenLinks and the CLI script has some issues with PHP 7.2 + MediaWiki 1.34.0:

  1. PHP Fatal error: Uncaught Error: Class 'MediaWiki\MediaWikiServices' not found in /var/www/mediawiki/1.34.0/extensions/RottenLinks/maintenance/updateExternalLinks.php:12
  2. Error from line 15 of /var/www/mediawiki/1.34.0/extensions/RottenLinks/includes/RottenLinks.php: Using $this when not in object context
  3. 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:

  1. 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
  1. declare $config = MediaWikiServices... in getResponse() → $this cannot be used in a static function
  1. this is very vicious and occurs on URL like //tools.wmflabs.org/geohack/geohack.php?language=sv&pagename=Illagilshn%C3%BAkur&params=65.68065_N_-14.54465_E_type:mountain_region:IS
    1. the first explode( ':', $url ) gives 3 parts: //tools.wmflabs.org/geohack/geohack.php?language=sv&pagename=Illagilshn%C3%BAkur&params=65.68065_N_-14.54465_E_type AND mountain_region AND IS, hence it is not detected as a protocol-independant URL
    2. $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.

Event Timeline

The third point is linked to T5295.

@John: I add you as author of the commit aebc1c6.

I propose a PR on Github, feel free to write it differently if you prefer.

John claimed this task.

Thank you for the contribution and spotting issues that escaped testing for this particular extension!

John triaged this task as Normal priority.Apr 16 2020, 20:48