Dzahn has submitted this change and it was merged.

Change subject: build external links based on si_server,si_articlepath
......................................................................


build external links based on si_server,si_articlepath

This looks like a small change but it's actually quite big.

In the past we were using URLs with "Special:Statistics?action=raw"
and we were trying to guesstimate the links to other Special
pages by splitting URLs at the 'S' and replacing. But this was
broken for many, as evidenced by the request in T136183.

After this we are going to use the newer database fields
"si_server" and "si_articlepath" to build a more reliable URLs.

These come directly from the API(.php). It fixes it for the example
wiki lietuvai.lt which asked for the wiki and for many others.

It works for newer mediawikis that have these set and provide them
via API. Another prerequisite is that update.php ran with the "extinfo"
option for this wiki at least once, but that should be done for most where
it worked.

So this fixes it for many and it is still broken for others but it's definitely
the way to go and the reliable way to create URLs from a MW API.

Bug:T136183
Change-Id: I907235779a5b7758a4f2ff42c29ad2b9fbfa34a4
---
M usr/share/php/wikistats/largest_query.php
M var/www/wikistats/largest_html.php
2 files changed, 3 insertions(+), 2 deletions(-)

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



diff --git a/usr/share/php/wikistats/largest_query.php 
b/usr/share/php/wikistats/largest_query.php
index 5b72737..ee6ce74 100755
--- a/usr/share/php/wikistats/largest_query.php
+++ b/usr/share/php/wikistats/largest_query.php
@@ -8,6 +8,7 @@
 $fields_uncyclo = "id,lang,statsurl AS prefix,version,${number_fields}";
 $fields_nolangs = "id,name AS lang,statsurl AS 
prefix,version,${number_fields}";
 $fields_nolang2 = "id,name AS lang,statsurl,version,${number_fields}";
+$fields_mediawikis = "id,si_sitename as lang, concat(si_server,si_articlepath) 
as prefix,version,${number_fields}";
 $fields_wikia   = "id,prefix as lang,prefix,version,${number_fields}";
 
 # build the query to combine it all
@@ -37,7 +38,7 @@
 
 UNION SELECT ${fields_uncyclo},"Uncyclomedia" AS type FROM uncyclomedia WHERE 
good >= ${threshold} AND statsurl not like "%wikia.com%"
 
-UNION SELECT ${fields_nolangs},"Mediawiki" AS type FROM mediawikis WHERE  good 
>= ${threshold}
+UNION SELECT ${fields_mediawikis},"Mediawiki" AS type FROM mediawikis WHERE  
good >= ${threshold}
 
 UNION SELECT ${fields_nolangs},"openSUSE" AS type FROM opensuse WHERE good >= 
${threshold}
 
diff --git a/var/www/wikistats/largest_html.php 
b/var/www/wikistats/largest_html.php
index 25b1b72..e52f193 100644
--- a/var/www/wikistats/largest_html.php
+++ b/var/www/wikistats/largest_html.php
@@ -253,7 +253,7 @@
     case "Mediawiki":
         $name=$row['lang'];
         $surl=htmlspecialchars($row['prefix']);
-        $url=explode("S",$row['prefix']);
+        $url=explode("$1",$row['prefix']);
         $url=$url[0];
         $url=htmlspecialchars($url);
     break;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I907235779a5b7758a4f2ff42c29ad2b9fbfa34a4
Gerrit-PatchSet: 2
Gerrit-Project: operations/debs/wikistats
Gerrit-Branch: master
Gerrit-Owner: Dzahn <dz...@wikimedia.org>
Gerrit-Reviewer: Dzahn <dz...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to