r106760 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106759‎ | r106760 | r106761 >
Date:06:16, 20 December 2011
Author:bawolff
Status:ok
Tags:
Comment:
If you request LogEventList to display the combination of 2 log types, and one of
those logs are restricted, will generate a warning, since it removes first entry of
array, but doesn't re-index the array, and subsequent code makes assumptions of the
form if ( count( $this->types ) $singleType = $this->types[0] (which doesn't work, as
first index is 1).

Thus cause array to be re-indexed if a $wgLogRestriction causes a log type to be removed.

Steps to reproduce the issue is make deletion log restricted, then view a (non-existent) user page.

Personally I think its kind of weird/wrong that if someone restricts both the move and delete log,
then viewing a non-existent will give "This page has been deleted, here's delete log:" followed by an
entry from *any* public log.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/logging/LogEventsList.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -185,6 +185,8 @@
186186 * (bug 32414) Empty page get a empty bytes attribute in Export/Dump.
187187 * (bug 33101) Viewing a User or User talk of username resembling IP ending
188188 with .xxx causes Internal error
 189+* Warning about undefined index in certain situations when $wgLogRestrictions
 190+ causes the first log type requested to be removed but not the others
189191
190192 === API changes in 1.19 ===
191193 * (bug 19838) siprop=interwikimap can now use the interwiki cache.
Index: trunk/phase3/includes/logging/LogEventsList.php
@@ -826,13 +826,20 @@
827827 // If $types is not an array, make it an array
828828 $types = ($types === '') ? array() : (array)$types;
829829 // Don't even show header for private logs; don't recognize it...
 830+ $needReindex = false;
830831 foreach ( $types as $type ) {
831832 if( isset( $wgLogRestrictions[$type] )
832833 && !$this->getUser()->isAllowed($wgLogRestrictions[$type])
833834 ) {
 835+ $needReindex = true;
834836 $types = array_diff( $types, array( $type ) );
835837 }
836838 }
 839+ if ( $needReindex ) {
 840+ // Lots of this code makes assumptions that
 841+ // the first entry in the array is $types[0].
 842+ $types = array_values( $types );
 843+ }
837844 $this->types = $types;
838845 // Don't show private logs to unprivileged users.
839846 // Also, only show them upon specific request to avoid suprises.

Status & tagging log