On Wed, Feb 20, 2008 at 6:52 AM, Tim Starling
<tstarling(a)wikimedia.org> wrote:
A bug was introduced in r25374 by Aaron, last
September, and despite half
a dozen people editing the few lines around that point, nobody picked it
up. Simetrical eventually fixed it in r29156, blaming a bug in PHP's
array_diff(). It was not.
$permErrors += array_diff(
$this->mTitle->getUserPermissionsErrors('create', $wgUser),
$permErrors );
What I said is another reason the code didn't work, though, AFAICT.
http://www.php.net/manual/en/function.array-diff.php
"Note: Two elements are considered equal if and only if (string)
$elem1 === (string) $elem2. In words: when the string representation
is the same."
In particular, any array is equal to "Array" when cast to a string,
and so any two arrays are equal for this purpose, as I said in the
comment accompanying my fix. Both $permErrors and the return value of
getUserPermissionsErrors() were arrays of arrays, and *any* two arrays
of arrays will have an empty difference according to array_diff().
Even if the code had been
$permErrors = array_merge( $permErrors, array_diff(
$this->mTitle->getUserPermissionsErrors('create', $wgUser),
$permErrors
));
it would have included no reasons for why the user couldn't edit,
because you're merging with an empty array. Am I wrong?
Yes, two bugs on the same line. You could have fixed the array comparison
problem using array_udiff(), but then you would have been left with the
array plus problem.
-- Tim Starling