From 00c23304860ba80df8456e52898ad0c9bcaec00d Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 22 Jun 2024 14:07:51 +0200 Subject: [PATCH] Add a workaround for the migration of the spider data Fixes #5941 --- ...pdate_com.woltlab.wcf_6.1_spider_step1.php | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) rename wcfsetup/install/files/acp/{database => }/update_com.woltlab.wcf_6.1_spider_step1.php (62%) diff --git a/wcfsetup/install/files/acp/database/update_com.woltlab.wcf_6.1_spider_step1.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_6.1_spider_step1.php similarity index 62% rename from wcfsetup/install/files/acp/database/update_com.woltlab.wcf_6.1_spider_step1.php rename to wcfsetup/install/files/acp/update_com.woltlab.wcf_6.1_spider_step1.php index b807f63cc8..cf91642998 100644 --- a/wcfsetup/install/files/acp/database/update_com.woltlab.wcf_6.1_spider_step1.php +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_6.1_spider_step1.php @@ -10,11 +10,20 @@ */ use wcf\system\database\table\column\IntDatabaseTableColumn; +use wcf\system\database\table\DatabaseTableChangeProcessor; use wcf\system\database\table\index\DatabaseTableForeignKey; use wcf\system\database\table\index\DatabaseTableIndex; use wcf\system\database\table\PartialDatabaseTable; +use wcf\system\WCF; -return [ +$tableNames = WCF::getDB()->getEditor()->getTableNames(); +if (!\in_array('wcf' . WCF_N . '_spider', $tableNames)) { + // The table `wcf1_spider` will be removed by a database PIP that is + // executed after this script. + return; +} + +$tables = [ PartialDatabaseTable::create('wcf1_session') ->columns([ IntDatabaseTableColumn::create('spiderID') @@ -27,6 +36,9 @@ return [ ->drop(), ]) ->foreignKeys([ + // This foreign key definition fails to validate when the table + // `wcf1_spider` no longer exists, despite it being scheduled for + // removal. DatabaseTableForeignKey::create() ->columns(['spiderID']) ->referencedTable('wcf1_spider') @@ -35,3 +47,11 @@ return [ ->drop(), ]), ]; + +(new DatabaseTableChangeProcessor( + /** @var ScriptPackageInstallationPlugin $this */ + $this->installation->getPackage(), + $tables, + WCF::getDB()->getEditor() +) +)->process(); -- 2.20.1