Florianschmidtwelzow has uploaded a new change for review.

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

Change subject: Don't redirect Flow boards to SpecialMobileHistory
......................................................................

Don't redirect Flow boards to SpecialMobileHistory

Bug: T93491
Change-Id: I2b3843d8499ffd0bfa054e2b4c94821b1e08f01b
---
M includes/MobileContext.php
M includes/specials/SpecialMobileHistory.php
2 files changed, 41 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/42/257642/1

diff --git a/includes/MobileContext.php b/includes/MobileContext.php
index 5950881..1a6bf72 100644
--- a/includes/MobileContext.php
+++ b/includes/MobileContext.php
@@ -393,12 +393,18 @@
         * If a page has an equivalent but different mobile page redirect to it
         */
        private function redirectMobileEnabledPages() {
+               $request = $this->getRequest();
+               $title = $this->getTitle();
+
                $redirectUrl = null;
-               if ( $this->getRequest()->getCheck( 'diff' ) ) {
+               if ( $request->getCheck( 'diff' ) ) {
                        $redirectUrl = 
SpecialMobileDiff::getMobileUrlFromDesktop();
                }
 
-               if ( $this->getRequest()->getVal( 'action' ) === 'history' ) {
+               if ( $request->getVal( 'action' ) === 'history' &&
+                       // check, if SpecialMobileHistory supports the history 
action set for this title
+                       // content model
+                       SpecialMobileHistory::shouldUseSpecialHistory( $title ) 
) {
                        $values = $this->getRequest()->getValues();
                        // avoid infinite redirect loops
                        unset( $values['action'] );
diff --git a/includes/specials/SpecialMobileHistory.php 
b/includes/specials/SpecialMobileHistory.php
index a3dc673..1d1ebf6 100644
--- a/includes/specials/SpecialMobileHistory.php
+++ b/includes/specials/SpecialMobileHistory.php
@@ -20,6 +20,10 @@
        /** @var Title|null $title Null if no title passed */
        protected $title;
 
+       /** @var array $actionOverrides Holds non-default actions
+               (from ContentHandler::getActionOverrides()) */
+       private static $actionOverrides = array();
+
        /**
         * Construct function
         */
@@ -89,6 +93,28 @@
        }
 
        /**
+        * Checks, if the given title supports the use of SpecialMobileHistory.
+        *
+        * @param Title $title The title to check
+        * @return boolean True, if SpecialMobileHistory can be used, false 
otherwise
+        */
+       public static function shouldUseSpecialHistory( Title $title ) {
+               // check, if the actionOverrides for this title are already 
cached
+               if ( !isset( self::$actionOverrides[$title->getDBKey()] ) ) {
+                       // if not, get them
+                       $contentHandler = ContentHandler::getForTitle( $title );
+                       self::$actionOverrides[$title->getDBKey()] = 
$contentHandler->getActionOverrides();
+               }
+
+               // if history is overwritten, assume, that SpecialMobileHistory 
can't handle them
+               if ( isset( 
self::$actionOverrides[$title->getDBKey()]['history'] ) ) {
+                       // and return false
+                       return false;
+               }
+               return true;
+       }
+
+       /**
         * Render the special page
         * @param string $par parameter as subpage of specialpage
         */
@@ -104,6 +130,13 @@
                        // enter article history view
                        $this->title = Title::newFromText( $par );
                        if ( $this->title && $this->title->exists() ) {
+                               // make sure, the content of the page supports 
the default history page
+                               if ( !self::shouldUseSpecialHistory( 
$this->title ) ) {
+                                       // and if not, redirect to the default 
history action
+                                       $out->redirect( 
$this->title->getLocalUrl( array( 'action' => 'history' ) ) );
+                                       return;
+                               }
+                               
                                $this->addModules();
                                $this->getOutput()->addHtml(
                                        Html::openElement( 'div', array( 
'class' => 'history content-unstyled' ) )

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2b3843d8499ffd0bfa054e2b4c94821b1e08f01b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to