Pull back r56730 for now: "New configuration variable $wgShowPageOnRedlink that can...
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 30 Sep 2009 19:12:41 +0000 (19:12 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 30 Sep 2009 19:12:41 +0000 (19:12 +0000)
The config var's formatting strikes me as kinda scary; might be better to implement this as a permission key, which can have fancy namespace variants handled by an extension or something pretty easily (it seems to me like that's a rarer use case).

RELEASE-NOTES
includes/DefaultSettings.php
includes/EditPage.php

index 32b0731..992794d 100644 (file)
@@ -232,9 +232,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   $wgAJAXCategoriesNamespaces.
 * Admins could disable some variants using $wgDisabledVariants now. ONLY apply
   on wikis enabled LanguageConverter.
-* New configuration variable $wgShowPageOnRedlink that can be set to show the
-  page instead of an edit interface when visiting a red link. The value can be
-  specified for specific usergroups and namespaces.
 * (bug 16310) Credits page now lists IP addresses rather than saying the number
   of anonymous users that edited the page
 * New permission 'sendemail' added. Default right for all registered users. Can
index 466855e..9a60135 100644 (file)
@@ -4275,16 +4275,3 @@ $wgUploadMaintenance = false;
  * Use old names for change_tags indices.
  */
 $wgOldChangeTagsIndex = false;
-
-/**
- * View page instead of edit interface when visiting a red link
- * There are three ways to define this variable:
- *  1. Set $wgShowPageOnRedlink to true (false is default)
- *  2. Set $wgShowPageOnRedlink['usergroup'] to false. If a user is member of at least one usergroup for which the variable 
- *     has been set to false, the edit interface will be shown. Otherwise the page is shown.
- *  3. Set $wgShowPageOnRedlink['usergroup'][NS_XY] to false. Same as 2., but you can specify the namespace. The namespace
- *     is a numerical value (namespace index), you can use constants such as NS_MAIN or NS_USER_TALK.
- * If you use an array (2. or 3.), the default will be true (for 1. it's false). In 2. and 3. there is no way to overwrite 
- * a value 'false' once it has already been set (this is due to the undefined order of usergroups).
- */
-$wgShowPageOnRedlink = false;
index 3a873cd..282307c 100644 (file)
@@ -418,11 +418,11 @@ class EditPage {
                                }
                        }
                }
-
-               # Evaluate if the edit interface should be shown or
-               # if the page should be shown, in case redlink=true
-               if ( $wgRequest->getBool( 'redlink' ) )
-                       $this->showPageOnRedlink();
+               
+               // If they used redlink=1 and the page exists, redirect to the main article
+               if ( $wgRequest->getBool( 'redlink' ) && $this->mTitle->exists() ) {
+                       $wgOut->redirect( $this->mTitle->getFullURL() );
+               }
 
                wfProfileIn( __METHOD__."-business-end" );
 
@@ -487,45 +487,7 @@ class EditPage {
                wfProfileOut( __METHOD__."-business-end" );
                wfProfileOut( __METHOD__ );
        }
-
-       /*
-        * Evaluate if the edit interface should be shown or the page, in case redlink=true. 
-        * If the page exists, it is always shown. If it doesn't, it depends on the settings 
-        * of $wgShowPageOnRedlink (see DefaultSettings for documentation).
-        */
-       protected function showPageOnRedlink() {
-               global $wgShowPageOnRedlink, $wgUser, $wgRequest, $wgOut;
-               $redirectToPage = false;
-               # If the page exists (it has been created after the link has been emerged),
-               # redirect to the page instead of editing the current page
-               if ( $this->mTitle->exists() )
-                       $wgOut->redirect( $this->mTitle->getFullURL() );
-               # Check site configuration ($wgShowPageOnRedlink)
-               if ( is_array( $wgShowPageOnRedlink ) ) {
-                       $ns = $this->mTitle->getNamespace();
-                       $groups = $wgUser->getEffectiveGroups();
-                       # Gets overwritten if user is member of a group that has been specified:
-                       $redirectToPage = true;
-                       foreach ( $groups as $i => $group ) {
-                               # Test if there is a rule for a specific usergroup and a specific namespace
-                               if ( isset( $wgShowPageOnRedlink[$group][$ns] ) && $wgShowPageOnRedlink[$group][$ns] == false ) {
-                                       $redirectToPage = false;
-                               }
-                               # Test if there is a rule for a specific usergroup in all namespaces
-                               elseif ( isset( $wgShowPageOnRedlink[$group] ) && !is_array( $wgShowPageOnRedlink[$group] ) 
-                                          && $wgShowPageOnRedlink[$group] == false ) {
-                                       $redirectToPage = false;
-                               }
-                       }
-               }
-               else {
-                       $redirectToPage = $wgShowPageOnRedlink;
-               }
-               if ( $redirectToPage ) {
-                       $wgOut->redirect( $this->mTitle->getFullURL() );
-               }
-       }
-
+       
        protected function getEditPermissionErrors() {
                global $wgUser;
                $permErrors = $this->mTitle->getUserPermissionsErrors( 'edit', $wgUser );