GWicke has submitted this change and it was merged.

Change subject: Use $wgCanonicalServer instead of $wgServer
......................................................................


Use $wgCanonicalServer instead of $wgServer

Unlike $wgServer, $wgCanonicalServer always contains the protocol
portion of the URL, easing domain extraction.

Also:
* better RegEx for extracting the domain from $wgCanonicalServer
  - now accounts for the possibility of $wgCanonicalServer having the
  form host:port
* minor variable name fix in RestbaseUpdate.php

Bug: T87520
Change-Id: I4f4242e31aeb21cf7aaff9fed24e0f376a0da4d2
---
M RestbaseUpdate.php
M RestbaseUpdateJob.php
2 files changed, 7 insertions(+), 3 deletions(-)

Approvals:
  GWicke: Verified; Looks good to me, approved



diff --git a/RestbaseUpdate.php b/RestbaseUpdate.php
index d6a50e2..c523f20 100644
--- a/RestbaseUpdate.php
+++ b/RestbaseUpdate.php
@@ -69,7 +69,7 @@
                /**
                 * The RESTBase server to inform of updates.
                */
-               $wgRestbaseServers = 'http://localhost:7321';
+               $wgRestbaseServer = 'http://localhost:7321';
 
                /**
                 * The RESTBase API version in use
diff --git a/RestbaseUpdateJob.php b/RestbaseUpdateJob.php
index 1883f5f..2347207 100644
--- a/RestbaseUpdateJob.php
+++ b/RestbaseUpdateJob.php
@@ -43,9 +43,13 @@
                // the prefix URL every time
                if ( is_null( $prefix ) ) {
                        global $wgRestbaseServer, $wgRestbaseAPIVersion,
-                               $wgRestbaseDomain, $wgServer;
+                               $wgRestbaseDomain, $wgCanonicalServer;
                        if ( !isset( $wgRestbaseDomain ) || is_null( 
$wgRestbaseDomain ) ) {
-                               $wgRestbaseDomain = preg_replace( 
'/^(https?:\/\/)?(.+?)\/?$/', '$2', $wgServer );
+                               $wgRestbaseDomain = preg_replace(
+                                       
'/^(https?:\/\/)?([^\/:]+?)(\/|:\d+\/?)?$/',
+                                       '$2',
+                                       $wgCanonicalServer
+                               );
                        }
                        $prefix = implode( '/', array(
                                $wgRestbaseServer,

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4f4242e31aeb21cf7aaff9fed24e0f376a0da4d2
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/RestBaseUpdateJobs
Gerrit-Branch: master
Gerrit-Owner: Mobrovac <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>

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

Reply via email to