r68381 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68380‎ | r68381 | r68382 >
Date:21:26, 21 June 2010
Author:catrope
Status:deferred
Tags:
Comment:
resourceloader: Add load.php entry point, add ResourceLoader to the autoloader, add wikibits module for testing
Modified paths:
  • /branches/resourceloader/phase3/includes/AutoLoader.php (modified) (history)
  • /branches/resourceloader/phase3/includes/ResourceLoader.php (modified) (history)
  • /branches/resourceloader/phase3/load.php (added) (history)

Diff [purge]

Index: branches/resourceloader/phase3/includes/ResourceLoader.php
@@ -36,6 +36,10 @@
3737 * 'script' and 'loader' are mandatory.
3838 */
3939 public static $modules = array(
 40+ 'wikibits' => array(
 41+ 'script' => 'skins/common/wikibits.js',
 42+ 'loader' => 'skins/common/loader.js',
 43+ ),
4044 );
4145
4246 private $scripts = array();
@@ -76,6 +80,7 @@
7781 $retval = '';
7882 foreach ( $styles as $style ) {
7983 // TODO: file_get_contents() errors?
 84+ // TODO: CACHING!
8085 $css = file_get_contents( $style );
8186 if ( $this->useCSSJanus ) {
8287 $css = $this->cssJanus( $css );
@@ -103,6 +108,7 @@
104109
105110 foreach ( $this->scripts as $script ) {
106111 // TODO: file_get_contents() errors?
 112+ // TODO: CACHING!
107113 $retval .= file_get_contents( $script );
108114 }
109115 $retval .= $this->getStyleJS( $this->styles );
@@ -118,6 +124,7 @@
119125 $retval = '';
120126 foreach ( self::$modules as $name => $module ) {
121127 // TODO: file_get_contents() errors?
 128+ // TODO: CACHING!
122129 $retval .= file_get_contents( $module['loader'] );
123130 }
124131 // FIXME: Duplicated; centralize in doJSTransforms() or something?
Index: branches/resourceloader/phase3/includes/AutoLoader.php
@@ -186,6 +186,7 @@
187187 'RegexlikeReplacer' => 'includes/StringUtils.php',
188188 'ReplacementArray' => 'includes/StringUtils.php',
189189 'Replacer' => 'includes/StringUtils.php',
 190+ 'ResourceLoader' => 'includes/ResourceLoader.php',
190191 'ReverseChronologicalPager' => 'includes/Pager.php',
191192 'Revision' => 'includes/Revision.php',
192193 'RevisionDelete' => 'includes/RevisionDelete.php',
Index: branches/resourceloader/phase3/load.php
@@ -0,0 +1,64 @@
 2+<?php
 3+/**
 4+ * This program is free software; you can redistribute it and/or modify
 5+ * it under the terms of the GNU General Public License as published by
 6+ * the Free Software Foundation; either version 2 of the License, or
 7+ * (at your option) any later version.
 8+ *
 9+ * This program is distributed in the hope that it will be useful,
 10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 12+ * GNU General Public License for more details.
 13+ *
 14+ * You should have received a copy of the GNU General Public License along
 15+ * with this program; if not, write to the Free Software Foundation, Inc.,
 16+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 17+ * http://www.gnu.org/copyleft/gpl.html
 18+ *
 19+ * @author Roan Kattouw
 20+ *
 21+ */
 22+
 23+/**
 24+ * This file is the entry point for the resource loader.
 25+ */
 26+
 27+// TODO: Caching + easy 304s before WebStart
 28+
 29+require ( dirname( __FILE__ ) . '/includes/WebStart.php' );
 30+wfProfileIn( 'loader.php' );
 31+
 32+// URL safety checks
 33+//
 34+// See RawPage.php for details; summary is that MSIE can override the
 35+// Content-Type if it sees a recognized extension on the URL, such as
 36+// might be appended via PATH_INFO after 'api.php'.
 37+//
 38+// Some data formats can end up containing unfiltered user-provided data
 39+// which will end up triggering HTML detection and execution, hence
 40+// XSS injection and all that entails.
 41+//
 42+if ( $wgRequest->isPathInfoBad() ) {
 43+ wfHttpError( 403, 'Forbidden',
 44+ 'Invalid file extension found in PATH_INFO. ' .
 45+ 'The resource loader must be accessed through the primary script entry point.' );
 46+ return;
 47+ // FIXME: Doesn't this execute the rest of the request anyway?
 48+ // Was taken from api.php so I guess it's maybe OK but it doesn't look good.
 49+}
 50+
 51+$loader = new ResourceLoader();
 52+$moduleParam = $wgRequest->getVal( 'modules' );
 53+$modules = $moduleParam ? explode( '|', $moduleParam ) : array();
 54+foreach ( $modules as $module ) {
 55+ $loader->addModule( $module );
 56+}
 57+
 58+// TODO: Cache-Control header
 59+echo $loader->getOutput();
 60+
 61+wfProfileOut( 'loader.php' );
 62+wfLogProfilingData();
 63+
 64+// Shut down the database
 65+wfGetLBFactory()->shutdown();
\ No newline at end of file

Status & tagging log