Remove redundant data updates for GadgetDefinitionNamespaceRepo

Remove DefinitionDeletionUpdate and DefinitionSecondaryDataUpdate –
both call $repo->handlePageUpdate() which is already being called from
onPageSaveComplete/onPageDeleteComplete hooks.

The chain that made this redundant:

1. Ibe2e26d123, change hooks from hardcoded to GadgetRepo singleton.
2. Ieccc1cae8c, migrate from create-only onPageContentInsertComplete
   hook to create-and-edit onPageSaveComplete hook.
3. Ib27fd34fbf, further consolidate handling of create and edit
   events with handlePageUpdate, and remove any hook-level
   conditionals. At this point, the DateUpdate classes became redundant.

Bug: T31272
Change-Id: I20c2759b219c80571237a73e8422f3128047eb87
This commit is contained in:
Siddharth VP 2023-12-11 00:39:53 +05:30 committed by Krinkle
parent c665a90423
commit 8695a4ee1a
3 changed files with 0 additions and 124 deletions

View file

@ -21,12 +21,10 @@
namespace MediaWiki\Extension\Gadgets\Content;
use Content;
use DeferrableUpdate;
use FormatJson;
use JsonContentHandler;
use Linker;
use MediaWiki\Content\Renderer\ContentParseParams;
use MediaWiki\Revision\SlotRenderingProvider;
use MediaWiki\Title\Title;
use ParserOutput;
@ -81,40 +79,6 @@ class GadgetDefinitionContentHandler extends JsonContentHandler {
];
}
/**
* @param Title $title The title of the page to supply the updates for.
* @param string $role The role (slot) in which the content is being used.
* @return DeferrableUpdate[] A list of DeferrableUpdate objects for putting information
* about this content object somewhere.
*/
public function getDeletionUpdates( Title $title, $role ) {
return array_merge(
parent::getDeletionUpdates( $title, $role ),
[ new GadgetDefinitionDeletionUpdate( $title ) ]
);
}
/**
* @param Title $title The title of the page to supply the updates for.
* @param Content $content The content to generate data updates for.
* @param string $role The role (slot) in which the content is being used.
* @param SlotRenderingProvider $slotOutput A provider that can be used to gain access to
* a ParserOutput of $content by calling $slotOutput->getSlotParserOutput( $role, false ).
* @return DeferrableUpdate[] A list of DeferrableUpdate objects for putting information
* about this content object somewhere.
*/
public function getSecondaryDataUpdates(
Title $title,
Content $content,
$role,
SlotRenderingProvider $slotOutput
) {
return array_merge(
parent::getSecondaryDataUpdates( $title, $content, $role, $slotOutput ),
[ new GadgetDefinitionSecondaryDataUpdate( $title ) ]
);
}
/**
* @inheritDoc
*/

View file

@ -1,46 +0,0 @@
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
namespace MediaWiki\Extension\Gadgets\Content;
use DataUpdate;
use MediaWiki\Linker\LinkTarget;
use MediaWiki\MediaWikiServices;
/**
* DataUpdate to run whenever a page in the Gadget definition
* is deleted.
*/
class GadgetDefinitionDeletionUpdate extends DataUpdate {
/**
* Page that was deleted
* @var LinkTarget
*/
private $target;
public function __construct( LinkTarget $target ) {
$this->target = $target;
}
public function doUpdate() {
$gadgetRepo = MediaWikiServices::getInstance()->getService( 'GadgetsRepo' );
$gadgetRepo->handlePageUpdate( $this->target );
}
}

View file

@ -1,42 +0,0 @@
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
namespace MediaWiki\Extension\Gadgets\Content;
use DataUpdate;
use MediaWiki\Linker\LinkTarget;
use MediaWiki\MediaWikiServices;
class GadgetDefinitionSecondaryDataUpdate extends DataUpdate {
/**
* @var LinkTarget
*/
private $target;
public function __construct( LinkTarget $target ) {
$this->target = $target;
}
public function doUpdate() {
$gadgetRepo = MediaWikiServices::getInstance()->getService( 'GadgetsRepo' );
$gadgetRepo->handlePageUpdate( $this->target );
}
}