Last modified: 2013-09-01 20:57:56 UTC
When an extension adds a variable temporarily to the global namespace in their entry point, they should clean up after themselves. The biggest offender would be: $dir = dirname(__FILE__) . '/'; When in the coded $dir isn't needed anymore, it should be unset: unset( $dir ); The other big offender (though, some do clean it up already) is the common code used in $wgResourceModules e.g. $myResourceTemplate = array( 'localBasePath' => dirname( __FILE__ ) . '/modules', 'remoteExtPath' => 'SVGEdit/modules', 'group' => 'ext.svgedit', ); $wgResourceModules += array( 'ext.svgedit.editButton' => $myResourceTemplate + array( 'scripts' => array( 'ext.svgedit.editButton.js', ), 'messages' => array( 'svgedit-editbutton-edit', 'svgedit-edit-tab', 'svgedit-edit-tab-tooltip' ), 'dependencies' => array( 'ext.svgedit.editor' ) ), ); $myResourceTemplate should be unset when it's not needed anymore: unset( $myResourceTemplate ); Should be a pretty easy thing to tidy up, committing would be more difficult (with SVN it could be one bigger commit) as it needs one commit per repo that needs cleaning up.
Change 76243 had a related patch set uploaded by Legoktm: 'Cleaning up unused variables in the global space https://gerrit.wikimedia.org/r/76243
Change 76244 had a related patch set uploaded by Legoktm: Cleaning up unused variables in the global space https://gerrit.wikimedia.org/r/76244
In order to avoid spamming this bug with messages for each of the 500+ extensions, I'll adjust the commit summary so it won't explicitly mention the bug.
Change 76245 had a related patch set uploaded by Legoktm: Cleaning up unused variables in the global space https://gerrit.wikimedia.org/r/76245
Ok, after speaking with Ori in #wikimedia-dev, it seems this may not be the best idea ever. Log: http://bots.wmflabs.org/~wm-bot/logs/%23wikimedia-dev/20130727.txt <ori-l> so: chance of unsetting needed global; noise for reviewers; __DIR__ being better than $dir anyhow; no convincing rationale other than 'tidyness' === don't do it I've already submitted 22 patchsets (https://gerrit.wikimedia.org/r/#/q/topic:bug/47514,p,0026adb8000129d4) which probably should get abandoned...
(In reply to comment #5) > I've already submitted 22 patchsets > (https://gerrit.wikimedia.org/r/#/q/topic:bug/47514,p,0026adb8000129d4) which > probably should get abandoned... :[ Could someone clarify the status of this bug and WONTFIX it if appropriate, so that patches can be abandoned, or otherwise let it proceed?
No rationale was provided why this practice is problematic. If we in the future go away from registering stuff in the global scope, then we would need to remove the unsets or if removed, could again introduce these temporarily variables.
Change 76243 abandoned by Legoktm: Cleaning up unused variables in the global space https://gerrit.wikimedia.org/r/76243
Change 76244 abandoned by Legoktm: Cleaning up unused variables in the global space https://gerrit.wikimedia.org/r/76244
Change 76245 abandoned by Legoktm: Cleaning up unused variables in the global space https://gerrit.wikimedia.org/r/76245