}
}
+ /**
+ * @inheritDoc
+ */
+ public static function deleteAll(array $objectIDs = []) {
+ // delete language items
+ if (!empty($objectIDs)) {
+ $sql = "DELETE FROM wcf".WCF_N."_language_item
+ WHERE languageItem = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+
+ WCF::getDB()->beginTransaction();
+ foreach ($objectIDs as $cronjobID) {
+ $statement->execute(['wcf.acp.cronjob.description.cronjob' . $cronjobID]);
+ }
+ WCF::getDB()->commitTransaction();
+ }
+
+ return parent::deleteAll($objectIDs);
+ }
+
/**
* @inheritDoc
*/
return $menu;
}
+ /**
+ * @inheritDoc
+ */
+ public static function deleteAll(array $objectIDs = []) {
+ if (!empty($objectIDs)) {
+ // delete language items
+ $menuList = new MenuList();
+ $menuList->setObjectIDs($objectIDs);
+ $menuList->readObjects();
+
+ if (count($menuList)) {
+ $sql = "DELETE FROM wcf".WCF_N."_language_item
+ WHERE languageItem = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+
+ WCF::getDB()->beginTransaction();
+ foreach ($menuList as $menu) {
+ $statement->execute(['wcf.menu.' . $menu->identifier]);
+ }
+ WCF::getDB()->commitTransaction();
+ }
+ }
+
+ return parent::deleteAll($objectIDs);
+ }
+
/**
* @inheritDoc
*/
return $menuItem;
}
+ /**
+ * @inheritDoc
+ */
+ public static function deleteAll(array $objectIDs = []) {
+ if (!empty($objectIDs)) {
+ // delete language items
+ $menuItemList = new MenuItemList();
+ $menuItemList->setObjectIDs($objectIDs);
+ $menuItemList->readObjects();
+
+ if (count($menuItemList)) {
+ $sql = "DELETE FROM wcf".WCF_N."_language_item
+ WHERE languageItem = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+
+ WCF::getDB()->beginTransaction();
+ foreach ($menuItemList as $menuItem) {
+ $statement->execute(['wcf.menu.item.' . $menuItem->identifier]);
+ }
+ WCF::getDB()->commitTransaction();
+ }
+ }
+
+ return parent::deleteAll($objectIDs);
+ }
+
/**
* @inheritDoc
*/
namespace wcf\system\package\plugin;
use wcf\data\cronjob\Cronjob;
use wcf\data\cronjob\CronjobEditor;
+use wcf\data\cronjob\CronjobList;
use wcf\system\cronjob\ICronjob;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\devtools\pip\IDevtoolsPipEntryList;
use wcf\system\devtools\pip\IGuiPackageInstallationPlugin;
use wcf\system\devtools\pip\TXmlGuiPackageInstallationPlugin;
* @inheritDoc
*/
protected function handleDelete(array $items) {
- $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
- WHERE className = ?
- AND packageID = ?";
- $legacyStatement = WCF::getDB()->prepareStatement($sql);
-
- $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
- WHERE cronjobName = ?
- AND packageID = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
-
+ // read cronjobs from database because deleting the language items requires the
+ // cronjob id
+ $cronjobs = $legacyCronjobs = [];
foreach ($items as $item) {
if (!isset($item['attributes']['name'])) {
- $legacyStatement->execute([
- $item['elements']['classname'],
- $this->installation->getPackageID()
- ]);
+ $legacyCronjobs[] = $item['elements']['classname'];
}
else {
- $statement->execute([
- $item['attributes']['name'],
- $this->installation->getPackageID()
- ]);
+ $cronjobs[] = $item['attributes']['name'];
}
}
+
+ if (empty($cronjobs) && empty($legacyCronjobs)) {
+ return;
+ }
+
+ $cronjobList = new CronjobList();
+ $cronjobList->getConditionBuilder()->add(
+ 'packageID = ?',
+ [$this->installation->getPackageID()]
+ );
+
+ $conditionBuilder = new PreparedStatementConditionBuilder(false, 'OR');
+ if (!empty($cronjobs)) {
+ $conditionBuilder->add('cronjobName IN (?)', [$cronjobs]);
+ }
+ if (!empty($legacyCronjobs)) {
+ $conditionBuilder->add('className IN (?)', [$legacyCronjobs]);
+ }
+ $cronjobList->getConditionBuilder()->add($conditionBuilder, $conditionBuilder->getParameters());
+ $cronjobList->readObjectIDs();
+
+ if (!empty($cronjobList->getObjectIDs())) {
+ CronjobEditor::deleteAll($cronjobList->getObjectIDs());
+ }
}
/**
AND packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
+ $sql = "DELETE FROM wcf" . WCF_N . "_language_item
+ WHERE languageItem = ?";
+ $languageItemStatement = WCF::getDB()->prepareStatement($sql);
+
WCF::getDB()->beginTransaction();
foreach ($items as $item) {
$statement->execute([
$item['attributes']['identifier'],
$this->installation->getPackageID()
]);
+
+ $languageItemStatement->execute([
+ 'wcf.menu.item.' . $item['attributes']['identifier']
+ ]);
}
WCF::getDB()->commitTransaction();
}
AND packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
+ $sql = "DELETE FROM wcf" . WCF_N . "_language_item
+ WHERE languageItem = ?";
+ $languageItemStatement = WCF::getDB()->prepareStatement($sql);
+
WCF::getDB()->beginTransaction();
foreach ($items as $item) {
$statement->execute([
$item['attributes']['identifier'],
$this->installation->getPackageID()
]);
+
+ $languageItemStatement->execute([
+ 'wcf.menu.' . $item['attributes']['identifier']
+ ]);
}
WCF::getDB()->commitTransaction();
}