Pingback: Don't instantiate service if disabled by configuration

The service has an early return already and the performance overhead
of scheduling, executing and instantiatingn the service and its deferred
update is extremely low.

But, it makes the overall system harder to reason about when execution
always runs through here. And it helps developers to isolate problems
and improve fault tolerance by being able to properly turn this off
if it or its dependencies are causing issues for whatever reason.

The dependencies it uses are quite core to MW, and so their issues
should not be ignored, but it makes the difference between a site
mostly working for readers and a site completely being down, because
on a stock MW install, Pingback is the only feature that uses
DeferredUpdates on regular page views by default.

Bug: T270540
Change-Id: I0d5da6bf3affdf8ab27239ef77fb8cfd87aa70d0
This commit is contained in:
Timo Tijhof 2020-12-19 03:25:15 +00:00
parent 43e3a6460b
commit b1856d9f38

View file

@ -286,7 +286,18 @@ class Pingback {
* sent and (if so) proceed to send it.
*/
public static function schedulePingback() : void {
$config = MediaWikiServices::getInstance()->getMainConfig();
if ( !$config->get( 'Pingback' ) ) {
// Fault tolerance:
// Pingback is unusual. On a plain install of MediaWiki, it is likely the only
// feature making use of DeferredUpdates and DB_MASTER on most page views.
// In order for the wiki to remain available and readable even if DeferredUpdates
// or DB_MASTER have issues, allow this to be turned off completely. (T269516)
return;
}
DeferredUpdates::addCallableUpdate( 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()->getDBLoadBalancer(),