Niharika29 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/376638 )

Change subject: Skip the landing page for redlinks completely and take user to 
AfC
......................................................................

Skip the landing page for redlinks completely and take user to AfC

Bug: T173605
Change-Id: I9fbff4840bf324ee5579d3bd7220212189b45b0f
(cherry picked from commit 7e0294e284fc6d9c4a1ca7698c8bad41d0a0fbab)
---
M extension.json
M includes/Hooks.php
2 files changed, 32 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ArticleCreationWorkflow 
refs/changes/38/376638/1

diff --git a/extension.json b/extension.json
index 5ac4979..8309ffa 100644
--- a/extension.json
+++ b/extension.json
@@ -10,7 +10,8 @@
                "MediaWiki": ">= 1.30.0-alpha"
        },
        "Hooks": {
-               "AlternateEdit": 
"ArticleCreationWorkflow\\Hooks::onAlternateEdit"
+               "AlternateEdit": 
"ArticleCreationWorkflow\\Hooks::onAlternateEdit",
+               "ShowMissingArticle": 
"ArticleCreationWorkflow\\Hooks::onShowMissingArticle"
        },
        "AutoloadClasses": {
                "ArticleCreationWorkflow\\Hooks": "includes/Hooks.php",
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 93ca6e8..08e8b2d 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -4,6 +4,7 @@
 
 use EditPage;
 use MediaWiki\MediaWikiServices;
+use Article;
 
 /**
  * Hook handlers
@@ -11,7 +12,7 @@
 class Hooks {
        /**
         * AlternateEdit hook handler
-        * Redirects users attempting to create pages to Special:CreatePage, 
based on configuration
+        * Redirects users attempting to create pages to the landing page, 
based on configuration
         *
         * @see https://www.mediawiki.org/wiki/Manual:Hooks/AlternateEdit
         *
@@ -38,4 +39,32 @@
 
                return true;
        }
+
+       /**
+        * ShowMissingArticle hook handler
+        * If article doesn't exist, redirect non-autoconfirmed users to  AfC
+        *
+        * @see https://www.mediawiki.org/wiki/Manual:Hooks/ShowMissingArticle
+        *
+        * @param Article $article Article instance
+        * @return bool
+        */
+       public static function onShowMissingArticle( Article $article ) {
+               $config = MediaWikiServices::getInstance()
+                       ->getConfigFactory()
+                       ->makeConfig( 'ArticleCreationWorkflow' );
+               $workflow = new Workflow( $config );
+               $editPage = new EditPage( $article );
+               if ( $workflow->shouldInterceptEditPage( $editPage ) &&
+                       !$editPage->getContext()->getUser()->isAnon()
+               ) {
+                       $title = $editPage->getTitle();
+                       // If the landing page didn't exist, we wouldn't have 
intercepted.
+                       $redirTo = $workflow->getLandingPageTitle();
+                       $output = $editPage->getContext()->getOutput();
+                       $output->redirect( $redirTo->getFullURL(
+                               [ 'page' => $title->getPrefixedText(), 'wprov' 
=> 'acww1' ]
+                       ) );
+               }
+       }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9fbff4840bf324ee5579d3bd7220212189b45b0f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ArticleCreationWorkflow
Gerrit-Branch: wmf/1.30.0-wmf.17
Gerrit-Owner: Niharika29 <nko...@wikimedia.org>

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

Reply via email to