EBernhardson has uploaded a new change for review.

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

Change subject: Restore workflow query parameter
......................................................................

Restore workflow query parameter

This is required for BC with urls that have gone out some time ago.
This parameter is only accepted via web requests and now issues an
unconditional redirect to the correct title.

Bug: 72336
Change-Id: I0a43ace137b21980adb8dcf4c7cb303ef0592c80
---
M includes/Actions/Action.php
1 file changed, 45 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/84/168184/1

diff --git a/includes/Actions/Action.php b/includes/Actions/Action.php
index 0dd4eb6..932dc4e 100644
--- a/includes/Actions/Action.php
+++ b/includes/Actions/Action.php
@@ -70,10 +70,16 @@
 
                $request = $this->context->getRequest();
 
-               $action = $request->getVal( 'action', 'view' );
+               // BC for urls pre july 2014 with workflow query parameter
+               $redirect = $this->getRedirectUrl( $request, $title );
+               if ( $redirect ) {
+                       $output->redirect( $redirect );
+                       return;
+               }
 
+               $action = $request->getVal( 'action', 'view' );
                try {
-                       /** @var WorkflowLoaderFactory $factory */
+                       /** @var WorkflowLoaderFactory $factory */
                        $factory = $container['factory.loader.workflow'];
                        $loader = $factory->createWorkflowLoader( $title );
 
@@ -93,4 +99,41 @@
                        throw $e;
                }
        }
+
+
+       /**
+        * Flow used to output some permalink urls with workflow ids in them. 
Each
+        * workflow now has its own page, so those have been deprecated. This 
checks
+        * a web request for the old workflow parameter and returns a url to 
redirect
+        * to if necessary.
+        *
+        * @param WebRequest $request
+        * @param Title $title
+        * @return string URL to redirect to or blank string for no redirect
+        */
+       protected function getRedirectUrl( WebRequest $request, Title $title ) {
+               $workflowId = UUID::create( strtolower( $request->getVal( 
'workflow' ) ) ?: null );
+               if ( !$workflowId ) {
+                       return '';
+               }
+
+               /** @var ManagerGroup $storage */
+               $storage = Container::get( 'storage' );
+               /** @var Workflow $workflow */
+               $workflow = $storage->get( 'Workflow', $workflowId );
+
+               // The uuid points to a non-existant workflow
+               if ( !$workflow ) {
+                       return '';
+               }
+
+               // The uuid points to the current page
+               $redirTitle = $workflow->getArticleTitle();
+               if ( $redirTitle->equals( $title ) ) {
+                       return '';
+               }
+
+               // We need to redirect
+               return $redirTitle->getLinkURL();
+       }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0a43ace137b21980adb8dcf4c7cb303ef0592c80
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>

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

Reply via email to