wiki.techinc.nl/includes/ResourceLoader/ResourceLoaderEntryPoint.php
Timo Tijhof f6b850ea20 ResourceLoader: Limit injection of valid skins to names only
Follows-up I0191a812f044a5c04c:

* $installedSkins was named after MediaWiki's SkinFactory and its
  return value was not a list of skins, or actually a registry
  of skin names and PHP classes (subclasses of "Skin"). This
  information is of no use to ResourceLoader as it cannot construct
  skin objects (skins would require an RequestContext such used on
  index.php).

  Change its format to an actual list, and rename to reflect its
  local purpose.

* Simplify logic to: If not set, or, we do validation and the
  value is not valid.

* Update docs to explain what "perform validation" means.

Change-Id: Ic8544d99055a7b7c7e55496006b5971e4e4fa14f
2024-07-23 22:07:19 +00:00

67 lines
2.1 KiB
PHP

<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
namespace MediaWiki\ResourceLoader;
use MediaWiki\MediaWikiEntryPoint;
use Profiler;
/**
* Entry point implementation for @ref ResourceLoader, which serves static CSS/JavaScript
* via @ref MediaWiki\ResourceLoader\Module Module subclasses.
*
* @see load.php
* @ingroup ResourceLoader
* @ingroup entrypoint
*/
class ResourceLoaderEntryPoint extends MediaWikiEntryPoint {
/**
* Main entry point
*/
public function execute() {
$services = $this->getServiceContainer();
// Disable ChronologyProtector so that we don't wait for unrelated MediaWiki
// writes when getting database connections for ResourceLoader. (T192611)
$services->getChronologyProtector()->setEnabled( false );
$resourceLoader = $services->getResourceLoader();
$context = new Context(
$resourceLoader,
$this->getRequest(),
array_keys( $services->getSkinFactory()->getInstalledSkins() )
);
// Respond to ResourceLoader request
$resourceLoader->respond( $context );
// Append any visible profiling data in a manner appropriate for the Content-Type
$profiler = Profiler::instance();
$profiler->setAllowOutput();
$profiler->logDataPageOutputOnly();
}
protected function doPrepareForOutput() {
// No-op.
// Do not call parent::doPrepareForOutput() to avoid
// commitMainTransaction() getting called.
}
}