From: Antoine Musso Date: Wed, 8 Feb 2012 09:16:19 +0000 (+0000) Subject: use rtrim() to strip trailing slashes X-Git-Tag: 1.31.0-rc.0~24875 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=0d734714977e4f0662eb10249fd56e63812f2cc2;p=lhc%2Fweb%2Fwiklou.git use rtrim() to strip trailing slashes rtrim() can be given a list of character to strip from a given string. --- 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']