r70375 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70374‎ | r70375 | r70376 >
Date:23:55, 2 August 2010
Author:tparscal
Status:ok (Comments)
Tags:
Comment:
Now the server automatically reports it's address when outputting the mediawiki module
Modified paths:
  • /branches/resourceloader/phase3/includes/ResourceLoader.php (modified) (history)
  • /branches/resourceloader/phase3/resources/mediawiki/mediawiki.js (modified) (history)
  • /branches/resourceloader/phase3/resources/test/index.html (modified) (history)

Diff [purge]

Index: branches/resourceloader/phase3/includes/ResourceLoader.php
@@ -234,6 +234,7 @@
235235 *
236236 * Also, the naming of these variables is horrible and sad, hopefully this can be worked on
237237 */
 238+ $parameters['server'] = dirname( $_SERVER['REQUEST_URI'] );
238239 echo "mw.config.set( " . json_encode( $parameters ) . " );\n";
239240 // Collect all loaders
240241 $loaders = array();
Index: branches/resourceloader/phase3/resources/test/index.html
@@ -7,17 +7,8 @@
88 body {
99 font-size: 100.01%;
1010 }
11 - p {
12 - font-size: 0.8em;
13 - }
14 - #tests li {
15 - color: white;
16 - }
1711 </style>
18 - <script type="text/javascript" src="../../load.php?modules=jquery|mediawiki&amp;debug=false&amp;skin=cyborg&amp;lang=ja"></script>
19 - <script type="text/javascript">
20 - mw.config.set( 'wgScriptPath', '../..' );
21 - </script>
 12+ <script type="text/javascript" src="../../load.php?modules=jquery|mediawiki&amp;debug=true&amp;skin=vector&amp;lang=ja"></script>
2213 </head>
2314 <body>
2415 <h1>Resource Loader Tests</h1>
Index: branches/resourceloader/phase3/resources/mediawiki/mediawiki.js
@@ -406,7 +406,7 @@
407407 var html = '';
408408 for ( var r = 0; r < requests.length; r++ ) {
409409 // Build out the HTML
410 - var src = mw.config.get( 'wgScriptPath' ) + '/load.php?' + jQuery.param( requests[r] );
 410+ var src = mw.config.get( 'server' ) + '/load.php?' + jQuery.param( requests[r] );
411411 html += '<script type="text/javascript" src="' + src + '"></script>';
412412 }
413413 // Append script to body

Comments

#Comment by Nikerabbit (talk | contribs)   14:27, 3 August 2010

I don't understand what is going on here? I don't think $_SERVER['REQUEST_URI'] is something you want to base on your urls. Just look at how complicated code there is includes/DefaultSettings.php to figure out the server name. And that still has problems in some server configurations, because it can be whatever the user wants and the only good option is to set it manually.

#Comment by Trevor Parscal (WMF) (talk | contribs)   17:06, 3 August 2010

Yeah, I'm positive it's not the right way to do it, but it got the functionality working quickly in this branch. I'm open to this being fixed to point to the actual server in all cases.

Status & tagging log