jenkins-bot has submitted this change and it was merged.

Change subject: Add interstitial to all appropriate footer links. Fixes bug 
55748.
......................................................................


Add interstitial to all appropriate footer links. Fixes bug 55748.

* Currently, the first qualifying link on a footer line gets rewritten.
* This patch rewrites every qualifying link per footer line.

Change-Id: I767584b135888fd0af90f75db4e0653df6d01586
---
M includes/PageRenderingHooks.php
1 file changed, 17 insertions(+), 14 deletions(-)

Approvals:
  Yurik: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/PageRenderingHooks.php b/includes/PageRenderingHooks.php
index e400928..9589ace 100644
--- a/includes/PageRenderingHooks.php
+++ b/includes/PageRenderingHooks.php
@@ -880,20 +880,23 @@
         */
        private function addWarning( BaseTemplate $template, $templateValName ) 
{
                $link = $template->get( $templateValName );
-               if ( preg_match( '/href=([\'"])(.*?)\1/', $link, $match ) ) {
-                       $href = $match[2];
-                       $ch0 = substr( $href, 0, 1 );
-                       $ch1 = substr( $href, 1, 1 );
-                       // Local links start with either '#...', '?...' or 
'/...', but not '//...'
-                       if ( $ch0 !== '#' && $ch0 !== '?' && ( $ch0 !== '/' || 
$ch1 === '/' ) ) {
-                               $link = str_replace(
-                                       $href,
-                                       $this->makeRedirect( $href ),
-                                       $link
-                               );
-                               $template->set( $templateValName, $link );
-                       }
-               }
+               $self = $this;
+               $link = preg_replace_callback( '/href=([\'"])(.*?)\1/',
+                       function ( $matches ) use ( $self ) {
+                               $quoteChar = $matches[1];
+                               $href = $matches[2];
+                               $ch0 = substr( $href, 0, 1 );
+                               $ch1 = substr( $href, 1, 1 );
+                               // Local links start with either '#...', '?...' 
or '/...', but not '//...'
+                               if ( $ch0 !== '#' && $ch0 !== '?' && ( $ch0 !== 
'/' || $ch1 === '/' ) ) {
+                                       return 'href=' . $quoteChar . 
$self->makeRedirect( $href ) . $quoteChar ;
+                               } else {
+                                       return $matches[0];
+                               }
+                       },
+                       $link
+               );
+               $template->set( $templateValName, $link );
        }
 
        /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I767584b135888fd0af90f75db4e0653df6d01586
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/ZeroRatedMobileAccess
Gerrit-Branch: master
Gerrit-Owner: Dr0ptp4kt <[email protected]>
Gerrit-Reviewer: Yurik <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to