r110163 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110162‎ | r110163 | r110164 >
Date:20:35, 27 January 2012
Author:aaron
Status:ok
Tags:
Comment:
Follow-up r110159: set the FilesystemIterator flags when that class is available (PHP >= 5.3). Apparently, some versions of PHP 5.3 have different defaults that others for SKIP_DOTS.
Modified paths:
  • /trunk/phase3/includes/filerepo/backend/FSFileBackend.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/backend/FSFileBackend.php
@@ -550,7 +550,17 @@
551551 $this->suffixStart = strlen( $dir ) + 1; // size of "path/to/dir/"
552552 try {
553553 # Get an iterator that will return leaf nodes (non-directories)
554 - $this->iter = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $dir ) );
 554+ if ( MWInit::classExists( 'FilesystemIterator' ) ) { // PHP >= 5.3
 555+ # RecursiveDirectoryIterator extends FilesystemIterator.
 556+ # FilesystemIterator::SKIP_DOTS default is inconsistent in PHP 5.3.x.
 557+ $flags = FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS;
 558+ $this->iter = new RecursiveIteratorIterator(
 559+ new RecursiveDirectoryIterator( $dir, $flags ) );
 560+ } else { // PHP < 5.3
 561+ # RecursiveDirectoryIterator extends DirectoryIterator
 562+ $this->iter = new RecursiveIteratorIterator(
 563+ new RecursiveDirectoryIterator( $dir ) );
 564+ }
555565 } catch ( UnexpectedValueException $e ) {
556566 $this->iter = null; // bad permissions? deleted?
557567 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r110159* Reverted r108194 to support PHP < 5.3. These should already be the default ...aaron20:12, 27 January 2012

Status & tagging log