From: Thiemo Kreuz Date: Thu, 28 Feb 2019 10:47:07 +0000 (+0100) Subject: maintenance: Replace custom .ext extraction with pathinfo() X-Git-Tag: 1.34.0-rc.0~2686^2 X-Git-Url: http://git.cyclocoop.org/data/Fool?a=commitdiff_plain;h=cb04fe6a06f69b4936acb49b473d40d98523b692;p=lhc%2Fweb%2Fwiklou.git maintenance: Replace custom .ext extraction with pathinfo() Note the custom code was not working correctly for filenames that do not contain a dot. I assume this is not relevant for the filenames this code needs to process. Change-Id: Id4578bc86203dcbd9f76928bbec71a2c46176e11 --- diff --git a/maintenance/importImages.php b/maintenance/importImages.php index 7a2e0f405f..172869506b 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -418,7 +418,7 @@ class ImportImages extends Maintenance { $files = []; while ( ( $file = readdir( $dhl ) ) !== false ) { if ( is_file( $dir . '/' . $file ) ) { - list( /* $name */, $ext ) = $this->splitFilename( $dir . '/' . $file ); + $ext = pathinfo( $file, PATHINFO_EXTENSION ); if ( array_search( strtolower( $ext ), $exts ) !== false ) { $files[] = $dir . '/' . $file; } @@ -436,21 +436,6 @@ class ImportImages extends Maintenance { } } - /** - * Split a filename into filename and extension - * - * @param string $filename - * @return array - */ - private function splitFilename( $filename ) { - $parts = explode( '.', $filename ); - $ext = $parts[count( $parts ) - 1]; - unset( $parts[count( $parts ) - 1] ); - $fname = implode( '.', $parts ); - - return [ $fname, $ext ]; - } - /** * Find an auxilliary file with the given extension, matching * the give base file path. $maxStrip determines how many extensions