(bug 37714) Use log type in target object when deleting logs of the same type
[lhc/web/wiklou.git] / includes / specials / SpecialRevisiondelete.php
index 089f967..eaf0d52 100644 (file)
@@ -147,6 +147,19 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                } else {
                        $this->typeName = $request->getVal( 'type' );
                        $this->targetObj = Title::newFromText( $request->getText( 'target' ) );
+                       if ( $this->targetObj && $this->targetObj->isSpecial( 'Log' ) ) {
+                               $result = wfGetDB( DB_SLAVE )->select( 'logging',
+                                       'log_type',
+                                       array( 'log_id' => $this->ids ),
+                                       __METHOD__,
+                                       array( 'DISTINCT' )
+                               );
+
+                               if ( $result->numRows() == 1 ) {
+                                       // If there's only one type, the target can be set to include it.
+                                       $this->targetObj = SpecialPage::getTitleFor( 'Log', $result->current()->log_type );
+                               }
+                       }
                }
 
                # For reviewing deleted files...
@@ -504,6 +517,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
 
        /**
         * UI entry point for form submission.
+        * @throws PermissionsError
         * @return bool
         */
        protected function submit() {