use rtrim() to strip trailing slashes
authorAntoine Musso <hashar@users.mediawiki.org>
Wed, 8 Feb 2012 09:16:19 +0000 (09:16 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Wed, 8 Feb 2012 09:16:19 +0000 (09:16 +0000)
rtrim() can be given a list of character to strip from a given string.

includes/filerepo/backend/FSFileBackend.php

index e891c9d..68c69d6 100644 (file)
@@ -39,18 +39,18 @@ class FSFileBackend extends FileBackendStore {
         */
        public function __construct( array $config ) {
                parent::__construct( $config );
+
+               // Remove any possible trailing slash from directories
+
                if ( isset( $config['basePath'] ) ) {
-                       if ( substr( $this->basePath, -1 ) === '/' ) {
-                               $this->basePath = substr( $this->basePath, 0, -1 ); // remove trailing slash
-                       }
+                       rtrim( $this->basePath, '/' ); // remove trailing slash
                } else {
                        $this->basePath = null; // none; containers must have explicit paths
                }
+
                $this->containerPaths = (array)$config['containerPaths'];
                foreach ( $this->containerPaths as &$path ) {
-                       if ( substr( $path, -1 ) === '/' ) {
-                               $path = substr( $path, 0, -1 ); // remove trailing slash
-                       }
+                       rtrim( $path, '/' );  // remove trailing slash
                }
                $this->fileMode = isset( $config['fileMode'] )
                        ? $config['fileMode']