* (bug 17649) Added isDeletedQuick() and replaced some slow checks
authorAaron Schulz <aaron@users.mediawiki.org>
Tue, 24 Feb 2009 16:17:23 +0000 (16:17 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Tue, 24 Feb 2009 16:17:23 +0000 (16:17 +0000)
includes/EditPage.php
includes/Title.php
includes/filerepo/File.php
includes/specials/SpecialUpload.php

index 4163a12..840497e 100644 (file)
@@ -324,7 +324,7 @@ class EditPage {
        protected function wasDeletedSinceLastEdit() {
                if ( $this->deletedSinceEdit )
                        return true;
-               if ( $this->mTitle->isDeleted() ) {
+               if ( $this->mTitle->isDeletedQuick() ) {
                        $this->lastDelete = $this->getLastDelete();
                        if ( $this->lastDelete ) {
                                $deleteTime = wfTimestamp( TS_MW, $this->lastDelete->log_timestamp );
index 8ae93fe..888c47a 100644 (file)
@@ -1979,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,
index 03a8322..523a1c0 100644 (file)
@@ -951,7 +951,7 @@ abstract class File {
         */
        function wasDeleted() {
                $title = $this->getTitle();
-               return $title && $title->isDeleted() > 0;
+               return $title && $title->isDeletedQuick();
        }
 
        /**
index 074a9f2..2d4b7f9 100644 (file)
@@ -993,7 +993,7 @@ wgUploadAutoFill = {$autofill};
                        }
 
                        // Show the relevant lines from deletion log (for still deleted files only)
-                       if( $title instanceof Title && $title->isDeleted() > 0 && !$title->exists() ) {
+                       if( $title instanceof Title && $title->isDeletedQuick() && !$title->exists() ) {
                                $this->showDeletionLog( $wgOut, $title->getPrefixedText() );
                        }
                }