Page MenuHomePhabricator

PHPVersionCheck::getIndexErrorOutput() output does not include $wgScriptPath in URL
Open, Needs TriagePublic

Description

The message on the page should have the MediaWiki logo.

It linked for us too https://test3.miraheze.org/resources/assets/mediawiki.png instead of https://test3.miraheze.org/w/resources/assets/mediawiki.png

Event Timeline

Restricted Application added subscribers: Reception123, Aklapper. · View Herald Transcript
RhinosF1 renamed this task from $phpVersionCheck->checkVendorExistence(); does not include $wgScriptPath to $phpVersionCheck->checkVendorExistence(); message does not include $wgScriptPath in URL.May 24 2021, 6:41 PM
RhinosF1 moved this task from Radar to Miraheze-Linked on the User-RhinosF1 board.

The message on the page should have the MediaWiki logo.

Which page?

The message on the page should have the MediaWiki logo.

Which page?

The page generated when that check fails and displays an internal error

Reedy renamed this task from $phpVersionCheck->checkVendorExistence(); message does not include $wgScriptPath in URL to PHPVersionCheck::getIndexErrorOutput() output does not include $wgScriptPath in URL.May 24 2021, 7:04 PM

Your report is about the wrong function, PHPVersionCheck::checkVendorExistence() does not output a logo. PHPVersionCheck::getIndexErrorOutput() does and uses $this->scriptPath

		$encLogo =
			htmlspecialchars( str_replace( '//', '/', $this->scriptPath . '/' ) .
				'resources/assets/mediawiki.png' );

which is set by

/**
 * Check PHP version and that external dependencies are installed, and
 * display an informative error if either condition is not satisfied.
 *
 * @param string $format One of "text" or "html"
 * @param string $scriptPath Used when an error is formatted as HTML.
 */
function wfEntryPointCheck( $format = 'text', $scriptPath = '/' ) {
	$phpVersionCheck = new PHPVersionCheck();
	$phpVersionCheck->setFormat( $format );
	$phpVersionCheck->setScriptPath( $scriptPath );
	$phpVersionCheck->checkRequiredPHPVersion();
	$phpVersionCheck->checkVendorExistence();
	$phpVersionCheck->checkExtensionExistence();
}

Which is set by the wfEntryPointCheck( 'html', dirname( $_SERVER['SCRIPT_NAME'] ) ); call

It didn't output with the path when I saw the error just before filing this.

The only other thing I can think is it wasn't set because things were more messed up than I guessed.

I didn't say it should've output the right thing/path... Just quoting the relevant code that does it.

I guess it should be easy enough to test locally (I'll have a look in a few) by moving the vendor dir out of the way

Reedy added a subscriber: Krinkle.

I note on my devwiki $scriptPath is / if I just visit http://<ipaddress>

<img src="/resources/assets/mediawiki.png" alt="The MediaWiki logo">

If I explicitly browse to http://<ipaddress>/w/index.php it's /w/

<img src="/w/resources/assets/mediawiki.png" alt="The MediaWiki logo">

If I explicitly browse to http://<ipaddress>/wiki/Special:Version it's also /

<img src="/resources/assets/mediawiki.png" alt="The MediaWiki logo">

Then SCRIPT_NAME is documented as

Contains the current script's path. This is useful for pages which need to point to themselves. The FILE constant contains the full path and filename of the current (i.e. included) file.

Looks to have been this way since @Krinkle did rMWe6763161e732: PHPVersionCheck: Remove obsolete load.php code and simplify for T189966: Audit and simplify MediaWiki initialisation code (Spring 2018)

Screenshot 2021-05-25 at 00.08.06.png (224×1 px, 28 KB)

FWIW, to replicate, just do mv vendor vendor.old in your install folder

Umherirrender subscribed.

NoLocalSettings.php and MissingExtensionException are using $_SERVER['PHP_SELF'], maybe $wgResourceBasePath instead of the script path is just enough as the path must match the path on the file system, not the server path.