From 0d734714977e4f0662eb10249fd56e63812f2cc2 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Wed, 8 Feb 2012 09:16:19 +0000 Subject: [PATCH] use rtrim() to strip trailing slashes rtrim() can be given a list of character to strip from a given string. --- includes/filerepo/backend/FSFileBackend.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/filerepo/backend/FSFileBackend.php b/includes/filerepo/backend/FSFileBackend.php index e891c9dedf..68c69d6f43 100644 --- a/includes/filerepo/backend/FSFileBackend.php +++ b/includes/filerepo/backend/FSFileBackend.php @@ -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'] -- 2.20.1