r113040 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113039‎ | r113040 | r113041 >
Date:15:15, 5 March 2012
Author:reedy
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/REL1_19/phase3 (modified) (history)
  • /branches/REL1_19/phase3/docs/hooks.txt (modified) (history)
  • /branches/REL1_19/phase3/includes (modified) (history)
  • /branches/REL1_19/phase3/includes/AjaxResponse.php (modified) (history)
  • /branches/REL1_19/phase3/includes/Article.php (modified) (history)
  • /branches/REL1_19/phase3/includes/api (modified) (history)
  • /branches/REL1_19/phase3/includes/api/ApiQueryLogEvents.php (modified) (history)
  • /branches/REL1_19/phase3/includes/filerepo/backend/FSFileBackend.php (modified) (history)
  • /branches/REL1_19/phase3/includes/filerepo/backend/FileBackend.php (modified) (history)
  • /branches/REL1_19/phase3/resources/mediawiki.action/mediawiki.action.history.diff.css (modified) (history)

Diff [purge]

Index: branches/REL1_19/phase3/docs/hooks.txt
@@ -587,6 +587,11 @@
588588 Change $bad and return false to override. If an image is "bad", it is not
589589 rendered inline in wiki pages or galleries in category pages.
590590
 591+'BeforeDisplayNoArticleText': before displaying noarticletext or noarticletext-nopermission
 592+at Article::showMissingArticle()
 593+
 594+$article: article object
 595+
591596 'BeforeInitialize': before anything is initialized in MediaWiki::performRequest()
592597 &$title: Title being used for request
593598 $unused: null
Index: branches/REL1_19/phase3/includes/Article.php
@@ -988,6 +988,18 @@
989989 'msgKey' => array( 'moveddeleted-notice' ) )
990990 );
991991
 992+ if ( !$this->mPage->hasViewableContent() && $wgSend404Code ) {
 993+ // If there's no backing content, send a 404 Not Found
 994+ // for better machine handling of broken links.
 995+ $wgRequest->response()->header( "HTTP/1.1 404 Not Found" );
 996+ }
 997+
 998+ $hookResult = wfRunHooks( 'BeforeDisplayNoArticleText', array( $this ) );
 999+
 1000+ if ( ! $hookResult ) {
 1001+ return;
 1002+ }
 1003+
9921004 # Show error message
9931005 $oldid = $this->getOldID();
9941006 if ( $oldid ) {
@@ -1010,12 +1022,6 @@
10111023 }
10121024 $text = "<div class='noarticletext'>\n$text\n</div>";
10131025
1014 - if ( !$this->mPage->hasViewableContent() && $wgSend404Code ) {
1015 - // If there's no backing content, send a 404 Not Found
1016 - // for better machine handling of broken links.
1017 - $wgRequest->response()->header( "HTTP/1.1 404 Not Found" );
1018 - }
1019 -
10201026 $wgOut->addWikiText( $text );
10211027 }
10221028
Index: branches/REL1_19/phase3/includes/filerepo/backend/FSFileBackend.php
@@ -16,7 +16,7 @@
1717 * Sharding can be accomplished by using FileRepo-style hash paths.
1818 *
1919 * Status messages should avoid mentioning the internal FS paths.
20 - * Likewise, error suppression should be used to avoid path disclosure.
 20+ * PHP warnings are assumed to be logged rather than output.
2121 *
2222 * @ingroup FileBackend
2323 * @since 1.19
@@ -41,14 +41,13 @@
4242 parent::__construct( $config );
4343
4444 // Remove any possible trailing slash from directories
45 -
4645 if ( isset( $config['basePath'] ) ) {
4746 $this->basePath = rtrim( $config['basePath'], '/' ); // remove trailing slash
4847 } else {
4948 $this->basePath = null; // none; containers must have explicit paths
5049 }
5150
52 - if( isset( $config['containerPaths'] ) ) {
 51+ if ( isset( $config['containerPaths'] ) ) {
5352 $this->containerPaths = (array)$config['containerPaths'];
5453 foreach ( $this->containerPaths as &$path ) {
5554 $path = rtrim( $path, '/' ); // remove trailing slash
@@ -138,13 +137,11 @@
139138 }
140139 $parentDir = dirname( $fsPath );
141140
142 - wfSuppressWarnings();
143141 if ( file_exists( $fsPath ) ) {
144142 $ok = is_file( $fsPath ) && is_writable( $fsPath );
145143 } else {
146144 $ok = is_dir( $parentDir ) && is_writable( $parentDir );
147145 }
148 - wfRestoreWarnings();
149146
150147 return $ok;
151148 }
@@ -163,9 +160,7 @@
164161
165162 if ( file_exists( $dest ) ) {
166163 if ( !empty( $params['overwrite'] ) ) {
167 - wfSuppressWarnings();
168164 $ok = unlink( $dest );
169 - wfRestoreWarnings();
170165 if ( !$ok ) {
171166 $status->fatal( 'backend-fail-delete', $params['dst'] );
172167 return $status;
@@ -176,9 +171,7 @@
177172 }
178173 }
179174
180 - wfSuppressWarnings();
181175 $ok = copy( $params['src'], $dest );
182 - wfRestoreWarnings();
183176 if ( !$ok ) {
184177 $status->fatal( 'backend-fail-store', $params['src'], $params['dst'] );
185178 return $status;
@@ -209,9 +202,7 @@
210203
211204 if ( file_exists( $dest ) ) {
212205 if ( !empty( $params['overwrite'] ) ) {
213 - wfSuppressWarnings();
214206 $ok = unlink( $dest );
215 - wfRestoreWarnings();
216207 if ( !$ok ) {
217208 $status->fatal( 'backend-fail-delete', $params['dst'] );
218209 return $status;
@@ -222,9 +213,7 @@
223214 }
224215 }
225216
226 - wfSuppressWarnings();
227217 $ok = copy( $source, $dest );
228 - wfRestoreWarnings();
229218 if ( !$ok ) {
230219 $status->fatal( 'backend-fail-copy', $params['src'], $params['dst'] );
231220 return $status;
@@ -257,9 +246,7 @@
258247 if ( !empty( $params['overwrite'] ) ) {
259248 // Windows does not support moving over existing files
260249 if ( wfIsWindows() ) {
261 - wfSuppressWarnings();
262250 $ok = unlink( $dest );
263 - wfRestoreWarnings();
264251 if ( !$ok ) {
265252 $status->fatal( 'backend-fail-delete', $params['dst'] );
266253 return $status;
@@ -271,10 +258,8 @@
272259 }
273260 }
274261
275 - wfSuppressWarnings();
276262 $ok = rename( $source, $dest );
277263 clearstatcache(); // file no longer at source
278 - wfRestoreWarnings();
279264 if ( !$ok ) {
280265 $status->fatal( 'backend-fail-move', $params['src'], $params['dst'] );
281266 return $status;
@@ -302,9 +287,7 @@
303288 return $status; // do nothing; either OK or bad status
304289 }
305290
306 - wfSuppressWarnings();
307291 $ok = unlink( $source );
308 - wfRestoreWarnings();
309292 if ( !$ok ) {
310293 $status->fatal( 'backend-fail-delete', $params['src'] );
311294 return $status;
@@ -327,9 +310,7 @@
328311
329312 if ( file_exists( $dest ) ) {
330313 if ( !empty( $params['overwrite'] ) ) {
331 - wfSuppressWarnings();
332314 $ok = unlink( $dest );
333 - wfRestoreWarnings();
334315 if ( !$ok ) {
335316 $status->fatal( 'backend-fail-delete', $params['dst'] );
336317 return $status;
@@ -340,9 +321,7 @@
341322 }
342323 }
343324
344 - wfSuppressWarnings();
345325 $bytes = file_put_contents( $dest, $params['content'] );
346 - wfRestoreWarnings();
347326 if ( $bytes === false ) {
348327 $status->fatal( 'backend-fail-create', $params['dst'] );
349328 return $status;
@@ -381,9 +360,7 @@
382361 $dir = ( $dirRel != '' ) ? "{$contRoot}/{$dirRel}" : $contRoot;
383362 // Seed new directories with a blank index.html, to prevent crawling...
384363 if ( !empty( $params['noListing'] ) && !file_exists( "{$dir}/index.html" ) ) {
385 - wfSuppressWarnings();
386364 $bytes = file_put_contents( "{$dir}/index.html", '' );
387 - wfRestoreWarnings();
388365 if ( !$bytes ) {
389366 $status->fatal( 'backend-fail-create', $params['dir'] . '/index.html' );
390367 return $status;
@@ -392,9 +369,7 @@
393370 // Add a .htaccess file to the root of the container...
394371 if ( !empty( $params['noAccess'] ) ) {
395372 if ( !file_exists( "{$contRoot}/.htaccess" ) ) {
396 - wfSuppressWarnings();
397373 $bytes = file_put_contents( "{$contRoot}/.htaccess", "Deny from all\n" );
398 - wfRestoreWarnings();
399374 if ( !$bytes ) {
400375 $storeDir = "mwstore://{$this->name}/{$shortCont}";
401376 $status->fatal( 'backend-fail-create', "{$storeDir}/.htaccess" );
@@ -430,7 +405,7 @@
431406 return false; // invalid storage path
432407 }
433408
434 - $this->trapWarnings();
 409+ $this->trapWarnings(); // don't trust 'false' if there were errors
435410 $stat = is_file( $source ) ? stat( $source ) : false; // regular files only
436411 $hadError = $this->untrapWarnings();
437412
@@ -460,16 +435,12 @@
461436 list( $b, $shortCont, $r ) = FileBackend::splitStoragePath( $params['dir'] );
462437 $contRoot = $this->containerFSRoot( $shortCont, $fullCont ); // must be valid
463438 $dir = ( $dirRel != '' ) ? "{$contRoot}/{$dirRel}" : $contRoot;
464 - wfSuppressWarnings();
465439 $exists = is_dir( $dir );
466 - wfRestoreWarnings();
467440 if ( !$exists ) {
468441 wfDebug( __METHOD__ . "() given directory does not exist: '$dir'\n" );
469442 return array(); // nothing under this dir
470443 }
471 - wfSuppressWarnings();
472444 $readable = is_readable( $dir );
473 - wfRestoreWarnings();
474445 if ( !$readable ) {
475446 wfDebug( __METHOD__ . "() given directory is unreadable: '$dir'\n" );
476447 return null; // bad permissions?
@@ -506,9 +477,7 @@
507478 $tmpPath = $tmpFile->getPath();
508479
509480 // Copy the source file over the temp file
510 - wfSuppressWarnings();
511481 $ok = copy( $source, $tmpPath );
512 - wfRestoreWarnings();
513482 if ( !$ok ) {
514483 return null;
515484 }
@@ -533,17 +502,18 @@
534503 }
535504
536505 /**
537 - * Suppress E_WARNING errors and track whether any happen
 506+ * Listen for E_WARNING errors and track whether any happen
538507 *
539 - * @return void
 508+ * @return bool
540509 */
541510 protected function trapWarnings() {
542511 $this->hadWarningErrors[] = false; // push to stack
543512 set_error_handler( array( $this, 'handleWarning' ), E_WARNING );
 513+ return false; // invoke normal PHP error handler
544514 }
545515
546516 /**
547 - * Unsuppress E_WARNING errors and return true if any happened
 517+ * Stop listening for E_WARNING errors and return true if any happened
548518 *
549519 * @return bool
550520 */
Index: branches/REL1_19/phase3/includes/filerepo/backend/FileBackend.php
@@ -1236,7 +1236,7 @@
12371237 }
12381238
12391239 // Set output buffer and HTTP headers for stream
1240 - $extraHeaders = $params['headers'] ? $params['headers'] : array();
 1240+ $extraHeaders = isset( $params['headers'] ) ? $params['headers'] : array();
12411241 $res = StreamFile::prepareForStream( $params['src'], $info, $extraHeaders );
12421242 if ( $res == StreamFile::NOT_MODIFIED ) {
12431243 // do nothing; client cache is up to date
Index: branches/REL1_19/phase3/includes/api/ApiQueryLogEvents.php
@@ -197,26 +197,44 @@
198198 * @param $ts
199199 * @return array
200200 */
201 - public static function addLogParams( $result, &$vals, $params, $type, $action, $ts ) {
202 - $params = explode( "\n", $params );
 201+ public static function addLogParams( $result, &$vals, $params, $type, $action, $ts, $legacy = false ) {
203202 switch ( $type ) {
204203 case 'move':
205 - if ( isset( $params[0] ) ) {
206 - $title = Title::newFromText( $params[0] );
 204+ if ( $legacy ){
 205+ $targetKey = 0;
 206+ $noredirKey = 1;
 207+ } else {
 208+ $targetKey = '4::target';
 209+ $noredirKey = '5::noredir';
 210+ }
 211+
 212+ if ( isset( $params[ $targetKey ] ) ) {
 213+ $title = Title::newFromText( $params[ $targetKey ] );
207214 if ( $title ) {
208215 $vals2 = array();
209216 ApiQueryBase::addTitleInfo( $vals2, $title, 'new_' );
210217 $vals[$type] = $vals2;
211218 }
212219 }
213 - if ( isset( $params[1] ) && $params[1] ) {
 220+ if ( isset( $params[ $noredirKey ] ) && $params[ $noredirKey ] ) {
214221 $vals[$type]['suppressedredirect'] = '';
215222 }
216223 $params = null;
217224 break;
218225 case 'patrol':
 226+ if ( $legacy ){
 227+ $cur = 0;
 228+ $prev = 1;
 229+ $auto = 2;
 230+ } else {
 231+ $cur = '4::curid';
 232+ $prev = '5::previd';
 233+ $auto = '6::auto';
 234+ }
219235 $vals2 = array();
220 - list( $vals2['cur'], $vals2['prev'], $vals2['auto'] ) = $params;
 236+ $vals2['cur'] = $params[$cur];
 237+ $vals2['prev'] = $params[$prev];
 238+ $vals2['auto'] = $params[$auto];
221239 $vals[$type] = $vals2;
222240 $params = null;
223241 break;
@@ -250,6 +268,7 @@
251269 }
252270
253271 private function extractRowInfo( $row ) {
 272+ $logEntry = DatabaseLogEntry::newFromRow( $row );
254273 $vals = array();
255274
256275 if ( $this->fld_ids ) {
@@ -281,10 +300,11 @@
282301 self::addLogParams(
283302 $this->getResult(),
284303 $vals,
285 - $row->log_params,
286 - $row->log_type,
287 - $row->log_action,
288 - $row->log_timestamp
 304+ $logEntry->getParameters(),
 305+ $logEntry->getType(),
 306+ $logEntry->getSubtype(),
 307+ $logEntry->getTimestamp(),
 308+ $logEntry->isLegacy()
289309 );
290310 }
291311 }
Property changes on: branches/REL1_19/phase3/includes/api
___________________________________________________________________
Modified: svn:mergeinfo
292312 Merged /trunk/phase3/includes/api:r112374,112383,112700,112750,112855
Index: branches/REL1_19/phase3/includes/AjaxResponse.php
@@ -180,11 +180,11 @@
181181 $this->disable();
182182 $this->mLastModified = $lastmod;
183183
184 - wfDebug( "$fname: CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp ; site $wgCacheEpoch\n", false );
 184+ wfDebug( "$fname: CACHED client: $ismodsince ; user: {$wgUser->getTouched()} ; page: $timestamp ; site $wgCacheEpoch\n", false );
185185
186186 return true;
187187 } else {
188 - wfDebug( "$fname: READY client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp ; site $wgCacheEpoch\n", false );
 188+ wfDebug( "$fname: READY client: $ismodsince ; user: {$wgUser->getTouched()} ; page: $timestamp ; site $wgCacheEpoch\n", false );
189189 $this->mLastModified = $lastmod;
190190 }
191191 } else {
Property changes on: branches/REL1_19/phase3/includes
___________________________________________________________________
Modified: svn:mergeinfo
192192 Merged /trunk/phase3/includes:r111427,112347,112374,112383,112700,112750,112855
Index: branches/REL1_19/phase3/resources/mediawiki.action/mediawiki.action.history.diff.css
@@ -1,54 +1,39 @@
2 -/**
3 - * Diff rendering
4 - */
5 -
 2+/*
 3+** Diff rendering
 4+*/
 5+table.diff, td.diff-otitle, td.diff-ntitle {
 6+ background-color: white;
 7+}
68 td.diff-otitle,
79 td.diff-ntitle {
810 text-align: center;
911 }
10 -
1112 td.diff-marker {
1213 text-align: right;
1314 }
14 -
1515 td.diff-lineno {
1616 font-weight: bold;
1717 }
18 -
19 -td.diff-addedline,
20 -td.diff-deletedline,
21 -td.diff-context {
22 - font-size: 88%;
23 - vertical-align: top;
24 - white-space: -moz-pre-wrap;
25 - white-space: pre-wrap;
26 -}
27 -
2818 td.diff-addedline {
29 - background: #E0ECFF;
 19+ background: #cfc;
 20+ font-size: smaller;
3021 }
31 -
3222 td.diff-deletedline {
33 - background: #FCF8CC;
 23+ background: #ffa;
 24+ font-size: smaller;
3425 }
35 -
3626 td.diff-context {
37 - background: #F2F2F2;
 27+ background: #eee;
 28+ font-size: smaller;
3829 }
39 -
4030 .diffchange {
 31+ color: red;
4132 font-weight: bold;
 33+ white-space: -moz-pre-wrap;
 34+ white-space: pre-wrap;
4235 text-decoration: none;
4336 }
4437
45 -td.diff-addedline .diffchange {
46 - background: #B0C8FF;
47 -}
48 -
49 -td.diff-deletedline .diffchange {
50 - background: #FFD084;
51 -}
52 -
5338 table.diff {
5439 border: none;
5540 width: 98%;
@@ -57,25 +42,20 @@
5843 /* Ensure that colums are of equal width */
5944 table-layout: fixed;
6045 }
61 -
6246 table.diff td {
6347 padding: 0;
6448 }
65 -
6649 table.diff col.diff-marker {
6750 width: 2%;
6851 }
69 -
7052 table.diff col.diff-content {
7153 width: 48%;
7254 }
73 -
7455 table.diff td div {
7556 /* Force-wrap very long lines such as URLs or page-widening char strings.*/
7657 word-wrap: break-word;
7758
7859 /* As fallback (FF<3.5, Opera <10.5), scrollbars will be added for very wide cells
79 - * instead of text overflowing or widening
80 - */
 60+ instead of text overflowing or widening */
8161 overflow: auto;
8262 }
Property changes on: branches/REL1_19/phase3
___________________________________________________________________
Modified: svn:mergeinfo
8363 Merged /trunk/phase3:r111427,112347,112374,112383,112700,112750,112855

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111427Port (with changes) r110866 to trunk. Reviewed by Brion before commit.werdna22:32, 13 February 2012
r112347In FSFileBackend:...aaron20:10, 24 February 2012
r112374Attempting to address bug 34653; It seems ApiQueryLogEvents has not kept up w...awjrichards23:39, 24 February 2012
r112383Fixed $headers check in streamFile() to use isset()aaron02:01, 25 February 2012
r112700Followup r112374/bug 34653...reedy17:50, 29 February 2012
r112750[mediawiki.action.history.diff.css] Revert 1.19 style changes back to how it ...krinkle01:07, 1 March 2012
r112855Add some {}...reedy00:15, 2 March 2012

Status & tagging log