Page MenuHomePhabricator

convertExtensionToRegistration.php does not set defaults for globals, so $wgResourceModules += array(...) and similar cause fatals
Closed, ResolvedPublic

Description

$ php ../../maintenance/convertExtensionToRegistration.php VisualEditor.php
Fatal error: Invalid operand type was used: cannot perform this operation with arrays in /vagrant/mediawiki/extensions/VisualEditor/VisualEditor.php on line 1446

(Tested against VisualEditor rEVED560cd3edf7675069ee92fe8a31373a7ce74392ae.)

Details

Related Gerrit Patches:

Event Timeline

Jdforrester-WMF raised the priority of this task from to Needs Triage.
Jdforrester-WMF updated the task description. (Show Details)

The general issue here is that we're not setting defaults for the globals, so constructs like $wgResourceModules += array( ... ) will fail since $wgResourceModules doesn't exist in the function scope. A quick hack around this is to add: $wgResourceModules = array() right to the line before while running the conversion script. VE also does an array_merge with $wgContentNamespaces, which has the same issue.

Legoktm renamed this task from convertExtensionToRegistration.php fails on VisualEditor.php to convertExtensionToRegistration.php does not set defaults for globals, so $wgResourceModules += array(...) and similar cause fatals.Jan 9 2015, 4:40 PM
Legoktm set Security to None.
Legoktm triaged this task as High priority.Jan 9 2015, 5:51 PM

My quick grep shows that there are enough extensions doing something like this so it makes sense to fix it in the script.

Change 184208 had a related patch set uploaded (by Legoktm):
Handle more cases in convertExtensionToRegistration.php

https://gerrit.wikimedia.org/r/184208

Patch-For-Review

Legoktm claimed this task.Jan 11 2015, 4:27 AM

Above patch fixes nearly everything. I'm not sure how to interpret $wgVisualEditorNamespaces = array_merge( $wgContentNamespaces, array( NS_USER ) ); though.

Is that supposed to represent the content namespaces that have been customized by individual wikis? Or the value from DefaultSettings.php?

Above patch fixes nearly everything. I'm not sure how to interpret $wgVisualEditorNamespaces = array_merge( $wgContentNamespaces, array( NS_USER ) ); though.
Is that supposed to represent the content namespaces that have been customized by individual wikis? Or the value from DefaultSettings.php?

The value that's been customised; we achieve it by loading VE late. As you said, we should do this in a better way.

Change 184208 merged by jenkins-bot:
Handle more cases in convertExtensionToRegistration.php

https://gerrit.wikimedia.org/r/184208

Legoktm closed this task as Resolved.Jan 13 2015, 7:21 PM
bd808 moved this task from Done to Archive on the MediaWiki-Core-Team board.Jan 20 2015, 10:11 PM
Legoktm moved this task from Backlog to Done on the MediaWiki-Configuration board.Mar 4 2015, 7:54 AM