Файловый менеджер - Редактировать - /var/www/html/mediawiki-1.43.1/extensions/SocialProfile/UserStats/maintenance/migrateOldUserPointsWeeklyUserColumnToActor.php
Ðазад
<?php /** * @file * @ingroup Maintenance */ use MediaWiki\MediaWikiServices; $IP = getenv( 'MW_INSTALL_PATH' ); if ( $IP === false ) { $IP = __DIR__ . '/../../../..'; } require_once "$IP/maintenance/Maintenance.php"; /** * Run automatically with update.php * * @since January 2020 */ class MigrateOldUserPointsWeeklyUserColumnToActor extends LoggedUpdateMaintenance { public function __construct() { parent::__construct(); $this->addDescription( 'Migrates data from old _user_name/_user_id columns in the user_points_weekly table to the new actor column.' ); } /** * Get the update key name to go in the update log table * * @return string */ protected function getUpdateKey() { return __CLASS__; } /** * Message to show that the update was done already and was just skipped * * @return string */ protected function updateSkippedMessage() { return 'user_points_weekly has already been migrated to use the actor column.'; } /** * Do the actual work. * * @return bool True to log the update as done */ protected function doDBUpdates() { $dbw = $this->getDB( DB_PRIMARY ); if ( !$dbw->fieldExists( 'user_points_weekly', 'up_user_id', __METHOD__ ) ) { // Old field's been dropped already so nothing to do here... // Why is this loop here? Because Postgres was being weird, that's why. return true; } $res = $dbw->select( 'user_points_weekly', [ 'up_user_id' ], '', __METHOD__, [ 'DISTINCT' ] ); foreach ( $res as $row ) { $user = User::newFromId( $row->up_user_id ); if ( interface_exists( '\MediaWiki\User\ActorNormalization' ) ) { // MW 1.36+ $actorId = MediaWikiServices::getInstance()->getActorNormalization()->acquireActorId( $user, $dbw ); } else { $actorId = $user->getActorId( $dbw ); } $dbw->update( 'user_points_weekly', [ 'up_actor' => $actorId ], [ 'up_user_id' => $row->up_user_id ], __METHOD__ ); } return true; } } $maintClass = MigrateOldUserPointsWeeklyUserColumnToActor::class; require_once RUN_MAINTENANCE_IF_MAIN;
| ver. 1.1 | |
.
| PHP 8.4.18 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка