r89707 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89706‎ | r89707 | r89708 >
Date:22:30, 7 June 2011
Author:wikinaut
Status:ok (Comments)
Tags:
Comment:
quick fix for bug28983 . Do not use $path in the loop. Even the remaining $e is dangerous subject to change from the require-once-loaded extensions. This is NOT A FINAL fix, just a small improvement
Modified paths:
  • /trunk/phase3/includes/installer/Installer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/Installer.php
@@ -1224,7 +1224,6 @@
12251225 global $IP;
12261226 $exts = $this->getVar( '_Extensions' );
12271227 $IP = $this->getVar( 'IP' );
1228 - $path = $IP . '/extensions';
12291228
12301229 /**
12311230 * We need to include DefaultSettings before including extensions to avoid
@@ -1240,7 +1239,7 @@
12411240 require( "$IP/includes/DefaultSettings.php" );
12421241
12431242 foreach( $exts as $e ) {
1244 - require_once( "$path/$e/$e.php" );
 1243+ require_once( $IP . '/extensions' . "/$e/$e.php" );
12451244 }
12461245
12471246 $hooksWeWant = isset( $wgHooks['LoadExtensionSchemaUpdates'] ) ?

Follow-up revisions

RevisionCommit summaryAuthorDate
r89708Follow up r89707. No need for the explicit concatenations.platonides22:33, 7 June 2011
r897411.17: MFT r84739, r89707catrope20:19, 8 June 2011
r92348MFT to REL1_18:...hashar08:57, 16 July 2011

Comments

#Comment by Wikinaut (talk | contribs)   22:31, 7 June 2011

remaining problem: $e . If an extensions take the liberty to use $e , it changes the loop.

Please fix finally.

#Comment by Wikinaut (talk | contribs)   22:32, 7 June 2011

s/take/takes/ (my keyboard does not like me)

#Comment by Wikinaut (talk | contribs)   22:34, 7 June 2011

Attention, we need a better code for the loop to avoid $e. Any volunteers?

#Comment by Platonides (talk | contribs)   22:42, 7 June 2011

This is prefectly sane. On the next iteration foreach() sets $e again, so the changed $e would not corrupt it.

A change to $ext looks more suspicious, but it is locked by the foreach, so no problem there, either.

<?php

$a = array( 1, 2, 3 );

foreach( $a as $b ) {
	echo "$b\n";
	$a = array( 'foo', 'bar', 'baz' );
	$b = 'Hello World!';
}

outputs

1
2
3

(and leaves $a set to 'foo', 'bar', 'baz')

#Comment by Catrope (talk | contribs)   11:36, 8 June 2011

Foreach runs on a copy of the array, so changing or overwriting $ext has no effect on the loop. This fix looks sufficient to me. Tagging 1.17, 1.18

#Comment by Wikinaut (talk | contribs)   22:44, 7 June 2011

Oops, I overlooked that, yes, thanks, will try to remember this.

+++ I am happy that the issue of "installation plus extensions" appears now finally be solved +++

#Comment by 😂 (talk | contribs)   01:17, 8 June 2011

I could rename it to $pleaseDontNameYourVariableThis ;-)

Status & tagging log