Index: Title.php
===================================================================
--- Title.php	(revisão 83693)
+++ Title.php	(cópia de trabalho)
@@ -751,21 +751,50 @@
 	}
 
 	/**
-	 * Get the base name, i.e. the leftmost parts before the /
+	 * Get the name of the lowest-level parent page which exists and returns
+	 * the real subpage or basepage
 	 *
-	 * @return String Base name
+	 * @return String Base page name or Sub page name
 	 */
-	public function getBaseText() {
+	private function CheckExistence( $type = null ) {
 		if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
 			return $this->getText();
 		}
+		$defaultpage = $this->mTextform;
+		$page = $this->mTextform;
+		for ( $i = 1; $i <= 25; $i++ ) {
+			$pos = strrpos( $page, '/' );
+			if ( $pos ) {
+				$page = substr( $page, 0, $pos );
+				if ( Title::newFromText( $page )->exists()  ) {
+					switch( $type ) {
+					case 'subpage' :
+						return ( substr( $defaultpage, $pos + 1 ) );
+					case 'basepage':
+						return ( $page );
+					default:
+						return( $defaultpage );
+					}
+				}
+			}
+			else {
+				return( $defaultpage );
+			}
+		}
+		return '';
+	}
 
-		$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] );
+	/**
+	 * Get the base name, i.e. the leftmost parts before the /
+	 *
+	 * @return String Base name
+	 */
+	public function getBaseText() {
+		$page = $this->mTextform;
+		if ( $this->CheckExistence( 'basepage' ) ) {
+			return $this->CheckExistence( 'basepage' );
 		}
-		return implode( '/', $parts );
+		return substr( $page, 0, strrpos( $page, '/' ) );
 	}
 
 	/**
@@ -774,11 +803,11 @@
 	 * @return String Subpage name
 	 */
 	public function getSubpageText() {
-		if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
-			return( $this->mTextform );
+		$page = $this->mTextform;
+		if ( $this->CheckExistence( 'subpage' ) ) {
+			return $this->CheckExistence( 'subpage' );
 		}
-		$parts = explode( '/', $this->mTextform );
-		return( $parts[count( $parts ) - 1] );
+		return substr( $page, strrpos( $page, '/' ) + 1 );
 	}
 
 	/**
