Pingback: Make Pingback a MediaWiki service
Change-Id: Ib93fb4e0098d32a8e9798b6e2109df4d347c23ce
This commit is contained in:
parent
82b378c3b0
commit
2dcae8e9b7
3 changed files with 25 additions and 14 deletions
|
|
@ -79,6 +79,7 @@ use MediaWiki\FileBackend\LockManager\LockManagerGroupFactory;
|
|||
use MediaWiki\HookContainer\HookContainer;
|
||||
use MediaWiki\HookContainer\HookRunner;
|
||||
use MediaWiki\Http\HttpRequestFactory;
|
||||
use MediaWiki\Installer\Pingback;
|
||||
use MediaWiki\Interwiki\InterwikiLookup;
|
||||
use MediaWiki\Interwiki\NullInterwikiLookup;
|
||||
use MediaWiki\JobQueue\JobFactory;
|
||||
|
|
@ -1668,6 +1669,15 @@ class MediaWikiServices extends ServiceContainer {
|
|||
return $this->getService( 'PermissionManager' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.41
|
||||
* @return Pingback
|
||||
* @internal
|
||||
*/
|
||||
public function getPingback(): Pingback {
|
||||
return $this->getService( 'Pingback' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.40
|
||||
* @return PoolCounterFactory
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ use MediaWiki\HookContainer\HookContainer;
|
|||
use MediaWiki\HookContainer\HookRunner;
|
||||
use MediaWiki\HookContainer\StaticHookRegistry;
|
||||
use MediaWiki\Http\HttpRequestFactory;
|
||||
use MediaWiki\Installer\Pingback;
|
||||
use MediaWiki\Interwiki\ClassicInterwikiLookup;
|
||||
use MediaWiki\Interwiki\InterwikiLookup;
|
||||
use MediaWiki\JobQueue\JobFactory;
|
||||
|
|
@ -1583,6 +1584,16 @@ return [
|
|||
);
|
||||
},
|
||||
|
||||
'Pingback' => static function ( MediaWikiServices $services ): PingBack {
|
||||
return new Pingback(
|
||||
$services->getMainConfig(),
|
||||
$services->getDBLoadBalancerFactory(),
|
||||
ObjectCache::getLocalClusterInstance(),
|
||||
$services->getHttpRequestFactory(),
|
||||
LoggerFactory::getInstance( 'Pingback' )
|
||||
);
|
||||
},
|
||||
|
||||
'PoolCounterFactory' => static function ( MediaWikiServices $services ): PoolCounterFactory {
|
||||
$mainConfig = $services->getMainConfig();
|
||||
return new PoolCounterFactory(
|
||||
|
|
|
|||
|
|
@ -27,11 +27,9 @@ use Config;
|
|||
use DeferredUpdates;
|
||||
use FormatJson;
|
||||
use MediaWiki\Http\HttpRequestFactory;
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MWCryptRand;
|
||||
use ObjectCache;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Wikimedia\Rdbms\DBError;
|
||||
use Wikimedia\Rdbms\IConnectionProvider;
|
||||
|
|
@ -302,7 +300,8 @@ class Pingback {
|
|||
* sent and (if so) proceed to send it.
|
||||
*/
|
||||
public static function schedulePingback(): void {
|
||||
$config = MediaWikiServices::getInstance()->getMainConfig();
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$config = $services->getMainConfig();
|
||||
if ( !$config->get( MainConfigNames::Pingback ) ) {
|
||||
// Fault tolerance:
|
||||
// Pingback is unusual. On a plain install of MediaWiki, it is likely the only
|
||||
|
|
@ -311,17 +310,8 @@ class Pingback {
|
|||
// or DB_PRIMARY have issues, allow this to be turned off completely. (T269516)
|
||||
return;
|
||||
}
|
||||
DeferredUpdates::addCallableUpdate( static function () {
|
||||
// Avoid re-use of $config as that would hold the same object from
|
||||
// the outer call via Setup.php, all the way here through post-send.
|
||||
$instance = new Pingback(
|
||||
MediaWikiServices::getInstance()->getMainConfig(),
|
||||
MediaWikiServices::getInstance()->getDBLoadBalancerFactory(),
|
||||
ObjectCache::getLocalClusterInstance(),
|
||||
MediaWikiServices::getInstance()->getHttpRequestFactory(),
|
||||
LoggerFactory::getInstance( 'Pingback' )
|
||||
);
|
||||
$instance->run();
|
||||
DeferredUpdates::addCallableUpdate( static function () use ( $services ) {
|
||||
$services->getPingback()->run();
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue