mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-12-25 06:14:04 +00:00
e72f58ca78
Inspired by this Wikitech-l discussion: https://lists.wikimedia.org/hyperkitty/list/wikitech-l@lists.wikimedia.org/thread/NWXPNHRNLEVXHSWX33H473OAWQP6CDOA/ To keep this simple for now, I am only removing redundant PHPDoc comments on constructors, and only when all the documentation for parameters completely duplicates type hints. More could be done, but that can happen later when we have better tooling. Redundant comments on constructors that take a dozen services are by far the most annoying for me and I want them gone now. Change-Id: I86cbf7d6e48035cfa06f780c8fb1b02e68709a0c
56 lines
1.6 KiB
PHP
56 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* DiscussionTools data updates hooks
|
|
*
|
|
* @file
|
|
* @ingroup Extensions
|
|
* @license MIT
|
|
*/
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Hooks;
|
|
|
|
use DeferrableUpdate;
|
|
use MediaWiki\Extension\DiscussionTools\ThreadItemStore;
|
|
use MediaWiki\Revision\RenderedRevision;
|
|
use MediaWiki\Storage\Hook\RevisionDataUpdatesHook;
|
|
use MWCallableUpdate;
|
|
use MWExceptionHandler;
|
|
use Throwable;
|
|
use Title;
|
|
|
|
class DataUpdatesHooks implements RevisionDataUpdatesHook {
|
|
|
|
private ThreadItemStore $threadItemStore;
|
|
|
|
public function __construct(
|
|
ThreadItemStore $threadItemStore
|
|
) {
|
|
$this->threadItemStore = $threadItemStore;
|
|
}
|
|
|
|
/**
|
|
* @param Title $title
|
|
* @param RenderedRevision $renderedRevision
|
|
* @param DeferrableUpdate[] &$updates
|
|
* @return bool|void
|
|
*/
|
|
public function onRevisionDataUpdates( $title, $renderedRevision, &$updates ) {
|
|
// This doesn't trigger on action=purge, only on automatic purge after editing a template or
|
|
// transcluded page, and API action=purge&forcelinkupdate=1.
|
|
|
|
// TODO Deduplicate work between this and the Echo hook (make it use Parsoid too)
|
|
$rev = $renderedRevision->getRevision();
|
|
if ( HookUtils::isAvailableForTitle( $title ) ) {
|
|
$updates[] = new MWCallableUpdate( function () use ( $rev ) {
|
|
try {
|
|
$threadItemSet = HookUtils::parseRevisionParsoidHtml( $rev );
|
|
$this->threadItemStore->insertThreadItems( $rev, $threadItemSet );
|
|
} catch ( Throwable $e ) {
|
|
// Catch errors, so that they don't cause other updates to fail (T315383), but log them.
|
|
MWExceptionHandler::logException( $e );
|
|
}
|
|
}, __METHOD__ );
|
|
}
|
|
}
|
|
}
|