X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FTitle.php;h=ce0b9595c5d8bf72540ab8b4eda7612538e8a2e2;hb=a7bf7f5b293755044c1ede43537f5c393dba09c1;hp=0f458395774dd1ab1c32b6443da18e9b17c1c442;hpb=0a6d507ed0871dba1f9baa4cc22dfcac34b047dd;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Title.php b/includes/Title.php index 0f45839577..ce0b9595c5 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1702,16 +1702,18 @@ class Title implements LinkTarget, IDBAccessObject { * @return string Base name */ public function getBaseText() { + $text = $this->getText(); if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) { - return $this->getText(); + return $text; } - $parts = explode( '/', $this->getText() ); - # Don't discard the real title if there's no subpage involved - if ( count( $parts ) > 1 ) { - unset( $parts[count( $parts ) - 1] ); + $lastSlashPos = strrpos( $text, '/' ); + // Don't discard the real title if there's no subpage involved + if ( $lastSlashPos === false ) { + return $text; } - return implode( '/', $parts ); + + return substr( $text, 0, $lastSlashPos ); } /**