r12349 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r12348‎ | r12349 | r12350 >
Date:12:00, 2 January 2006
Author:robchurch
Status:old
Tags:
Comment:
Add checks when opening and reading the log file, and report errors accordingly
Modified paths:
  • /trunk/extensions/CheckUser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CheckUser.php
@@ -126,11 +126,20 @@
127127 function showLog() {
128128 global $wgOut, $wgCheckUserLog;
129129 $output = '';
130 - $log = array_reverse( file( $wgCheckUserLog ) );
131 - foreach( $log as $log_line ) {
132 - $output .= $log_line;
 130+ if( file_exists( $wgCheckUserLog ) ) {
 131+ $log = file( $wgCheckUserLog );
 132+ if( !!$log ) {
 133+ $log = array_reverse( $log );
 134+ foreach( $log as $log_line ) {
 135+ $output .= $log_line;
 136+ }
 137+ $wgOut->addHTML( '<ul>' . $output . '</ul>' );
 138+ } else {
 139+ $wgOut->addHTML( '<p>The CheckUser log could not be read.</p>' );
 140+ }
 141+ } else {
 142+ $wgOut->addHTML( '<p>The CheckUser log could not be found.</p>' );
133143 }
134 - $wgOut->addHTML( '<ul>' . $output . '</ul>' );
135144 }
136145
137146 function addLogEntry( $entry ) {

Status & tagging log