Index: trunk/phase3/includes/filerepo/backend/FSFileBackend.php |
— | — | @@ -405,17 +405,19 @@ |
406 | 406 | return false; // invalid storage path |
407 | 407 | } |
408 | 408 | |
409 | | - wfSuppressWarnings(); |
| 409 | + $this->trapWarnings(); |
410 | 410 | $stat = is_file( $source ) ? stat( $source ) : false; // regular files only |
411 | | - wfRestoreWarnings(); |
| 411 | + $hadError = $this->untrapWarnings(); |
412 | 412 | |
413 | 413 | if ( $stat ) { |
414 | 414 | return array( |
415 | 415 | 'mtime' => wfTimestamp( TS_MW, $stat['mtime'] ), |
416 | 416 | 'size' => $stat['size'] |
417 | 417 | ); |
| 418 | + } elseif ( !$hadError ) { |
| 419 | + return false; // file does not exist |
418 | 420 | } else { |
419 | | - return false; |
| 421 | + return null; // failure |
420 | 422 | } |
421 | 423 | } |
422 | 424 | |
— | — | @@ -495,6 +497,31 @@ |
496 | 498 | |
497 | 499 | return $ok; |
498 | 500 | } |
| 501 | + |
| 502 | + /** |
| 503 | + * Suppress E_WARNING errors and track whether any happen |
| 504 | + * |
| 505 | + * @return void |
| 506 | + */ |
| 507 | + protected function trapWarnings() { |
| 508 | + $this->hadWarningErrors[] = false; // push to stack |
| 509 | + set_error_handler( array( $this, 'handleWarning' ), E_WARNING ); |
| 510 | + } |
| 511 | + |
| 512 | + /** |
| 513 | + * Unsuppress E_WARNING errors and return true if any happened |
| 514 | + * |
| 515 | + * @return bool |
| 516 | + */ |
| 517 | + protected function untrapWarnings() { |
| 518 | + restore_error_handler(); // restore previous handler |
| 519 | + return array_pop( $this->hadWarningErrors ); // pop from stack |
| 520 | + } |
| 521 | + |
| 522 | + private function handleWarning() { |
| 523 | + $this->hadWarningErrors[count( $this->hadWarningErrors ) - 1] = true; |
| 524 | + return true; // suppress from PHP handler |
| 525 | + } |
499 | 526 | } |
500 | 527 | |
501 | 528 | /** |
Index: trunk/phase3/includes/filerepo/backend/FileBackend.php |
— | — | @@ -305,9 +305,9 @@ |
306 | 306 | abstract protected function doPrepare( array $params ); |
307 | 307 | |
308 | 308 | /** |
309 | | - * Take measures to block web access to a directory and |
| 309 | + * Take measures to block web access to a storage directory and |
310 | 310 | * the container it belongs to. FS backends might add .htaccess |
311 | | - * files wheras backends like Swift this might restrict container |
| 311 | + * files whereas backends like Swift this might restrict container |
312 | 312 | * access to backend user that represents end-users in web request. |
313 | 313 | * This is not guaranteed to actually do anything. |
314 | 314 | * |
— | — | @@ -774,6 +774,8 @@ |
775 | 775 | return $status; |
776 | 776 | } |
777 | 777 | |
| 778 | + clearstatcache(); // temp file changed |
| 779 | + |
778 | 780 | return $status; |
779 | 781 | } |
780 | 782 | |