Last modified: 2013-09-01 20:57:56 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T49514, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 47514 - Extensions should clean up after themselves in the global namespace
Extensions should clean up after themselves in the global namespace
Status: RESOLVED WONTFIX
Product: MediaWiki extensions
Classification: Unclassified
General/Unknown (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Kunal Mehta (Legoktm)
: easy
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-04-22 20:41 UTC by Sam Reed (reedy)
Modified: 2013-09-01 20:57 UTC (History)
7 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Sam Reed (reedy) 2013-04-22 20:41:36 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.
Comment 1 Gerrit Notification Bot 2013-07-27 07:16:41 UTC
Change 76243 had a related patch set uploaded by Legoktm:
 'Cleaning up unused variables in the global space

https://gerrit.wikimedia.org/r/76243
Comment 2 Gerrit Notification Bot 2013-07-27 07:20:35 UTC
Change 76244 had a related patch set uploaded by Legoktm:
 Cleaning up unused variables in the global space

https://gerrit.wikimedia.org/r/76244
Comment 3 Kunal Mehta (Legoktm) 2013-07-27 07:21:47 UTC
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.
Comment 4 Gerrit Notification Bot 2013-07-27 07:23:35 UTC
Change 76245 had a related patch set uploaded by Legoktm:
 Cleaning up unused variables in the global space

https://gerrit.wikimedia.org/r/76245
Comment 5 Kunal Mehta (Legoktm) 2013-07-27 08:24:21 UTC
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...
Comment 6 Nemo 2013-08-11 13:16:36 UTC
(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?
Comment 7 Niklas Laxström 2013-09-01 09:55:36 UTC
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.
Comment 8 Gerrit Notification Bot 2013-09-01 20:57:33 UTC
Change 76243 abandoned by Legoktm:
Cleaning up unused variables in the global space

https://gerrit.wikimedia.org/r/76243
Comment 9 Gerrit Notification Bot 2013-09-01 20:57:48 UTC
Change 76244 abandoned by Legoktm:
 Cleaning up unused variables in the global space

https://gerrit.wikimedia.org/r/76244
Comment 10 Gerrit Notification Bot 2013-09-01 20:57:56 UTC
Change 76245 abandoned by Legoktm:
 Cleaning up unused variables in the global space

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

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links