Page MenuHomePhabricator

oojs-ui.styles.icons module causes server error 500
Closed, DuplicatePublic

Description

Currently I have installed the recent snapshot of VisualEditor for Mediawiki 1.26.2, which uses OOjs-UI, and configured everything correctly. When I was using Mediawiki 1.25 the VE extension worked perfectly for me, but now, after upgrading every software, VisualEditor stopped working.

Once I checked my DOM console I noticed, that the issue is caused by the module called oojs-ui.styles.icons creating a 500 server error. I also took a look into my error.log file. These are the essential details:

2016/01/31 03:33:47 [error] 1178#0: *50446 FastCGI sent in stderr: "PHP message: PHP Warning:  DOMDocument::load(): I/O warning : failed to load external entity "/var/www/html/Wiki/resources/lib/oojs-ui/themes/mediawiki/images/icons/add.svg" in /var/www/html/Wiki/includes/resourceloader/ResourceLoaderImage.php on line 275
PHP message: PHP Notice:  Trying to get property of non-object in /var/www/html/Wiki/includes/resourceloader/ResourceLoaderImage.php on line 278
PHP message: PHP Fatal error:  Call to a member function appendChild() on a non-object in /var/www/html/Wiki/includes/resourceloader/ResourceLoaderImage.php on line 281" while reading response header from upstream, client: 123.123.123.123, server: domain.com, request: "GET /load.php?debug=true&modules=oojs-ui.styles.icons&* HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "domain.com"

Obviously the filepath can't be recognized, because of the " attribute. So I checked line 275 of the file /var/www/html/Wiki/includes/resourceloader/ResourceLoaderImage.php, which contains the following:

protected function variantize( $variantConf, ResourceLoaderContext $context ) {
	$dom = new DomDocument;
	$dom->load( $this->getPath( $context ) ); ########## Line 275
	$root = $dom->documentElement;
	$wrapper = $dom->createElement( 'g' );
	while ( $root->firstChild ) {
		$wrapper->appendChild( $root->firstChild );
	}
	$root->appendChild( $wrapper );
	$wrapper->setAttribute( 'fill', $variantConf['color'] );
	return $dom->saveXml();
}

Normally, the php function getPath() should work fine, shouldn't it? I also tried to remove all settings in the LocalSettings.php, which were done by me. Then I opened the direct url "http://domain.com/load.php?modules=oojs-ui.styles.icons&*" and the error 500 is still there. I even set the correct permissions for the icon folder and ran the update.php script from the maintenance folder.

Am I the only one with this problem? If yes, can you recommend me a fix?

Event Timeline

Restricted Application added subscribers: StudiesWorld, Aklapper. · View Herald Transcript
DominikGX triaged this task as Medium priority.
DominikGX updated the task description. (Show Details)
DominikGX edited projects, added OOUI; removed SRE-Access-Requests, SRE.
DominikGX changed Security from None to Access Request.
DominikGX edited subscribers, added: DominikGX; removed: Aklapper, StudiesWorld.
Krenair changed Security from Access Request to None.Jan 31 2016, 9:40 PM

If the file "/var/www/html/Wiki/resources/lib/oojs-ui/themes/mediawiki/images/icons/add.svg" definitely exists on your server, this probably means you have some security hardening PHP settings enabled that prevent it from reading that file. I vaguely recall some other report about this…

@DominikGX Can you try replacing that line 275 with:

$dom->loadXml( file_get_contents( $this->getPath( $context ) ) );

And see if that helps?

@matmarex Well, this was a fast solution. Now I am receiving the CSS content, when I visit the direct link. Thank you.
(Even though VE seems to have still some curl issues, but I don't think this is related to this topic.)

Is this going to be updated in the next release or will I have to update it everytime by myself?
(Since I do not know if I am the only one who has this problem.)

Yeah, I'm going to commit that patch. I found that duplicate and it was the same issue you're having. The advantage of DomDocument::load is supposed to be in handling large files, and the icons here are supposed to be small, so we might as well use DomDocument::loadXml if the former doesn't work for some reason.

RobH closed subtask Restricted Task as Resolved.Feb 10 2016, 8:13 PM
bd808 removed a subtask: Restricted Task.Feb 10 2016, 8:30 PM