r110923 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110922‎ | r110923 | r110924 >
Date:09:16, 8 February 2012
Author:hashar
Status:resolved (Comments)
Tags:
Comment:
use rtrim() to strip trailing slashes

rtrim() can be given a list of character to strip from a given string.
Modified paths:
  • /trunk/phase3/includes/filerepo/backend/FSFileBackend.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/backend/FSFileBackend.php
@@ -39,18 +39,18 @@
4040 */
4141 public function __construct( array $config ) {
4242 parent::__construct( $config );
 43+
 44+ // Remove any possible trailing slash from directories
 45+
4346 if ( isset( $config['basePath'] ) ) {
44 - if ( substr( $this->basePath, -1 ) === '/' ) {
45 - $this->basePath = substr( $this->basePath, 0, -1 ); // remove trailing slash
46 - }
 47+ rtrim( $this->basePath, '/' ); // remove trailing slash
4748 } else {
4849 $this->basePath = null; // none; containers must have explicit paths
4950 }
 51+
5052 $this->containerPaths = (array)$config['containerPaths'];
5153 foreach ( $this->containerPaths as &$path ) {
52 - if ( substr( $path, -1 ) === '/' ) {
53 - $path = substr( $path, 0, -1 ); // remove trailing slash
54 - }
 54+ rtrim( $path, '/' ); // remove trailing slash
5555 }
5656 $this->fileMode = isset( $config['fileMode'] )
5757 ? $config['fileMode']

Follow-up revisions

RevisionCommit summaryAuthorDate
r110926r110923 made basePath always null!hashar09:54, 8 February 2012
r110934rtrim() call does not pass by reference!...hashar14:30, 8 February 2012

Comments

#Comment by Hashar (talk | contribs)   09:55, 8 February 2012

That revision made basePath always null. Fixed with r110926

#Comment by Aaron Schulz (talk | contribs)   10:42, 8 February 2012

The change in the foreach loop is broken since rtrim does not work by reference.

Status & tagging log