From ce023443bcef4e2094c1befab68a4a587f528ca1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 12 Jun 2023 15:08:09 +0200 Subject: [PATCH] Add update_com.woltlab.wcf_6.0_articleOrphans.php Resolves #5339 --- com.woltlab.wcf/package.xml | 3 ++ ...ate_com.woltlab.wcf_6.0_articleOrphans.php | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 wcfsetup/install/files/acp/update_com.woltlab.wcf_6.0_articleOrphans.php diff --git a/com.woltlab.wcf/package.xml b/com.woltlab.wcf/package.xml index eb85a928b3..8e9ca9bafe 100644 --- a/com.woltlab.wcf/package.xml +++ b/com.woltlab.wcf/package.xml @@ -84,6 +84,9 @@ tar cvf com.woltlab.wcf/files_pre_check.tar -C wcfsetup/install/files/ \ acp/update_com.woltlab.wcf_6.0_landingPage.php + + acp/update_com.woltlab.wcf_6.0_articleOrphans.php + acp/database/update_com.woltlab.wcf_6.0_reaction_fk_step1.php acp/database/update_com.woltlab.wcf_6.0_reaction_fk_step2.php diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_6.0_articleOrphans.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_6.0_articleOrphans.php new file mode 100644 index 0000000000..f036ed83c3 --- /dev/null +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_6.0_articleOrphans.php @@ -0,0 +1,31 @@ + + */ + +use wcf\data\article\ArticleAction; +use wcf\system\package\SplitNodeException; +use wcf\system\WCF; + +$sql = "SELECT articleID + FROM wcf1_article + WHERE categoryID IS NULL"; +$statement = WCF::getDB()->prepare($sql, 50); +$statement->execute(); +$articleIDs = $statement->fetchAll(\PDO::FETCH_COLUMN); + +if ($articleIDs === []) { + return; +} + +$articleAction = new ArticleAction($articleIDs, 'delete'); +$articleAction->executeAction(); + +// Repeat the deletion if any article was deleted. If no deletable articles +// remain, the script will abort further above. +throw new SplitNodeException(); -- 2.20.1