Last modified: 2006-05-22 21:17:57 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T7523, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 5523 - Allow disabling $wgNoFollowLinks is some namespaces
Allow disabling $wgNoFollowLinks is some namespaces
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
unspecified
All All
: Normal enhancement with 3 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-need-review
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-04-10 17:11 UTC by Ilmari Karonen
Modified: 2006-05-22 21:17 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Patch against SVN HEAD to add the $wgNoFollowNsExceptions config option. Added default param (2.61 KB, patch)
2006-04-10 17:13 UTC, Ilmari Karonen
Details
Fixed patch, see comments (2.61 KB, patch)
2006-05-19 10:37 UTC, Ilmari Karonen
Details

Description Ilmari Karonen 2006-04-10 17:11:39 UTC
The attached patch adds a new config option, $wgNoFollowNsExceptions, which
allows disabling rel="nofollow" attributes from external links in some
namespaces while leaving them enabled in others.  This allows, for example,
enabling rel="nofollow" only in talk pages, or everywhere outside the main
namespace.
Comment 1 Ilmari Karonen 2006-04-10 17:13:08 UTC
Created attachment 1509 [details]
Patch against SVN HEAD to add the $wgNoFollowNsExceptions config option. Added default param
Comment 2 Ilmari Karonen 2006-04-12 19:18:13 UTC
Tested the patch: It works, but needs an extra "= null" after the first
occurrence of "$ns" to avoid a spurious warning.  I won't upload a new patch for
this -- if someone knows how to edit the patch, feel free to do so.
Comment 3 Platonides 2006-05-16 20:02:24 UTC
Comment on attachment 1509 [details]
Patch against SVN HEAD to add the $wgNoFollowNsExceptions config option. Added default param

>Index: mediawiki-svn/phase3/includes/Linker.php
>===================================================================
>--- mediawiki-svn/phase3/includes/Linker.php	(revision 13561)
>+++ mediawiki-svn/phase3/includes/Linker.php	(working copy)
>@@ -732,10 +732,10 @@
> 	}
> 
> 	/** @todo document */
>-	function makeExternalLink( $url, $text, $escape = true, $linktype = '' ) {
>+	function makeExternalLink( $url, $text, $escape = true, $linktype = '', $ns = NULL) {
> 		$style = $this->getExternalLinkAttributes( $url, $text, 'external ' . $linktype );
>-		global $wgNoFollowLinks;
>-		if( $wgNoFollowLinks ) {
>+		global $wgNoFollowLinks, $wgNoFollowNsExceptions;
>+		if( $wgNoFollowLinks && !(isset($ns) && in_array($ns, $wgNoFollowNsExceptions)) ) {
> 			$style .= ' rel="nofollow"';
> 		}
> 		$url = htmlspecialchars( $url );
>Index: mediawiki-svn/phase3/includes/Parser.php
>===================================================================
>--- mediawiki-svn/phase3/includes/Parser.php	(revision 13561)
>+++ mediawiki-svn/phase3/includes/Parser.php	(working copy)
>@@ -1190,7 +1190,7 @@
> 			# This means that users can paste URLs directly into the text
> 			# Funny characters like ö aren't valid in URLs anyway
> 			# This was changed in August 2004
>-			$s .= $sk->makeExternalLink( $url, $text, false, $linktype ) . $dtrail . $trail;
>+			$s .= $sk->makeExternalLink( $url, $text, false, $linktype, $this->mTitle->getNamespace() ) . $dtrail . $trail;
> 
> 			# Register link in the output object.
> 			# Replace unnecessary URL escape codes with the referenced character
>@@ -1270,7 +1270,7 @@
> 				$text = $this->maybeMakeExternalImage( $url );
> 				if ( $text === false ) {
> 					# Not an image, make a link
>-					$text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free' );
>+					$text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', $this->mTitle->getNamespace() );
> 					# Register it in the output object...
> 					# Replace unnecessary URL escape codes with their equivalent characters
> 					$pasteurized = Parser::replaceUnusualEscapes( $url );
>Index: mediawiki-svn/phase3/includes/DefaultSettings.php
>===================================================================
>--- mediawiki-svn/phase3/includes/DefaultSettings.php	(revision 13561)
>+++ mediawiki-svn/phase3/includes/DefaultSettings.php	(working copy)
>@@ -1719,6 +1719,12 @@
> $wgNoFollowLinks = true;
> 
> /**
>+ * Namespaces in which $wgNoFollowLinks doesn't apply.
>+ * See Language.php for a list of namespaces.
>+ */
>+$wgNoFollowNsExceptions = array();
>+
>+/**
>  * Specifies the minimal length of a user password. If set to
>  * 0, empty passwords are allowed.
>  */
Comment 4 Platonides 2006-05-16 20:03:17 UTC
Well, that's not really what i intended but i think that was the corrected patch?
Comment 5 Rob Church 2006-05-16 20:38:39 UTC
We have the attachments feature to provide patches.
Comment 6 Platonides 2006-05-17 21:14:36 UTC
I know, Rob. I used its edit link, and thought it would save as an attachment
too. But something went wrong :s
Comment 7 Cesar Eduardo Barros 2006-05-18 18:46:50 UTC
Come on, the right way to do it is to upload as a new attachment, and mark it as
obsoleting the previous one. The "obsoletes" feature is there for exactly that
reason.
Comment 8 Platonides 2006-05-18 20:36:26 UTC
This was a mistake, sorry. These are the cases when you want an 'edit' button to
clean the mess. :( 
Comment 9 Ilmari Karonen 2006-05-19 10:37:59 UTC
Created attachment 1789 [details]
Fixed patch, see comments
Comment 10 Brion Vibber 2006-05-22 21:17:57 UTC
Applied on trunk in r14346.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links