AndyRussG has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/98475


Change subject: Fix undelete courses and institutions
......................................................................

Fix undelete courses and institutions

After deleting a course or organization, if you go to the page
of the deleted course or organization, and click on the "restore
X versions" link, nothing happens. This patch fixes it. The
problem was apparently introduced in change
I11cba8f8b2740c86d2628e71d323305f78f48d02.

Bug: 39246
Change-Id: Iad1e4463491e6b545ea01ef3422754f9474dcec4
---
M includes/actions/UndeleteAction.php
M includes/rows/Course.php
M includes/rows/Org.php
M includes/tables/Courses.php
M includes/tables/Orgs.php
M includes/tables/PageTable.php
6 files changed, 37 insertions(+), 7 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EducationProgram 
refs/changes/75/98475/1

diff --git a/includes/actions/UndeleteAction.php 
b/includes/actions/UndeleteAction.php
index 63cb4e7..bfd26e6 100644
--- a/includes/actions/UndeleteAction.php
+++ b/includes/actions/UndeleteAction.php
@@ -48,8 +48,8 @@
                if ( $object === false ) {
                        $revision = Revisions::singleton()->getLatestRevision( 
array(
                                'object_identifier' => 
$this->getTitle()->getText(),
-                               'type' => get_class( $this->page->getTable() ),
-                       ) );
+                               'type' => 
$this->page->getTable()->getRevisionedObjectTypeId(),
+                       ) );
 
                        if ( $revision === false ) {
                                $this->getRequest()->setSessionData(
diff --git a/includes/rows/Course.php b/includes/rows/Course.php
index 98084c4..ac82ae5 100644
--- a/includes/rows/Course.php
+++ b/includes/rows/Course.php
@@ -747,7 +747,6 @@
         * @return string
         */
        protected function getTypeId() {
-               return 'EPCourses';
+               return $this->table->getRevisionedObjectTypeId();
        }
-
 }
diff --git a/includes/rows/Org.php b/includes/rows/Org.php
index 4e72015..63bba6a 100644
--- a/includes/rows/Org.php
+++ b/includes/rows/Org.php
@@ -256,7 +256,7 @@
         * @return string
         */
        protected function getTypeId() {
-               return 'EPOrgs';
+               return $this->table->getRevisionedObjectTypeId();
        }
 
 }
diff --git a/includes/tables/Courses.php b/includes/tables/Courses.php
index 4f1e53c..6d5af9c 100644
--- a/includes/tables/Courses.php
+++ b/includes/tables/Courses.php
@@ -137,6 +137,15 @@
                );
        }
 
+       /**
+        * @see \EducationProgram\PageTable::getRevisionedObjectTypeId()
+        * @since 0.4 alpha
+        * @return string
+        */
+       public function getRevisionedObjectTypeId() {
+               return "EPCourses";
+       }
+
        public function hasActiveTitle( $courseTitle ) {
                $now = wfGetDB( DB_SLAVE )->addQuotes( wfTimestampNow() );
 
@@ -280,5 +289,4 @@
        public function getEditRight() {
                return 'ep-course';
        }
-
 }
diff --git a/includes/tables/Orgs.php b/includes/tables/Orgs.php
index 5739857..46e92f7 100644
--- a/includes/tables/Orgs.php
+++ b/includes/tables/Orgs.php
@@ -98,6 +98,15 @@
        }
 
        /**
+        * @see \EducationProgram\PageTable::getRevisionedObjectTypeId()
+        * @since 0.4 alpha
+        * @return string
+        */
+       public function getRevisionedObjectTypeId() {
+               return "EPOrgs";
+       }
+
+       /**
         * @see ORMTable::getSummaryFields()
         * @since 0.1
         * @return array
@@ -134,5 +143,4 @@
        public function getEditRight() {
                return 'ep-org';
        }
-
 }
diff --git a/includes/tables/PageTable.php b/includes/tables/PageTable.php
index f64ee7b..50d8bd9 100644
--- a/includes/tables/PageTable.php
+++ b/includes/tables/PageTable.php
@@ -44,6 +44,21 @@
        public abstract function getRevertibleFields();
 
        /**
+        * Get a string for use in the 'type' field of the Revisions table for
+        * identifying revisions of rows in this table.
+        *
+        * (Note: In theory, if a subclass of PageTable does not store previous
+        * revisions of its rows in the Revisions table, it may return null 
here.
+        * However, at this time there are no subclasses of PageTable that do 
not
+        * store revisions. PageObject inherits from RevisionedObject.)
+        *
+        * @since 0.4 alpha
+        *
+        * @return string|null
+        */
+       public abstract function getRevisionedObjectTypeId();
+
+       /**
         * Returns the right needed to edit items in this table.
         *
         * @since 0.1

-- 
To view, visit https://gerrit.wikimedia.org/r/98475
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iad1e4463491e6b545ea01ef3422754f9474dcec4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/EducationProgram
Gerrit-Branch: master
Gerrit-Owner: AndyRussG <andrew.green...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to