[bugfix] Fetch tag ID before calling undefineTag()
authorMartin Urbanec <martin@urbanec.cz>
Sun, 16 Jun 2019 14:15:22 +0000 (16:15 +0200)
committerMartin Urbanec <martin@urbanec.cz>
Sun, 16 Jun 2019 14:17:53 +0000 (16:17 +0200)
undefineTag() also deletes the tag if it's not used anywhere,
which is breaking the rest of deleteTagEverywhere() in that case.

Bug: T225564
Change-Id: I7ca5db9efd0088b266e33c0a9ce78d73a4fa87c9

includes/changetags/ChangeTags.php

index 9146429..7466f82 100644 (file)
@@ -1229,11 +1229,13 @@ class ChangeTags {
                $dbw = wfGetDB( DB_MASTER );
                $dbw->startAtomic( __METHOD__ );
 
+               // fetch tag id, this must be done before calling undefineTag(), see T225564
+               $tagId = MediaWikiServices::getInstance()->getChangeTagDefStore()->getId( $tag );
+
                // set ctd_user_defined = 0
                self::undefineTag( $tag );
 
                // delete from change_tag
-               $tagId = MediaWikiServices::getInstance()->getChangeTagDefStore()->getId( $tag );
                $dbw->delete( 'change_tag', [ 'ct_tag_id' => $tagId ], __METHOD__ );
                $dbw->delete( 'change_tag_def', [ 'ctd_name' => $tag ], __METHOD__ );
                $dbw->endAtomic( __METHOD__ );