r111581 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111580‎ | r111581 | r111582 >
Date:20:46, 15 February 2012
Author:reedy
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.19wmf1 (modified) (history)
  • /branches/wmf/1.19wmf1/extensions (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/AbuseFilter/AbuseFilter.class.php (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/AbuseFilter/modules/ext.abuseFilter.css (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/ContributionReporting/ContributionReporting.i18n.magic.php (deleted) (history)
  • /branches/wmf/1.19wmf1/extensions/ContributionReporting/ContributionReporting.magic.php (added) (history)
  • /branches/wmf/1.19wmf1/extensions/wikihiero/SpecialHieroglyphs.php (modified) (history)
  • /branches/wmf/1.19wmf1/includes (modified) (history)
  • /branches/wmf/1.19wmf1/includes/Cdb_PHP.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.19wmf1/extensions/AbuseFilter/AbuseFilter.class.php
@@ -1293,13 +1293,20 @@
12941294 return $user;
12951295 }
12961296
 1297+ /**
 1298+ * @param $rules String
 1299+ * @param $textName String
 1300+ * @param $addResultDiv Boolean
 1301+ * @param $canEdit Boolean
 1302+ */
12971303 static function buildEditBox( $rules, $textName = 'wpFilterRules', $addResultDiv = true,
12981304 $canEdit = true ) {
12991305 global $wgOut;
13001306
1301 - $readOnlyAttrib = array();
1302 - if ( !$canEdit )
1303 - $readOnlyAttrib['readonly'] = 'readonly';
 1307+ $textareaAttrib = array( 'dir' => 'ltr' ); # Rules are in English
 1308+ if ( !$canEdit ) {
 1309+ $textareaAttrib['readonly'] = 'readonly';
 1310+ }
13041311
13051312 global $wgUser;
13061313 $noTestAttrib = array();
@@ -1309,7 +1316,7 @@
13101317 }
13111318
13121319 $rules = rtrim( $rules ) . "\n";
1313 - $rules = Xml::textarea( $textName, $rules, 40, 5, $readOnlyAttrib );
 1320+ $rules = Xml::textarea( $textName, $rules, 40, 5, $textareaAttrib );
13141321
13151322 $dropDown = self::getBuilderValues();
13161323 // Generate builder drop-down
Index: branches/wmf/1.19wmf1/extensions/AbuseFilter/modules/ext.abuseFilter.css
@@ -115,9 +115,6 @@
116116 width: 50%;
117117 }
118118
119 -/* Rules are in English */
120 -/* @noflip */textarea#wpFilterRules { direction: ltr; }
121 -
122119 /* Name is in site content language */
123120 /* @noflip */.sitedir-ltr .TablePager_col_af_public_comments {
124121 direction: ltr;
Index: branches/wmf/1.19wmf1/extensions/wikihiero/SpecialHieroglyphs.php
@@ -47,6 +47,7 @@
4848 $this->setHeaders();
4949 $out = $this->getContext()->getOutput();
5050 $out->addModules( 'ext.wikihiero.Special' );
 51+ $out->addModuleStyles( 'ext.wikihiero.Special' ); // apply CSS during slow load
5152 $out->addWikiMsg( 'wikihiero-special-page-text' );
5253
5354 $out->addHTML( '<div id="hiero-result">' );
Index: branches/wmf/1.19wmf1/extensions/ContributionReporting/ContributionReporting.i18n.magic.php
@@ -1,11 +0,0 @@
2 -<?php
3 -/**
4 - * Magic words for extension.
5 - */
6 -
7 -$magicWords = array();
8 -
9 -/** English (English) */
10 -$magicWords['en'] = array(
11 - 'contributiontotal' => array( 0, 'contributiontotal' ),
12 -);
Index: branches/wmf/1.19wmf1/extensions/ContributionReporting/ContributionReporting.magic.php
@@ -0,0 +1,11 @@
 2+<?php
 3+/**
 4+ * Magic words for extension.
 5+ */
 6+
 7+$magicWords = array();
 8+
 9+/** English (English) */
 10+$magicWords['en'] = array(
 11+ 'contributiontotal' => array( 0, 'contributiontotal' ),
 12+);
Property changes on: branches/wmf/1.19wmf1/extensions/ContributionReporting/ContributionReporting.magic.php
___________________________________________________________________
Added: svn:eol-style
113 + native
Added: svn:keywords
214 + Id
Property changes on: branches/wmf/1.19wmf1/extensions
___________________________________________________________________
Modified: svn:mergeinfo
315 Merged /trunk/extensions:r111043,111484,111575
Index: branches/wmf/1.19wmf1/includes/Cdb_PHP.php
@@ -82,6 +82,9 @@
8383 * CDB reader class
8484 */
8585 class CdbReader_PHP extends CdbReader {
 86+ /** The filename */
 87+ var $fileName;
 88+
8689 /** The file handle */
8790 var $handle;
8891
@@ -110,9 +113,10 @@
111114 * @param $fileName string
112115 */
113116 function __construct( $fileName ) {
 117+ $this->fileName = $fileName;
114118 $this->handle = fopen( $fileName, 'rb' );
115119 if ( !$this->handle ) {
116 - throw new MWException( 'Unable to open CDB file "' . $fileName . '"' );
 120+ throw new MWException( 'Unable to open CDB file "' . $this->fileName . '".' );
117121 }
118122 $this->findStart();
119123 }
@@ -160,7 +164,8 @@
161165 protected function read( $length, $pos ) {
162166 if ( fseek( $this->handle, $pos ) == -1 ) {
163167 // This can easily happen if the internal pointers are incorrect
164 - throw new MWException( __METHOD__.': seek failed, file may be corrupted.' );
 168+ throw new MWException(
 169+ 'Seek failed, file "' . $this->fileName . '" may be corrupted.' );
165170 }
166171
167172 if ( $length == 0 ) {
@@ -169,7 +174,8 @@
170175
171176 $buf = fread( $this->handle, $length );
172177 if ( $buf === false || strlen( $buf ) !== $length ) {
173 - throw new MWException( __METHOD__.': read from CDB file failed, file may be corrupted' );
 178+ throw new MWException(
 179+ 'Read from CDB file failed, file "' . $this->fileName . '" may be corrupted.' );
174180 }
175181 return $buf;
176182 }
@@ -182,7 +188,8 @@
183189 protected function unpack31( $s ) {
184190 $data = unpack( 'V', $s );
185191 if ( $data[1] > 0x7fffffff ) {
186 - throw new MWException( __METHOD__.': error in CDB file, integer too big' );
 192+ throw new MWException(
 193+ 'Error in CDB file "' . $this->fileName . '", integer too big.' );
187194 }
188195 return $data[1];
189196 }
@@ -270,13 +277,14 @@
271278 $this->tmpFileName = $fileName . '.tmp.' . mt_rand( 0, 0x7fffffff );
272279 $this->handle = fopen( $this->tmpFileName, 'wb' );
273280 if ( !$this->handle ) {
274 - throw new MWException( 'Unable to open CDB file for write "' . $fileName . '"' );
 281+ $this->throwException(
 282+ 'Unable to open CDB file "' . $this->tmpFileName . '" for write.' );
275283 }
276284 $this->hplist = array();
277285 $this->numentries = 0;
278286 $this->pos = 2048; // leaving space for the pointer array, 256 * 8
279287 if ( fseek( $this->handle, $this->pos ) == -1 ) {
280 - throw new MWException( __METHOD__.': fseek failed' );
 288+ $this->throwException( 'fseek failed in file "' . $this->tmpFileName . '".' );
281289 }
282290 }
283291
@@ -314,7 +322,7 @@
315323 unlink( $this->realFileName );
316324 }
317325 if ( !rename( $this->tmpFileName, $this->realFileName ) ) {
318 - throw new MWException( 'Unable to move the new CDB file into place.' );
 326+ $this->throwException( 'Unable to move the new CDB file into place.' );
319327 }
320328 unset( $this->handle );
321329 }
@@ -326,7 +334,7 @@
327335 protected function write( $buf ) {
328336 $len = fwrite( $this->handle, $buf );
329337 if ( $len !== strlen( $buf ) ) {
330 - throw new MWException( 'Error writing to CDB file.' );
 338+ $this->throwException( 'Error writing to CDB file "'.$this->tmpFileName.'".' );
331339 }
332340 }
333341
@@ -337,7 +345,8 @@
338346 protected function posplus( $len ) {
339347 $newpos = $this->pos + $len;
340348 if ( $newpos > 0x7fffffff ) {
341 - throw new MWException( 'A value in the CDB file is too large' );
 349+ $this->throwException(
 350+ 'A value in the CDB file "'.$this->tmpFileName.'" is too large.' );
342351 }
343352 $this->pos = $newpos;
344353 }
@@ -366,10 +375,10 @@
367376 */
368377 protected function addbegin( $keylen, $datalen ) {
369378 if ( $keylen > 0x7fffffff ) {
370 - throw new MWException( __METHOD__.': key length too long' );
 379+ $this->throwException( 'Key length too long in file "'.$this->tmpFileName.'".' );
371380 }
372381 if ( $datalen > 0x7fffffff ) {
373 - throw new MWException( __METHOD__.': data length too long' );
 382+ $this->throwException( 'Data length too long in file "'.$this->tmpFileName.'".' );
374383 }
375384 $buf = pack( 'VV', $keylen, $datalen );
376385 $this->write( $buf );
@@ -444,8 +453,22 @@
445454 // Write the pointer array at the start of the file
446455 rewind( $this->handle );
447456 if ( ftell( $this->handle ) != 0 ) {
448 - throw new MWException( __METHOD__.': Error rewinding to start of file' );
 457+ $this->throwException( 'Error rewinding to start of file "'.$this->tmpFileName.'".' );
449458 }
450459 $this->write( $final );
451460 }
 461+
 462+ /**
 463+ * Clean up the temp file and throw an exception
 464+ *
 465+ * @param $msg string
 466+ * @throws MWException
 467+ */
 468+ protected function throwException( $msg ) {
 469+ if ( $this->handle ) {
 470+ fclose( $this->handle );
 471+ unlink( $this->tmpFileName );
 472+ }
 473+ throw new MWException( $msg );
 474+ }
452475 }
Property changes on: branches/wmf/1.19wmf1/includes
___________________________________________________________________
Modified: svn:mergeinfo
453476 Merged /trunk/phase3/includes:r111571,111574
Property changes on: branches/wmf/1.19wmf1
___________________________________________________________________
Modified: svn:mergeinfo
454477 Merged /trunk/phase3:r111571,111574

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111043It's better to set directionality in html than in css. Also fixes bug 34297, ...robin17:00, 9 February 2012
r111484* (bug 34396) Apply Special:Hieroglyphs CSS immediately...brion20:49, 14 February 2012
r111571Put the filename in more of the exceptions thrownaaron20:06, 15 February 2012
r111574Delete the temp cdb file when an exception is thrown so they don't take up /t...aaron20:24, 15 February 2012
r111575fixing bug 34424, hopefullykaldari20:24, 15 February 2012

Status & tagging log