r57139 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57138‎ | r57139 | r57140 >
Date:19:12, 30 September 2009
Author:brion
Status:ok
Tags:
Comment:
Pull back r56730 for now: "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."
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).
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/EditPage.php
@@ -418,12 +418,12 @@
419419 }
420420 }
421421 }
 422+
 423+ // If they used redlink=1 and the page exists, redirect to the main article
 424+ if ( $wgRequest->getBool( 'redlink' ) && $this->mTitle->exists() ) {
 425+ $wgOut->redirect( $this->mTitle->getFullURL() );
 426+ }
422427
423 - # Evaluate if the edit interface should be shown or
424 - # if the page should be shown, in case redlink=true
425 - if ( $wgRequest->getBool( 'redlink' ) )
426 - $this->showPageOnRedlink();
427 -
428428 wfProfileIn( __METHOD__."-business-end" );
429429
430430 $this->isConflict = false;
@@ -487,45 +487,7 @@
488488 wfProfileOut( __METHOD__."-business-end" );
489489 wfProfileOut( __METHOD__ );
490490 }
491 -
492 - /*
493 - * Evaluate if the edit interface should be shown or the page, in case redlink=true.
494 - * If the page exists, it is always shown. If it doesn't, it depends on the settings
495 - * of $wgShowPageOnRedlink (see DefaultSettings for documentation).
496 - */
497 - protected function showPageOnRedlink() {
498 - global $wgShowPageOnRedlink, $wgUser, $wgRequest, $wgOut;
499 - $redirectToPage = false;
500 - # If the page exists (it has been created after the link has been emerged),
501 - # redirect to the page instead of editing the current page
502 - if ( $this->mTitle->exists() )
503 - $wgOut->redirect( $this->mTitle->getFullURL() );
504 - # Check site configuration ($wgShowPageOnRedlink)
505 - if ( is_array( $wgShowPageOnRedlink ) ) {
506 - $ns = $this->mTitle->getNamespace();
507 - $groups = $wgUser->getEffectiveGroups();
508 - # Gets overwritten if user is member of a group that has been specified:
509 - $redirectToPage = true;
510 - foreach ( $groups as $i => $group ) {
511 - # Test if there is a rule for a specific usergroup and a specific namespace
512 - if ( isset( $wgShowPageOnRedlink[$group][$ns] ) && $wgShowPageOnRedlink[$group][$ns] == false ) {
513 - $redirectToPage = false;
514 - }
515 - # Test if there is a rule for a specific usergroup in all namespaces
516 - elseif ( isset( $wgShowPageOnRedlink[$group] ) && !is_array( $wgShowPageOnRedlink[$group] )
517 - && $wgShowPageOnRedlink[$group] == false ) {
518 - $redirectToPage = false;
519 - }
520 - }
521 - }
522 - else {
523 - $redirectToPage = $wgShowPageOnRedlink;
524 - }
525 - if ( $redirectToPage ) {
526 - $wgOut->redirect( $this->mTitle->getFullURL() );
527 - }
528 - }
529 -
 491+
530492 protected function getEditPermissionErrors() {
531493 global $wgUser;
532494 $permErrors = $this->mTitle->getUserPermissionsErrors( 'edit', $wgUser );
Index: trunk/phase3/includes/DefaultSettings.php
@@ -4275,16 +4275,3 @@
42764276 * Use old names for change_tags indices.
42774277 */
42784278 $wgOldChangeTagsIndex = false;
4279 -
4280 -/**
4281 - * View page instead of edit interface when visiting a red link
4282 - * There are three ways to define this variable:
4283 - * 1. Set $wgShowPageOnRedlink to true (false is default)
4284 - * 2. Set $wgShowPageOnRedlink['usergroup'] to false. If a user is member of at least one usergroup for which the variable
4285 - * has been set to false, the edit interface will be shown. Otherwise the page is shown.
4286 - * 3. Set $wgShowPageOnRedlink['usergroup'][NS_XY] to false. Same as 2., but you can specify the namespace. The namespace
4287 - * is a numerical value (namespace index), you can use constants such as NS_MAIN or NS_USER_TALK.
4288 - * 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
4289 - * a value 'false' once it has already been set (this is due to the undefined order of usergroups).
4290 - */
4291 -$wgShowPageOnRedlink = false;
Index: trunk/phase3/RELEASE-NOTES
@@ -232,9 +232,6 @@
233233 $wgAJAXCategoriesNamespaces.
234234 * Admins could disable some variants using $wgDisabledVariants now. ONLY apply
235235 on wikis enabled LanguageConverter.
236 -* New configuration variable $wgShowPageOnRedlink that can be set to show the
237 - page instead of an edit interface when visiting a red link. The value can be
238 - specified for specific usergroups and namespaces.
239236 * (bug 16310) Credits page now lists IP addresses rather than saying the number
240237 of anonymous users that edited the page
241238 * New permission 'sendemail' added. Default right for all registered users. Can

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r56730New configuration variable $wgShowPageOnRedlink that can be set to show the p...churchofemacs19:21, 21 September 2009

Status & tagging log