- $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;