INDEX use fixes
[lhc/web/wiklou.git] / includes / Title.php
index 94ad845..616aebd 100644 (file)
@@ -867,19 +867,21 @@ class Title {
         * @return \type{\string} the URL
         */
        public function getLinkUrl( $query = array(), $variant = false ) {
+               wfProfileIn( __METHOD__ );
                if( !is_array( $query ) ) {
+                       wfProfileOut( __METHOD__ );
                        throw new MWException( 'Title::getLinkUrl passed a non-array for '.
                        '$query' );
                }
                if( $this->isExternal() ) {
-                       return $this->getFullURL( $query );
-               } elseif( $this->getPrefixedText() === ''
-               and $this->getFragment() !== '' ) {
-                       return $this->getFragmentForURL();
+                       $ret = $this->getFullURL( $query );
+               } elseif( $this->getPrefixedText() === '' && $this->getFragment() !== '' ) {
+                       $ret = $this->getFragmentForURL();
                } else {
-                       return $this->getLocalURL( $query, $variant )
-                               . $this->getFragmentForURL();
+                       $ret = $this->getLocalURL( $query, $variant ) . $this->getFragmentForURL();
                }
+               wfProfileOut( __METHOD__ );
+               return $ret;
        }
 
        /**
@@ -1977,20 +1979,45 @@ class Title {
         * @return \type{\int} the number of archived revisions
         */
        public function isDeleted() {
-               $fname = 'Title::isDeleted';
-               if ( $this->getNamespace() < 0 ) {
+               if( $this->getNamespace() < 0 ) {
                        $n = 0;
                } else {
                        $dbr = wfGetDB( DB_SLAVE );
-                       $n = $dbr->selectField( 'archive', 'COUNT(*)', array( 'ar_namespace' => $this->getNamespace(),
-                               'ar_title' => $this->getDBkey() ), $fname );
+                       $n = $dbr->selectField( 'archive', 'COUNT(*)', 
+                               array( 'ar_namespace' => $this->getNamespace(), 'ar_title' => $this->getDBkey() ),
+                               __METHOD__
+                       );
                        if( $this->getNamespace() == NS_FILE ) {
                                $n += $dbr->selectField( 'filearchive', 'COUNT(*)',
-                                       array( 'fa_name' => $this->getDBkey() ), $fname );
+                                       array( 'fa_name' => $this->getDBkey() ),
+                                       __METHOD__
+                               );
                        }
                }
                return (int)$n;
        }
+       
+       /**
+        * Is there a version of this page in the deletion archive?
+        * @return bool
+        */
+       public function isDeletedQuick() {
+               if( $this->getNamespace() < 0 ) {
+                       return false;
+               }
+               $dbr = wfGetDB( DB_SLAVE );
+               $deleted = (bool)$dbr->selectField( 'archive', '1',
+                       array( 'ar_namespace' => $this->getNamespace(), 'ar_title' => $this->getDBkey() ),
+                       __METHOD__
+               );
+               if( !$deleted && $this->getNamespace() == NS_FILE ) {
+                       $deleted = (bool)$dbr->selectField( 'filearchive', '1',
+                               array( 'fa_name' => $this->getDBkey() ),
+                               __METHOD__
+                       );
+               }
+               return $deleted;
+       }
 
        /**
         * Get the article ID for this Title from the link cache,
@@ -2170,6 +2197,9 @@ class Title {
                #
                $dbkey = preg_replace( '/[ _]+/', '_', $dbkey );
                $dbkey = trim( $dbkey, '_' );
+               
+               # Clean up Arabic harakats (bug 16899)
+               $dbkey = preg_replace( '/[\x{064B}-\x{0652}]/Su', '', $dbkey );
 
                if ( '' == $dbkey ) {
                        return false;
@@ -3356,7 +3386,7 @@ class Title {
                if( $this->mInterwiki != '' ) {
                        return true;  // any interwiki link might be viewable, for all we know
                }
-               switch( $this->mNamespace ) {                   
+               switch( $this->mNamespace ) {
                case NS_MEDIA:
                case NS_FILE:
                        return wfFindFile( $this );  // file exists, possibly in a foreign repo