Файловый менеджер - Редактировать - /var/www/html/HookHandler.zip
Ðазад
PK ! ��r0 0 ToolLinksHandler.phpnu �[��� <?php namespace MediaWiki\CheckUser\HookHandler; use MediaWiki\Hook\ContributionsToolLinksHook; use MediaWiki\Hook\UserToolLinksEditHook; use MediaWiki\Linker\LinkRenderer; use MediaWiki\Permissions\PermissionManager; use MediaWiki\SpecialPage\SpecialPage; use MediaWiki\SpecialPage\SpecialPageFactory; use MediaWiki\Title\Title; use MediaWiki\User\UserIdentityLookup; use MediaWiki\User\UserIdentityUtils; use RequestContext; class ToolLinksHandler implements ContributionsToolLinksHook, UserToolLinksEditHook { private PermissionManager $permissionManager; private SpecialPageFactory $specialPageFactory; private LinkRenderer $linkRenderer; private UserIdentityLookup $userIdentityLookup; private UserIdentityUtils $userIdentityUtils; /** * @param PermissionManager $permissionManager * @param SpecialPageFactory $specialPageFactory * @param LinkRenderer $linkRenderer * @param UserIdentityLookup $userIdentityLookup * @param UserIdentityUtils $userIdentityUtils */ public function __construct( PermissionManager $permissionManager, SpecialPageFactory $specialPageFactory, LinkRenderer $linkRenderer, UserIdentityLookup $userIdentityLookup, UserIdentityUtils $userIdentityUtils ) { $this->permissionManager = $permissionManager; $this->specialPageFactory = $specialPageFactory; $this->linkRenderer = $linkRenderer; $this->userIdentityLookup = $userIdentityLookup; $this->userIdentityUtils = $userIdentityUtils; } /** * Add a link to Special:CheckUser and Special:CheckUserLog * on Special:Contributions/<username> for * privileged users. * * @param int $id User ID * @param Title $nt User page title * @param string[] &$links Tool links * @param SpecialPage $sp Special page */ public function onContributionsToolLinks( $id, Title $nt, array &$links, SpecialPage $sp ) { $user = $sp->getUser(); $linkRenderer = $sp->getLinkRenderer(); if ( $this->permissionManager->userHasRight( $user, 'checkuser' ) ) { $links['checkuser'] = $linkRenderer->makeKnownLink( SpecialPage::getTitleFor( 'CheckUser' ), $sp->msg( 'checkuser-contribs' )->text(), [ 'class' => 'mw-contributions-link-check-user' ], [ 'user' => $nt->getText() ] ); } if ( $this->permissionManager->userHasRight( $user, 'checkuser-log' ) ) { $links['checkuser-log'] = $linkRenderer->makeKnownLink( SpecialPage::getTitleFor( 'CheckUserLog' ), $sp->msg( 'checkuser-contribs-log' )->text(), [ 'class' => 'mw-contributions-link-check-user-log' ], [ 'cuSearch' => $nt->getText() ] ); $userIdentity = $this->userIdentityLookup->getUserIdentityByUserId( $id ); if ( $id && $userIdentity && $this->userIdentityUtils->isNamed( $userIdentity ) ) { $links['checkuser-log-initiator'] = $linkRenderer->makeKnownLink( SpecialPage::getTitleFor( 'CheckUserLog' ), $sp->msg( 'checkuser-contribs-log-initiator' )->text(), [ 'class' => 'mw-contributions-link-check-user-initiator' ], [ 'cuInitiator' => $nt->getText() ] ); } } } /** @inheritDoc */ public function onUserToolLinksEdit( $userId, $userText, &$items ) { $requestTitle = RequestContext::getMain()->getTitle(); if ( $requestTitle !== null && $requestTitle->isSpecialPage() ) { $specialPageName = $this->specialPageFactory->resolveAlias( $requestTitle->getText() )[0]; if ( $specialPageName === 'CheckUserLog' ) { $items[] = $this->linkRenderer->makeLink( SpecialPage::getTitleFor( 'CheckUserLog', $userText ), wfMessage( 'checkuser-log-checks-on' )->text() ); } elseif ( $specialPageName === 'CheckUser' ) { $items[] = $this->linkRenderer->makeLink( SpecialPage::getTitleFor( 'CheckUser', $userText ), wfMessage( 'checkuser-toollink-check' )->text(), [], [ 'reason' => RequestContext::getMain()->getRequest()->getVal( 'reason', '' ) ] ); } } } } PK ! ٰE,K K UserMergeHandler.phpnu �[��� <?php namespace MediaWiki\CheckUser\HookHandler; use MediaWiki\Extension\UserMerge\Hooks\AccountFieldsHook; class UserMergeHandler implements AccountFieldsHook { /** @inheritDoc */ public function onUserMergeAccountFields( array &$updateFields ): void { $updateFields[] = [ 'cu_changes', 'batch_key' => 'cuc_id', 'actorId' => 'cuc_actor', 'actorStage' => SCHEMA_COMPAT_NEW ]; $updateFields[] = [ 'cu_log', 'batch_key' => 'cul_id', 'actorId' => 'cul_actor', 'actorStage' => SCHEMA_COMPAT_NEW ]; $updateFields[] = [ 'cu_log', 'cul_target_id' ]; } } PK ! �EB�j j PageDisplay.phpnu �[��� <?php namespace MediaWiki\CheckUser\HookHandler; use MediaWiki\Config\Config; use MediaWiki\Hook\BeforePageDisplayHook; use MediaWiki\Permissions\PermissionManager; use MediaWiki\User\Options\UserOptionsLookup; class PageDisplay implements BeforePageDisplayHook { private Config $config; private PermissionManager $permissionManager; protected UserOptionsLookup $userOptionsLookup; /** * @param Config $config * @param PermissionManager $permissionManager * @param UserOptionsLookup $userOptionsLookup */ public function __construct( Config $config, PermissionManager $permissionManager, UserOptionsLookup $userOptionsLookup ) { $this->config = $config; $this->permissionManager = $permissionManager; $this->userOptionsLookup = $userOptionsLookup; } /** * @inheritDoc */ public function onBeforePageDisplay( $out, $skin ): void { $action = $out->getRequest()->getVal( 'action' ); if ( $action !== 'history' && $action !== 'info' && $out->getRequest()->getRawVal( 'diff' ) === null && $out->getRequest()->getRawVal( 'oldid' ) === null && !( $out->getTitle() && ( $out->getTitle()->isSpecialPage() ) ) ) { return; } $user = $out->getUser(); if ( !$this->permissionManager->userHasRight( $user, 'checkuser-temporary-account-no-preference' ) && ( !$this->permissionManager->userHasRight( $user, 'checkuser-temporary-account' ) || !$this->userOptionsLookup->getOption( $user, 'checkuser-temporary-account-enable' ) ) ) { return; } // If the user is blocked if ( $user->getBlock() ) { return; } // Config needed for a js-added message on Special:Block if ( $out->getTitle()->isSpecial( 'Block' ) ) { $out->addJSConfigVars( [ 'wgCUDMaxAge' => $this->config->get( 'CUDMaxAge' ) ] ); } $out->addModules( 'ext.checkUser' ); $out->addModuleStyles( 'ext.checkUser.styles' ); $out->addJSConfigVars( [ 'wgCheckUserTemporaryAccountMaxAge' => $this->config->get( 'CheckUserTemporaryAccountMaxAge' ), 'wgCheckUserEventTablesMigrationStage' => $this->config->get( 'CheckUserEventTablesMigrationStage' ), ] ); } } PK ! ��U RLRegisterModulesHandler.phpnu �[��� <?php namespace MediaWiki\CheckUser\HookHandler; use ExtensionRegistry; use MediaWiki\ResourceLoader\Hook\ResourceLoaderRegisterModulesHook; use MediaWiki\ResourceLoader\ResourceLoader; class RLRegisterModulesHandler implements ResourceLoaderRegisterModulesHook { /** * @inheritDoc */ public function onResourceLoaderRegisterModules( ResourceLoader $resourceLoader ): void { if ( ExtensionRegistry::getInstance()->isLoaded( 'GuidedTour' ) ) { $dir = dirname( __DIR__, 2 ) . '/modules/'; $modules = [ 'ext.guidedTour.tour.checkuserinvestigateform' => [ 'localBasePath' => $dir . 'ext.guidedTour.tour.checkuserinvestigateform', 'remoteExtPath' => "CheckUser/modules", 'scripts' => "checkuserinvestigateform.js", 'dependencies' => 'ext.guidedTour', 'messages' => [ 'checkuser-investigate-tour-targets-title', 'checkuser-investigate-tour-targets-desc' ] ], 'ext.guidedTour.tour.checkuserinvestigate' => [ 'localBasePath' => $dir . 'ext.guidedTour.tour.checkuserinvestigate', 'remoteExtPath' => "CheckUser/module", 'scripts' => 'checkuserinvestigate.js', 'dependencies' => [ 'ext.guidedTour', 'ext.checkUser' ], 'messages' => [ 'checkuser-investigate-tour-useragents-title', 'checkuser-investigate-tour-useragents-desc', 'checkuser-investigate-tour-addusertargets-title', 'checkuser-investigate-tour-addusertargets-desc', 'checkuser-investigate-tour-filterip-title', 'checkuser-investigate-tour-filterip-desc', 'checkuser-investigate-tour-block-title', 'checkuser-investigate-tour-block-desc', 'checkuser-investigate-tour-copywikitext-title', 'checkuser-investigate-tour-copywikitext-desc', ], ] ]; $resourceLoader->register( $modules ); } } } PK ! ��y� ContributionsHandler.phpnu �[��� <?php namespace MediaWiki\CheckUser\HookHandler; use MediaWiki\CheckUser\Services\CheckUserLookupUtils; use MediaWiki\Config\Config; use MediaWiki\Hook\ContribsPager__getQueryInfoHook; use MediaWiki\Permissions\PermissionManager; use MediaWiki\User\Options\UserOptionsLookup; use MediaWiki\User\TempUser\TempUserConfig; use Wikimedia\IPUtils; use Wikimedia\Rdbms\IConnectionProvider; use Wikimedia\Rdbms\IExpression; class ContributionsHandler implements ContribsPager__getQueryInfoHook { private Config $config; private PermissionManager $permissionManager; private IConnectionProvider $dbProvider; private TempUserConfig $tempUserConfig; private UserOptionsLookup $userOptionsLookup; private CheckUserLookupUtils $checkUserLookupUtils; /** * @param Config $config * @param PermissionManager $permissionManager * @param IConnectionProvider $dbProvider * @param TempUserConfig $tempUserConfig * @param UserOptionsLookup $userOptionsLookup * @param CheckUserLookupUtils $checkUserLookupUtils */ public function __construct( Config $config, PermissionManager $permissionManager, IConnectionProvider $dbProvider, TempUserConfig $tempUserConfig, UserOptionsLookup $userOptionsLookup, CheckUserLookupUtils $checkUserLookupUtils ) { $this->config = $config; $this->permissionManager = $permissionManager; $this->dbProvider = $dbProvider; $this->tempUserConfig = $tempUserConfig; $this->userOptionsLookup = $userOptionsLookup; $this->checkUserLookupUtils = $checkUserLookupUtils; } /** * @inheritDoc */ public function onContribsPager__getQueryInfo( $pager, &$queryInfo ) { if ( !$this->tempUserConfig->isEnabled() ) { return; } $target = $pager->getTarget(); if ( !IPUtils::isValid( $target ) ) { // TODO: Handle ranges and change isValid to isIPAddress: T361867 return; } $user = $pager->getUser(); if ( !$this->permissionManager->userHasRight( $user, 'checkuser-temporary-account-no-preference' ) && ( !$this->permissionManager->userHasRight( $user, 'checkuser-temporary-account' ) || !$this->userOptionsLookup->getOption( $user, 'checkuser-temporary-account-enable' ) ) ) { return; } if ( $user->getBlock() ) { return; } $dbr = $this->dbProvider->getReplicaDatabase(); $ipConds = $this->checkUserLookupUtils->getIPTargetExpr( $target, false, 'cu_changes' ); if ( !$ipConds ) { return; } $results = $dbr->newSelectQueryBuilder() ->select( [ 'cuc_actor', 'actor_name' ] ) ->from( 'cu_changes' ) ->where( $ipConds ) ->andWhere( $this->tempUserConfig->getMatchCondition( $dbr, 'actor_name', IExpression::LIKE ) ) ->caller( __METHOD__ ) ->groupBy( [ 'cuc_actor', 'actor_name' ] ) ->limit( $this->config->get( 'CheckUserMaximumRowCount' ) ) ->join( 'actor', null, 'actor_id=cuc_actor' ) ->fetchResultSet(); $names = [ $queryInfo['conds']['actor_name'] ]; foreach ( $results as $row ) { $names[] = $row->actor_name; } $queryInfo['conds']['actor_name'] = $names; } } PK ! �:�<v v RenameUserSQLHandler.phpnu �[��� <?php namespace MediaWiki\CheckUser\HookHandler; use MediaWiki\RenameUser\Hook\RenameUserSQLHook; use MediaWiki\RenameUser\RenameuserSQL; class RenameUserSQLHandler implements RenameUserSQLHook { /** @inheritDoc */ public function onRenameUserSQL( RenameuserSQL $renameUserSql ): void { $renameUserSql->tables['cu_log'] = [ 'cul_target_text', 'cul_target_id' ]; } } PK ! �-x�� � Preferences.phpnu �[��� <?php namespace MediaWiki\CheckUser\HookHandler; use MediaWiki\CheckUser\Logging\TemporaryAccountLoggerFactory; use MediaWiki\Permissions\PermissionManager; use MediaWiki\Preferences\Hook\GetPreferencesHook; use MediaWiki\User\UserIdentity; class Preferences implements GetPreferencesHook { /** @var string */ public const INVESTIGATE_TOUR_SEEN = 'checkuser-investigate-tour-seen'; /** @var string */ public const INVESTIGATE_FORM_TOUR_SEEN = 'checkuser-investigate-form-tour-seen'; private PermissionManager $permissionManager; private TemporaryAccountLoggerFactory $loggerFactory; /** * @param PermissionManager $permissionManager * @param TemporaryAccountLoggerFactory $loggerFactory */ public function __construct( PermissionManager $permissionManager, TemporaryAccountLoggerFactory $loggerFactory ) { $this->permissionManager = $permissionManager; $this->loggerFactory = $loggerFactory; } /** * @inheritDoc */ public function onGetPreferences( $user, &$preferences ) { $preferences[self::INVESTIGATE_TOUR_SEEN] = [ 'type' => 'api', ]; $preferences[self::INVESTIGATE_FORM_TOUR_SEEN] = [ 'type' => 'api', ]; if ( $this->permissionManager->userHasRight( $user, 'checkuser-temporary-account' ) && !$this->permissionManager->userHasRight( $user, 'checkuser-temporary-account-no-preference' ) ) { $preferences['checkuser-temporary-account-enable'] = [ 'type' => 'toggle', 'label-message' => 'checkuser-tempaccount-enable-preference', // The following message is generated here: // * prefs-checkuser-tempaccount 'section' => 'personal/checkuser-tempaccount', ]; } } /** * @param UserIdentity $user * @param array &$modifiedOptions * @param array $originalOptions */ public function onSaveUserOptions( UserIdentity $user, array &$modifiedOptions, array $originalOptions ) { $wasEnabled = !empty( $originalOptions['checkuser-temporary-account-enable'] ); $wasDisabled = !$wasEnabled; $willEnable = !empty( $modifiedOptions['checkuser-temporary-account-enable'] ); $willDisable = isset( $modifiedOptions['checkuser-temporary-account-enable'] ) && !$modifiedOptions['checkuser-temporary-account-enable']; if ( ( $wasDisabled && $willEnable ) || ( $wasEnabled && $willDisable ) ) { $logger = $this->loggerFactory->getLogger(); if ( $willEnable ) { $logger->logAccessEnabled( $user ); } else { $logger->logAccessDisabled( $user ); } } } } PK ! ���� � SpecialPageInitListHandler.phpnu �[��� <?php namespace MediaWiki\CheckUser\HookHandler; use MediaWiki\CheckUser\Investigate\SpecialInvestigate; use MediaWiki\CheckUser\Investigate\SpecialInvestigateBlock; use MediaWiki\Config\Config; use MediaWiki\SpecialPage\Hook\SpecialPage_initListHook; // The name of onSpecialPage_initList raises the following phpcs error. As the // name is defined in core, this is an unavoidable issue and therefore the check // is disabled. // // phpcs:disable MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName /** * Hook handler for the SpecialPage_initList hook */ class SpecialPageInitListHandler implements SpecialPage_initListHook { private Config $config; public function __construct( Config $config ) { $this->config = $config; } /** @inheritDoc */ public function onSpecialPage_initList( &$list ) { if ( $this->config->get( 'CheckUserEnableSpecialInvestigate' ) ) { $list['Investigate'] = [ 'class' => SpecialInvestigate::class, 'services' => [ 'LinkRenderer', 'ContentLanguage', 'UserOptionsManager', 'CheckUserPreliminaryCheckPagerFactory', 'CheckUserComparePagerFactory', 'CheckUserTimelinePagerFactory', 'CheckUserTokenQueryManager', 'CheckUserDurationManager', 'CheckUserEventLogger', 'CheckUserGuidedTourLauncher', 'CheckUserHookRunner', 'PermissionManager', 'CheckUserLogService', 'UserIdentityLookup', 'UserFactory', ], ]; $list['InvestigateBlock'] = [ 'class' => SpecialInvestigateBlock::class, 'services' => [ 'BlockUserFactory', 'BlockPermissionCheckerFactory', 'PermissionManager', 'TitleFormatter', 'UserFactory', 'CheckUserEventLogger', ] ]; } return true; } } PK ! �{]`+ `+ SchemaChangesHandler.phpnu �[��� <?php namespace MediaWiki\CheckUser\HookHandler; use MediaWiki\CheckUser\Maintenance\FixTrailingSpacesInLogs; use MediaWiki\CheckUser\Maintenance\MoveLogEntriesFromCuChanges; use MediaWiki\CheckUser\Maintenance\PopulateCheckUserTable; use MediaWiki\CheckUser\Maintenance\PopulateCucActor; use MediaWiki\CheckUser\Maintenance\PopulateCucComment; use MediaWiki\CheckUser\Maintenance\PopulateCulActor; use MediaWiki\CheckUser\Maintenance\PopulateCulComment; use MediaWiki\Installer\Hook\LoadExtensionSchemaUpdatesHook; class SchemaChangesHandler implements LoadExtensionSchemaUpdatesHook { /** * @codeCoverageIgnore This is tested by installing or updating MediaWiki * @inheritDoc */ public function onLoadExtensionSchemaUpdates( $updater ) { $base = __DIR__ . '/../../schema'; $maintenanceDb = $updater->getDB(); $dbType = $maintenanceDb->getType(); $isCUInstalled = $updater->tableExists( 'cu_changes' ); $updater->addExtensionTable( 'cu_changes', "$base/$dbType/tables-generated.sql" ); if ( $dbType === 'mysql' ) { // 1.35 $updater->modifyExtensionField( 'cu_changes', 'cuc_id', "$base/$dbType/patch-cu_changes-cuc_id-unsigned.sql" ); // 1.38 $updater->addExtensionIndex( 'cu_changes', 'cuc_actor_ip_time', "$base/$dbType/patch-cu_changes-actor-comment.sql" ); // 1.39 $updater->modifyExtensionField( 'cu_changes', 'cuc_timestamp', "$base/$dbType/patch-cu_changes-cuc_timestamp.sql" ); $updater->addExtensionField( 'cu_log', 'cul_reason_id', "$base/$dbType/patch-cu_log-comment_table_for_reason.sql" ); $updater->addExtensionField( 'cu_log', 'cul_actor', "$base/$dbType/patch-cu_log-actor.sql" ); } elseif ( $dbType === 'sqlite' ) { // 1.39 $updater->addExtensionIndex( 'cu_changes', 'cuc_actor_ip_time', "$base/$dbType/patch-cu_changes-actor-comment.sql" ); $updater->addExtensionField( 'cu_log', 'cul_reason_id', "$base/$dbType/patch-cu_log-comment_table_for_reason.sql" ); $updater->addExtensionField( 'cu_log', 'cul_actor', "$base/$dbType/patch-cu_log-actor.sql" ); } elseif ( $dbType === 'postgres' ) { // 1.37 $updater->addExtensionUpdate( [ 'dropFkey', 'cu_log', 'cul_user' ] ); $updater->addExtensionUpdate( [ 'dropFkey', 'cu_log', 'cul_target_id' ] ); $updater->addExtensionUpdate( [ 'dropFkey', 'cu_changes', 'cuc_user' ] ); $updater->addExtensionUpdate( [ 'dropFkey', 'cu_changes', 'cuc_page_id' ] ); // 1.38 $updater->addExtensionUpdate( [ 'addPgField', 'cu_changes', 'cuc_actor', 'INTEGER NOT NULL DEFAULT 0' ] ); $updater->addExtensionUpdate( [ 'addPgField', 'cu_changes', 'cuc_comment_id', 'INTEGER NOT NULL DEFAULT 0' ] ); $updater->addExtensionUpdate( [ 'setDefault', 'cu_changes', 'cuc_user_text', '' ] ); $updater->addExtensionUpdate( [ 'addPgIndex', 'cu_changes', 'cuc_actor_ip_time', '( cuc_actor, cuc_ip, cuc_timestamp )' ] ); // 1.39 $updater->addExtensionIndex( 'cu_changes', 'cu_changes_pkey', "$base/$dbType/patch-cu_changes-pk.sql" ); $updater->addExtensionUpdate( [ 'changeField', 'cu_changes', 'cuc_namespace', 'INT', 'cuc_namespace::INT DEFAULT 0' ] ); if ( $maintenanceDb->fieldExists( 'cu_log', 'cuc_user' ) ) { $updater->addExtensionUpdate( [ 'changeNullableField', 'cu_changes', 'cuc_user', 'NOT NULL', true ] ); } if ( $maintenanceDb->fieldExists( 'cu_log', 'cuc_user_text' ) ) { $updater->addExtensionUpdate( [ 'changeField', 'cu_changes', 'cuc_user_text', 'VARCHAR(255)', '' ] ); $updater->addExtensionUpdate( [ 'setDefault', 'cu_changes', 'cuc_user_text', '' ] ); } $updater->addExtensionUpdate( [ 'changeField', 'cu_changes', 'cuc_actor', 'BIGINT', 'cuc_actor::BIGINT DEFAULT 0' ] ); $updater->addExtensionUpdate( [ 'changeField', 'cu_changes', 'cuc_comment_id', 'BIGINT', 'cuc_comment_id::BIGINT DEFAULT 0' ] ); $updater->addExtensionUpdate( [ 'changeField', 'cu_changes', 'cuc_minor', 'SMALLINT', 'cuc_minor::SMALLINT DEFAULT 0' ] ); $updater->addExtensionUpdate( [ 'changeNullableField', 'cu_changes', 'cuc_page_id', 'NOT NULL', true ] ); $updater->addExtensionUpdate( [ 'setDefault', 'cu_changes', 'cuc_page_id', 0 ] ); $updater->addExtensionUpdate( [ 'changeNullableField', 'cu_changes', 'cuc_timestamp', 'NOT NULL', true ] ); $updater->addExtensionUpdate( [ 'changeField', 'cu_changes', 'cuc_ip', 'VARCHAR(255)', '' ] ); $updater->addExtensionUpdate( [ 'setDefault', 'cu_changes', 'cuc_ip', '' ] ); $updater->addExtensionUpdate( [ 'changeField', 'cu_changes', 'cuc_ip_hex', 'VARCHAR(255)', '' ] ); $updater->addExtensionUpdate( [ 'setDefault', 'cu_changes', 'cuc_xff', '' ] ); $updater->addExtensionUpdate( [ 'changeField', 'cu_changes', 'cuc_xff_hex', 'VARCHAR(255)', '' ] ); $updater->addExtensionUpdate( [ 'changeField', 'cu_changes', 'cuc_private', 'TEXT', '' ] ); $updater->addExtensionIndex( 'cu_log', 'cu_log_pkey', "$base/$dbType/patch-cu_log-pk.sql" ); $updater->addExtensionUpdate( [ 'changeNullableField', 'cu_log', 'cul_timestamp', 'NOT NULL', true ] ); if ( $maintenanceDb->fieldExists( 'cu_log', 'cul_user' ) ) { $updater->addExtensionUpdate( [ 'changeNullableField', 'cu_log', 'cul_user', 'NOT NULL', true ] ); } $updater->addExtensionUpdate( [ 'dropDefault', 'cu_log', 'cul_type' ] ); $updater->addExtensionUpdate( [ 'changeNullableField', 'cu_log', 'cul_target_id', 'NOT NULL', true ] ); $updater->addExtensionUpdate( [ 'setDefault', 'cu_log', 'cul_target_id', 0 ] ); $updater->addExtensionUpdate( [ 'dropDefault', 'cu_log', 'cul_target_text' ] ); $updater->addExtensionUpdate( [ 'addPgField', 'cu_log', 'cul_reason_id', 'INTEGER NOT NULL DEFAULT 0' ] ); $updater->addExtensionUpdate( [ 'addPgField', 'cu_log', 'cul_reason_plaintext_id', 'INTEGER NOT NULL DEFAULT 0' ] ); $updater->addExtensionUpdate( [ 'addPgField', 'cu_log', 'cul_actor', 'INTEGER NOT NULL DEFAULT 0' ] ); $updater->addExtensionUpdate( [ 'addPgIndex', 'cu_log', 'cul_actor_time', '( cul_actor, cul_timestamp )' ] ); } $updater->addExtensionUpdate( [ 'runMaintenance', PopulateCulActor::class, 'extensions/CheckUser/maintenance/populateCulActor.php' ] ); $updater->addExtensionUpdate( [ 'runMaintenance', PopulateCulComment::class, 'extensions/CheckUser/maintenance/populateCulComment.php' ] ); if ( $dbType === 'postgres' ) { # For wikis which ran update.php after pulling the master branch of CheckUser between # 4 June 2022 and 6 June 2022, the cul_reason_id and cul_reason_plaintext_id columns # were added but were by default NULL. # This is needed for postgres installations that did the above. All other DB types # make the columns "NOT NULL" when removing the default. $updater->addExtensionUpdate( [ 'changeNullableField', 'cu_log', 'cul_reason_id', 'NOT NULL', true ] ); $updater->addExtensionUpdate( [ 'changeNullableField', 'cu_log', 'cul_reason_plaintext_id', 'NOT NULL', true ] ); } $updater->addExtensionUpdate( [ 'runMaintenance', PopulateCucActor::class, 'extensions/CheckUser/maintenance/populateCucActor.php' ] ); $updater->addExtensionUpdate( [ 'runMaintenance', PopulateCucComment::class, 'extensions/CheckUser/maintenance/populateCucComment.php' ] ); // 1.40 $updater->addExtensionTable( 'cu_log_event', "$base/$dbType/patch-cu_log_event-def.sql" ); $updater->addExtensionTable( 'cu_private_event', "$base/$dbType/patch-cu_private_event-def.sql" ); $updater->dropExtensionField( 'cu_log', 'cul_user', "$base/$dbType/patch-cu_log-drop-cul_user.sql" ); if ( $dbType !== 'sqlite' || $maintenanceDb->fieldExists( 'cu_log', 'cul_reason' ) ) { // Only run this for SQLite if cul_reason exists, // as modifyExtensionField does not take into account // SQLite patches that use temporary tables. If the cul_reason // field does not exist this SQL would fail, however, cul_reason // not existing also means this change has been previously applied. $updater->modifyExtensionField( 'cu_log', 'cul_actor', "$base/$dbType/patch-cu_log-drop-actor_default.sql" ); } $updater->dropExtensionField( 'cu_log', 'cul_reason', "$base/$dbType/patch-cu_log-drop-cul_reason.sql" ); $updater->modifyExtensionField( 'cu_log', 'cul_reason_id', "$base/$dbType/patch-cu_log-drop-cul_reason_id_default.sql" ); $updater->dropExtensionField( 'cu_changes', 'cuc_user', "$base/$dbType/patch-cu_changes-drop-cuc_user.sql" ); $updater->addExtensionField( 'cu_changes', 'cuc_only_for_read_old', "$base/$dbType/patch-cu_changes-add-cuc_only_for_read_old.sql" ); $updater->dropExtensionField( 'cu_changes', 'cuc_comment', "$base/$dbType/patch-cu_changes-drop-cuc_comment.sql" ); $updater->modifyExtensionField( 'cu_changes', 'cuc_actor', "$base/$dbType/patch-cu_changes-drop-defaults.sql" ); // 1.41 $updater->addExtensionTable( 'cu_useragent_clienthints', "$base/$dbType/cu_useragent_clienthints.sql" ); $updater->addExtensionTable( 'cu_useragent_clienthints_map', "$base/$dbType/cu_useragent_clienthints_map.sql" ); $updater->addPostDatabaseUpdateMaintenance( MoveLogEntriesFromCuChanges::class ); // 1.42 $updater->addExtensionField( 'cu_log', 'cul_result_id', "$base/$dbType/patch-cu_log-add-cul_result_id.sql" ); if ( $dbType !== 'sqlite' ) { $updater->modifyExtensionField( 'cu_changes', 'cuc_id', "$base/$dbType/patch-cu_changes-modify-cuc_id-bigint.sql" ); } $updater->addPostDatabaseUpdateMaintenance( FixTrailingSpacesInLogs::class ); // If any columns are modified or removed from cu_private_event in the future, then make sure to only apply this // patch if the later schema change has not yet been applied. Otherwise wikis using SQLite will have a DB error. $updater->modifyExtensionField( 'cu_private_event', 'cupe_actor', "$base/$dbType/patch-cu_private_event-modify-cupe_actor-nullable.sql" ); $updater->addExtensionTable( 'cu_useragent', "$base/$dbType/cu_useragent.sql" ); $updater->addExtensionField( 'cu_changes', 'cuc_agent_id', "$base/$dbType/patch-cu_changes-add-cuc_agent_id.sql" ); $updater->addExtensionField( 'cu_log_event', 'cule_agent_id', "$base/$dbType/patch-cu_log_event-add-cule_agent_id.sql" ); $updater->addExtensionField( 'cu_private_event', 'cupe_agent_id', "$base/$dbType/patch-cu_private_event-add-cupe_agent_id.sql" ); if ( !$isCUInstalled ) { // First time so populate cu_changes with recentchanges data. // Note: We cannot completely rely on updatelog here for old entries // as populateCheckUserTable.php doesn't check for duplicates $updater->addPostDatabaseUpdateMaintenance( PopulateCheckUserTable::class ); } } } PK ! !�� ClientHints.phpnu �[��� <?php namespace MediaWiki\CheckUser\HookHandler; use MediaWiki\Config\Config; use MediaWiki\Hook\BeforePageDisplayHook; use MediaWiki\SpecialPage\Hook\SpecialPageBeforeExecuteHook; /** * HookHandler for entry points related to requesting User-Agent Client Hints data. */ class ClientHints implements SpecialPageBeforeExecuteHook, BeforePageDisplayHook { private Config $config; /** * @param Config $config */ public function __construct( Config $config ) { $this->config = $config; } /** @inheritDoc */ public function onSpecialPageBeforeExecute( $special, $subPage ) { if ( !$this->config->get( 'CheckUserClientHintsEnabled' ) ) { return; } $request = $special->getRequest(); if ( $request->wasPosted() ) { // It's too late to ask for client hints when a user is POST'ing a form. if ( $this->config->get( 'CheckUserClientHintsUnsetHeaderWhenPossible' ) ) { $request->response()->header( $this->getEmptyClientHintsHeaderString() ); } return; } if ( in_array( $special->getName(), $this->config->get( 'CheckUserClientHintsSpecialPages' ) ) ) { $request->response()->header( $this->getClientHintsHeaderString() ); } elseif ( $this->config->get( 'CheckUserClientHintsUnsetHeaderWhenPossible' ) ) { $request->response()->header( $this->getEmptyClientHintsHeaderString() ); } } /** @inheritDoc */ public function onBeforePageDisplay( $out, $skin ): void { // We handle special pages in BeforeSpecialPageBeforeExecute. if ( $out->getTitle()->isSpecialPage() || // ClientHints is globally disabled !$this->config->get( 'CheckUserClientHintsEnabled' ) ) { return; } $out->addJsConfigVars( [ // Roundabout way to ensure we have a list of values like "architecture", "bitness" // etc for use with the client-side JS API. Make sure we get 1) just the values // from the configuration, 2) filter out any empty entries, 3) convert to a list 'wgCheckUserClientHintsHeadersJsApi' => array_values( array_filter( array_values( $this->config->get( 'CheckUserClientHintsHeaders' ) ) ) ), ] ); $out->addModules( 'ext.checkUser.clientHints' ); if ( $this->config->get( 'CheckUserClientHintsUnsetHeaderWhenPossible' ) ) { $request = $out->getRequest(); $request->response()->header( $this->getEmptyClientHintsHeaderString() ); } } /** * Get the list of headers to use with Accept-CH. * * @return string */ private function getClientHintsHeaderString(): string { $headers = implode( ', ', array_filter( array_keys( $this->config->get( 'CheckUserClientHintsHeaders' ) ) ) ); return "Accept-CH: $headers"; } /** * Get an Accept-CH header string to tell the client to stop sending client-hint data. * * @return string */ private function getEmptyClientHintsHeaderString(): string { return "Accept-CH: "; } } PK ! ��r0 0 ToolLinksHandler.phpnu �[��� PK ! ٰE,K K t UserMergeHandler.phpnu �[��� PK ! �EB�j j PageDisplay.phpnu �[��� PK ! ��U � RLRegisterModulesHandler.phpnu �[��� PK ! ��y� "