+++ /dev/null
-<?php
-
-/**
- * @author Tim Duesterhus
- * @copyright 2001-2021 WoltLab GmbH
- * @license WoltLab License <http://www.woltlab.com/license-agreement.html>
- */
-
-use wcf\system\database\table\index\DatabaseTableIndex;
-use wcf\system\database\table\index\DatabaseTablePrimaryIndex;
-use wcf\system\database\table\PartialDatabaseTable;
-
-// 1) Generate a blueprint to fill in the generated index names.
-
-$blueprint = [
- PartialDatabaseTable::create('wcf1_conversation')
- ->indices([
- // DatabaseTablePrimaryIndex::create()
- // ->columns(['conversationID']),
- DatabaseTableIndex::create()
- ->columns(['userID', 'isDraft']),
- ]),
- PartialDatabaseTable::create('wcf1_conversation_to_user')
- ->indices([
- DatabaseTableIndex::create()
- ->columns(['participantID', 'conversationID'])
- ->type(DatabaseTableIndex::UNIQUE_TYPE),
- // DatabaseTableIndex::create()
- // ->columns(['participantID', 'hideConversation']),
- ]),
- PartialDatabaseTable::create('wcf1_conversation_message')
- ->indices([
- // DatabaseTablePrimaryIndex::create()
- // ->columns(['messageID']),
- DatabaseTableIndex::create()
- ->columns(['conversationID', 'userID']),
- DatabaseTableIndex::create()
- ->columns(['ipAddress']),
- ]),
- PartialDatabaseTable::create('wcf1_conversation_label')
- ->indices([
- // DatabaseTablePrimaryIndex::create()
- // ->columns(['labelID']),
- ]),
- PartialDatabaseTable::create('wcf1_conversation_label_to_object')
- ->indices([
- DatabaseTableIndex::create()
- ->columns(['labelID', 'conversationID'])
- ->type(DatabaseTableIndex::UNIQUE_TYPE),
- ]),
-];
-
-// 2) Use this blueprint to recreate the index objects with ->generatedName() set to false.
-// Simply dropping the indices with ->generatedName() set to true does not work, because it will
-// also remove named indices as the fact that a name was generated does not persist to the database.
-
-$data = [];
-foreach ($blueprint as $blueprintTable) {
- $data[] = PartialDatabaseTable::create($blueprintTable->getName())
- ->indices(\array_map(static function ($index) {
- \assert($index instanceof DatabaseTableIndex);
-
- return DatabaseTableIndex::create($index->getName())
- ->columns($index->getColumns())
- ->type($index->getType())
- ->drop();
- }, $blueprintTable->getIndices()));
-}
-
-return $data;
+++ /dev/null
-<?php
-
-/**
- * Deletes orphaned attachments.
- *
- * @author Tim Duesterhus
- * @copyright 2001-2022 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core
- */
-
-use wcf\data\attachment\AttachmentAction;
-use wcf\data\object\type\ObjectTypeCache;
-use wcf\system\package\SplitNodeException;
-use wcf\system\WCF;
-
-$objectType = ObjectTypeCache::getInstance()
- ->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', 'com.woltlab.wcf.conversation.message');
-
-$sql = "SELECT attachmentID
- FROM wcf1_attachment
- WHERE objectTypeID = ?
- AND objectID NOT IN (
- SELECT messageID
- FROM wcf1_conversation_message
- )";
-$statement = WCF::getDB()->prepare($sql, 100);
-$statement->execute([$objectType->objectTypeID]);
-$attachmentIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
-
-if (empty($attachmentIDs)) {
- return;
-}
-
-(new AttachmentAction($attachmentIDs, 'delete'))->executeAction();
-
-// If we reached this location we processed at least one attachment.
-// If this was the final attachment the next iteration will abort this
-// script early, thus not splitting the node.
-throw new SplitNodeException();