r23953 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23952‎ | r23953 | r23954 >
Date:13:46, 10 July 2007
Author:yurik
Status:old
Tags:
Comment:
Added $wgShowHostnames to shows/hide host names in API results and HTML comments
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/Wiki.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuerySiteinfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -701,14 +701,16 @@
702702 * @return string
703703 */
704704 function wfReportTime() {
705 - global $wgRequestTime;
 705+ global $wgRequestTime, $wgShowHostnames;
706706
707707 $now = wfTime();
708708 $elapsed = $now - $wgRequestTime;
709709
710 - $com = sprintf( "<!-- Served by %s in %01.3f secs. -->",
711 - wfHostname(), $elapsed );
712 - return $com;
 710+ if ($wgShowHostnames) {
 711+ return sprintf( "<!-- Served by %s in %01.3f secs. -->", wfHostname(), $elapsed );
 712+ } else {
 713+ return sprintf( "<!-- Served in %01.3f secs. -->", $elapsed );
 714+ }
713715 }
714716
715717 /**
Index: trunk/phase3/includes/api/ApiQuerySiteinfo.php
@@ -132,11 +132,14 @@
133133 }
134134
135135 protected function appendDbReplLagInfo($property, $includeAll) {
136 - global $wgLoadBalancer;
 136+ global $wgLoadBalancer, $wgShowHostnames;
137137
138138 $data = array();
139139
140140 if ($includeAll) {
 141+ if (!$wgShowHostnames)
 142+ $this->dieUsage('Cannot view all servers info unless $wgShowHostnames is true', 'includeAllDenied');
 143+
141144 global $wgDBservers;
142145 $lags = $wgLoadBalancer->getLagTimes();
143146 foreach( $lags as $i => $lag ) {
@@ -147,7 +150,7 @@
148151 } else {
149152 list( $host, $lag ) = $wgLoadBalancer->getMaxLag();
150153 $data[] = array (
151 - 'host' => $host,
 154+ 'host' => $wgShowHostnames ? $host : '',
152155 'lag' => $lag);
153156 }
154157
Index: trunk/phase3/includes/Wiki.php
@@ -57,14 +57,19 @@
5858 }
5959
6060 function checkMaxLag( $maxLag ) {
61 - global $wgLoadBalancer;
 61+ global $wgLoadBalancer, $wgShowHostnames;
 62+
6263 list( $host, $lag ) = $wgLoadBalancer->getMaxLag();
6364 if ( $lag > $maxLag ) {
6465 header( 'HTTP/1.1 503 Service Unavailable' );
6566 header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) );
6667 header( 'X-Database-Lag: ' . intval( $lag ) );
6768 header( 'Content-Type: text/plain' );
68 - echo "Waiting for $host: $lag seconds lagged\n";
 69+ if ($wgShowHostnames) {
 70+ echo "Waiting for $host: $lag seconds lagged\n";
 71+ } else {
 72+ echo "Waiting for a database server: $lag seconds lagged\n";
 73+ }
6974 return false;
7075 } else {
7176 return true;
Index: trunk/phase3/includes/DefaultSettings.php
@@ -921,7 +921,11 @@
922922 $wgShowExceptionDetails = false;
923923
924924 /**
925 - * disable experimental dmoz-like category browsing. Output things like:
 925+ * If set to true, exposes host names through API and HTML comments.
 926+ */
 927+$wgShowHostnames = false;
 928+
 929+/** * disable experimental dmoz-like category browsing. Output things like:
926930 * Encyclopedia > Music > Style of Music > Jazz
927931 */
928932 $wgUseCategoryBrowser = false;
Index: trunk/phase3/RELEASE-NOTES
@@ -25,6 +25,7 @@
2626 * $wgAddGroups, $wgRemoveGroups - Finer control over who can assign which
2727 usergroups
2828 * $wgEnotifImpersonal, $wgEnotifUseJobQ - Bulk mail options for large sites
 29+* $wgShowHostnames - Shows host names in API results and HTML comments
2930
3031 == New features since 1.10 ==
3132

Follow-up revisions

RevisionCommit summaryAuthorDate
r24096Merged revisions 23910-24094 via svnmerge from...david22:38, 14 July 2007

Status & tagging log