From 9cb3b7e886a015ac3dce987f9465017d64fb249c Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Fri, 18 Nov 2022 10:05:22 -0100 Subject: [PATCH 1/4] remove 'chunk' Signed-off-by: Maxence Lange --- lib/Cron/Chunk.php | 70 ------------------------------ lib/Db/SocialCoreQueryBuilder.php | 28 ------------ lib/Db/SocialCrossQueryBuilder.php | 2 - lib/Db/StreamRequest.php | 2 - tests/psalm-baseline.xml | 8 +--- 5 files changed, 1 insertion(+), 109 deletions(-) delete mode 100644 lib/Cron/Chunk.php diff --git a/lib/Cron/Chunk.php b/lib/Cron/Chunk.php deleted file mode 100644 index b7c87ab3..00000000 --- a/lib/Cron/Chunk.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright 2018, Maxence Lange - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - -namespace OCA\Social\Cron; - -use OCP\AppFramework\Utility\ITimeFactory; -use OCP\BackgroundJob\TimedJob; -use OCA\Social\Service\ConfigService; -use OCP\AppFramework\QueryException; - -/** - * Class Queue - * - * @package OCA\Social\Cron - */ -class Chunk extends TimedJob { - private ConfigService $configService; - - public function __construct(ITimeFactory $time, ConfigService $configService) { - parent::__construct($time); - $this->setInterval(12 * 3600); // 12 hours - $this->configService = $configService; - } - - - /** - * @param mixed $argument - * - * @throws QueryException - */ - protected function run($argument) { - $size = (int)$this->configService->getAppValue(ConfigService::DATABASE_CHUNK_SIZE); - $this->morphChunks($size); - } - - - /** - * @param int $size - */ - private function morphChunks(int $size): void { - } -} diff --git a/lib/Db/SocialCoreQueryBuilder.php b/lib/Db/SocialCoreQueryBuilder.php index fc8f9644..433de466 100644 --- a/lib/Db/SocialCoreQueryBuilder.php +++ b/lib/Db/SocialCoreQueryBuilder.php @@ -34,7 +34,6 @@ namespace OCA\Social\Db; use OCA\Social\Tools\Db\ExtendedQueryBuilder; use OC\SystemConfig; use OCA\Social\Model\ActivityPub\Actor\Person; -use OCP\DB\QueryBuilder\ICompositeExpression; use OCP\IDBConnection; use OCP\IURLGenerator; use Psr\Log\LoggerInterface; @@ -47,7 +46,6 @@ use Psr\Log\LoggerInterface; class SocialCoreQueryBuilder extends ExtendedQueryBuilder { protected IURLGenerator $urlGenerator; private ?Person $viewer = null; - private int $chunk = 0; public function __construct( IDBConnection $connection, SystemConfig $systemConfig, LoggerInterface $logger, IURLGenerator $urlGenerator @@ -57,32 +55,6 @@ class SocialCoreQueryBuilder extends ExtendedQueryBuilder { $this->urlGenerator = $urlGenerator; } - public function setChunk(int $chunk): self { - $this->chunk = $chunk; - $this->inChunk(); - - return $this; - } - - public function getChunk(): int { - return $this->chunk; - } - - /** - * Limit the request to a chunk - */ - public function inChunk(string $alias = '', ?ICompositeExpression $expr = null): void { - if ($this->getChunk() === 0) { - return; - } - - if ($expr !== null) { - $expr->add($this->exprLimitToDBFieldInt('chunk', $this->getChunk(), $alias)); - - return; - } - $this->limitToDBFieldInt('chunk', $this->getChunk(), $alias); - } public function hasViewer(): bool { return ($this->viewer !== null); diff --git a/lib/Db/SocialCrossQueryBuilder.php b/lib/Db/SocialCrossQueryBuilder.php index bf76c02a..821309e0 100644 --- a/lib/Db/SocialCrossQueryBuilder.php +++ b/lib/Db/SocialCrossQueryBuilder.php @@ -56,7 +56,6 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder { if ($aliasDest !== '') { $this->from(CoreRequestBuilder::TABLE_STREAM_DEST, $aliasDest); -// $this->inChunk($aliasDest); } if ($aliasFollowing !== '') { $this->from(CoreRequestBuilder::TABLE_FOLLOWS, $aliasFollowing); @@ -277,7 +276,6 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder { $orX->add($expr->eq($alias . '.stream_id_prim', $pf . '.object_id_prim')); $on = $expr->andX(); -// $this->inChunk('sa', $on); $viewer = $this->getViewer(); $idPrim = $this->prim($viewer->getId()); diff --git a/lib/Db/StreamRequest.php b/lib/Db/StreamRequest.php index c814c15e..5da6c922 100644 --- a/lib/Db/StreamRequest.php +++ b/lib/Db/StreamRequest.php @@ -359,7 +359,6 @@ class StreamRequest extends StreamRequestBuilder { */ public function getTimelineHome(TimelineOptions $options): array { $qb = $this->getStreamSelectSql($options->getFormat()); - $qb->setChunk(1); $qb->filterType(SocialAppNotification::TYPE); $qb->paginate($options); @@ -396,7 +395,6 @@ class StreamRequest extends StreamRequestBuilder { int $since = 0, int $limit = 5, int $format = Stream::FORMAT_ACTIVITYPUB ): array { $qb = $this->getStreamSelectSql($format); - $qb->setChunk(1); $qb->filterType(SocialAppNotification::TYPE); $qb->limitPaginate($since, $limit); diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml index 2c030301..993ea03b 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -1,5 +1,5 @@ - + $level @@ -138,10 +138,4 @@ HintException - - - $curl - - - From 7da94393dc7aeec7af6a746b8d81bc5d7e0e9251 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Fri, 18 Nov 2022 14:31:53 -0100 Subject: [PATCH 2/4] stabilize database Signed-off-by: Maxence Lange --- lib/Db/CacheActorsRequestBuilder.php | 2 +- lib/Db/CoreRequestBuilder.php | 48 +- lib/Db/SocialCrossQueryBuilder.php | 3 +- lib/Migration/CheckInstallation.php | 74 --- .../Version0003Date20200823023900.php | 96 ---- .../Version0003Date20200823023911.php | 451 ----------------- .../Version0003Date20200921103342.php | 86 ---- ....php => Version1000Date20221118000001.php} | 464 ++++++++---------- lib/Service/ConfigService.php | 4 +- 9 files changed, 242 insertions(+), 986 deletions(-) delete mode 100644 lib/Migration/CheckInstallation.php delete mode 100644 lib/Migration/Version0003Date20200823023900.php delete mode 100644 lib/Migration/Version0003Date20200823023911.php delete mode 100644 lib/Migration/Version0003Date20200921103342.php rename lib/Migration/{Version0003Date20200611000001.php => Version1000Date20221118000001.php} (74%) diff --git a/lib/Db/CacheActorsRequestBuilder.php b/lib/Db/CacheActorsRequestBuilder.php index 779c21bf..11992cae 100644 --- a/lib/Db/CacheActorsRequestBuilder.php +++ b/lib/Db/CacheActorsRequestBuilder.php @@ -77,7 +77,7 @@ class CacheActorsRequestBuilder extends CoreRequestBuilder { /** @noinspection PhpMethodParametersCountMismatchInspection */ $qb->select( - 'ca.nid', 'ca.id', 'ca.account', 'ca.following', 'ca.followers', 'ca.inbox', 'ca.shared_inbox', + 'ca.id', 'ca.account', 'ca.following', 'ca.followers', 'ca.inbox', 'ca.shared_inbox', 'ca.outbox', 'ca.featured', 'ca.url', 'ca.type', 'ca.preferred_username', 'ca.name', 'ca.summary', 'ca.public_key', 'ca.local', 'ca.details', 'ca.source', 'ca.creation' ) diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php index 727bea99..1b5a73ba 100644 --- a/lib/Db/CoreRequestBuilder.php +++ b/lib/Db/CoreRequestBuilder.php @@ -48,6 +48,7 @@ use OCA\Social\Service\MiscService; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; use OCP\IURLGenerator; +use OCP\Server; use Psr\Log\LoggerInterface; /** @@ -56,26 +57,26 @@ use Psr\Log\LoggerInterface; * @package OCA\Social\Db */ class CoreRequestBuilder { - public const TABLE_REQUEST_QUEUE = 'social_3_req_queue'; - public const TABLE_INSTANCE = 'social_3_instance'; + public const TABLE_REQUEST_QUEUE = 'social_req_queue'; + public const TABLE_INSTANCE = 'social_instance'; - public const TABLE_ACTORS = 'social_3_actor'; - public const TABLE_STREAM = 'social_3_stream'; - public const TABLE_STREAM_DEST = 'social_3_stream_dest'; - public const TABLE_STREAM_TAGS = 'social_3_stream_tag'; - public const TABLE_STREAM_QUEUE = 'social_3_stream_queue'; - public const TABLE_STREAM_ACTIONS = 'social_3_stream_act'; + public const TABLE_ACTORS = 'social_actor'; + public const TABLE_STREAM = 'social_stream'; + public const TABLE_STREAM_DEST = 'social_stream_dest'; + public const TABLE_STREAM_TAGS = 'social_stream_tag'; + public const TABLE_STREAM_QUEUE = 'social_stream_queue'; + public const TABLE_STREAM_ACTIONS = 'social_stream_act'; - public const TABLE_HASHTAGS = 'social_3_hashtag'; - public const TABLE_FOLLOWS = 'social_3_follow'; - public const TABLE_ACTIONS = 'social_3_action'; + public const TABLE_HASHTAGS = 'social_hashtag'; + public const TABLE_FOLLOWS = 'social_follow'; + public const TABLE_ACTIONS = 'social_action'; - public const TABLE_CACHE_ACTORS = 'social_3_cache_actor'; - public const TABLE_CACHE_DOCUMENTS = 'social_3_cache_doc'; + public const TABLE_CACHE_ACTORS = 'social_cache_actor'; + public const TABLE_CACHE_DOCUMENTS = 'social_cache_doc'; - public const TABLE_CLIENT = 'social_3_client'; - public const TABLE_CLIENT_AUTH = 'social_3_client_auth'; - public const TABLE_CLIENT_TOKEN = 'social_3_client_token'; + public const TABLE_CLIENT = 'social_client'; + public const TABLE_CLIENT_AUTH = 'social_client_auth'; + public const TABLE_CLIENT_TOKEN = 'social_client_token'; private array $tables = [ @@ -105,7 +106,10 @@ class CoreRequestBuilder { protected ?string $defaultSelectAlias = null; public function __construct( - IDBConnection $connection, LoggerInterface $logger, IURLGenerator $urlGenerator, ConfigService $configService, + IDBConnection $connection, + LoggerInterface $logger, + IURLGenerator $urlGenerator, + ConfigService $configService, MiscService $miscService ) { $this->dbConnection = $connection; @@ -736,8 +740,7 @@ class CoreRequestBuilder { $pf = (($alias === '') ? $this->defaultSelectAlias : $alias); $qb->from(self::TABLE_CACHE_ACTORS, $pf); - $qb->selectAlias($pf . '.nid', 'cacheactor_nid') - ->selectAlias($pf . '.id', 'cacheactor_id') + $qb->selectAlias($pf . '.id', 'cacheactor_id') ->selectAlias($pf . '.type', 'cacheactor_type') ->selectAlias($pf . '.account', 'cacheactor_account') ->selectAlias($pf . '.following', 'cacheactor_following') @@ -777,8 +780,7 @@ class CoreRequestBuilder { $pf = ($alias === '') ? $this->defaultSelectAlias : $alias; - $qb->selectAlias('ca.nid', 'cacheactor_nid') - ->selectAlias('ca.id', 'cacheactor_id') + $qb->selectAlias('ca.id', 'cacheactor_id') ->selectAlias('ca.type', 'cacheactor_type') ->selectAlias('ca.account', 'cacheactor_account') ->selectAlias('ca.following', 'cacheactor_following') @@ -1129,7 +1131,7 @@ class CoreRequestBuilder { */ public function emptyAll() { /** @var ISchemaWrapper|SchemaWrapper $schema */ - $schema = new SchemaWrapper($this->dbConnection); + $schema = new SchemaWrapper(Server::get(OC\DB\Connection::class)); foreach ($this->tables as $table) { if ($schema->hasTable($table)) { $qb = $this->dbConnection->getQueryBuilder(); @@ -1145,7 +1147,7 @@ class CoreRequestBuilder { */ public function uninstallSocialTables() { /** @var ISchemaWrapper|SchemaWrapper $schema */ - $schema = new SchemaWrapper($this->dbConnection); + $schema = new SchemaWrapper(Server::get(OC\DB\Connection::class)); foreach ($this->tables as $table) { if ($schema->hasTable($table)) { $schema->dropTable($table); diff --git a/lib/Db/SocialCrossQueryBuilder.php b/lib/Db/SocialCrossQueryBuilder.php index 821309e0..3bc16b12 100644 --- a/lib/Db/SocialCrossQueryBuilder.php +++ b/lib/Db/SocialCrossQueryBuilder.php @@ -108,8 +108,7 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder { $this->from(CoreRequestBuilder::TABLE_CACHE_ACTORS, $pf); } - $this->selectAlias($pf . '.nid', 'cacheactor_nid') - ->selectAlias($pf . '.id', 'cacheactor_id') + $this->selectAlias($pf . '.id', 'cacheactor_id') ->selectAlias($pf . '.type', 'cacheactor_type') ->selectAlias($pf . '.account', 'cacheactor_account') ->selectAlias($pf . '.following', 'cacheactor_following') diff --git a/lib/Migration/CheckInstallation.php b/lib/Migration/CheckInstallation.php deleted file mode 100644 index 350337cf..00000000 --- a/lib/Migration/CheckInstallation.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright 2018, Maxence Lange - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - -namespace OCA\Social\Migration; - -use OCA\Social\Service\CheckService; -use OCP\Migration\IOutput; -use OCP\Migration\IRepairStep; - -/** - * Class CheckInstallation - * - * @package OCA\Social\Migration - */ -class CheckInstallation implements IRepairStep { - protected CheckService $checkService; - - - /** - * CheckInstallation constructor. - * - * @param CheckService $checkService - */ - public function __construct(CheckService $checkService) { - $this->checkService = $checkService; - } - - - /** - * Returns the step's name - * - * @return string - * @since 9.1.0 - */ - public function getName() { - return 'Check the installation of the Social app.'; - } - - - /** - * @param IOutput $output - */ - public function run(IOutput $output) { - $this->checkService->checkInstallationStatus(true); - } -} diff --git a/lib/Migration/Version0003Date20200823023900.php b/lib/Migration/Version0003Date20200823023900.php deleted file mode 100644 index 30b8a58e..00000000 --- a/lib/Migration/Version0003Date20200823023900.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @copyright 2018, Maxence Lange - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - -namespace OCA\Social\Migration; - -use Closure; -use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Schema\SchemaException; -use Exception; -use OCP\DB\ISchemaWrapper; -use OCP\IDBConnection; -use OCP\Migration\IOutput; -use OCP\Migration\SimpleMigrationStep; - -/** - * Class Version0003Date20200823023910 - * - * @package OCA\Social\Migration - */ -class Version0003Date20200823023900 extends SimpleMigrationStep { - private IDBConnection $connection; - - - /** - * @param IDBConnection $connection - */ - public function __construct(IDBConnection $connection) { - $this->connection = $connection; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * - * @return ISchemaWrapper - * @throws SchemaException - * @throws DBALException - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - if ($schema->hasTable('social_3_cache_actor')) { - $table = $schema->getTable('social_3_cache_actor'); - if ($table->hasPrimaryKey()) { - $kc = $table->getPrimaryKeyColumns(); - if (count($kc) === 1 && $kc[0] === 'id_prim') { - $table->dropPrimaryKey(); - } - } - } - - return $schema; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * - * @throws Exception - */ - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { - } -} diff --git a/lib/Migration/Version0003Date20200823023911.php b/lib/Migration/Version0003Date20200823023911.php deleted file mode 100644 index cf1f725d..00000000 --- a/lib/Migration/Version0003Date20200823023911.php +++ /dev/null @@ -1,451 +0,0 @@ - - * @copyright 2018, Maxence Lange - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - -namespace OCA\Social\Migration; - -use Closure; -use Doctrine\DBAL\Schema\SchemaException; -use Doctrine\DBAL\Types\Type; -use Exception; -use OCP\DB\ISchemaWrapper; -use OCP\IDBConnection; -use OCP\Migration\IOutput; -use OCP\Migration\SimpleMigrationStep; - -/** - * Class Version0003Date20200823023911 - * - * @package OCA\Social\Migration - */ -class Version0003Date20200823023911 extends SimpleMigrationStep { - private IDBConnection $connection; - - - /** - * @param IDBConnection $connection - */ - public function __construct(IDBConnection $connection) { - $this->connection = $connection; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * - * @return ISchemaWrapper - * @throws SchemaException - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options - ): ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - $this->fixStreamNid($schema); - $this->fixCacheActorNid($schema); - - $this->createClient($schema); - $this->createInstance($schema); - - $this->addChunkToTable($schema, 'social_3_stream', ''); - $this->addChunkToTable($schema, 'social_3_stream_act', '_act'); - $this->addChunkToTable($schema, 'social_3_stream_dest', '_dest'); - - return $schema; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * - * @throws Exception - */ - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { - $qb = $this->connection->getQueryBuilder(); - - $qb->select('*') - ->from('social_3_stream') - ->orderBy('creation', 'asc'); - - $result = $qb->execute(); - $nid = 0; - while ($row = $result->fetch()) { - $nid++; - if (is_int($row['nid']) and $row['nid'] > 0) { - continue; - } - $update = $this->connection->getQueryBuilder(); - $expr = $update->expr(); - - $update->update('social_3_stream'); - $update->set('nid', $update->createNamedParameter($nid)); - $update->where($expr->eq('id_prim', $update->createNamedParameter($row['id_prim']))); - $update->execute(); - } - } - - - /** - * @param ISchemaWrapper $schema - */ - private function fixStreamNid(ISchemaWrapper $schema) { - try { - $table = $schema->getTable('social_3_stream'); - } catch (SchemaException $e) { - return; - } - - if ($table->hasColumn('nid')) { - return; - } - - $table->addColumn( - 'nid', 'bigint', - [ - 'length' => 11, - 'unsigned' => true, - 'notnull' => false, - ] - ); - } - - - /** - * @param ISchemaWrapper $schema - */ - private function fixCacheActorNid(ISchemaWrapper $schema) { - try { - $table = $schema->getTable('social_3_cache_actor'); - } catch (SchemaException $e) { - return; - } - - if ($table->hasColumn('nid')) { - return; - } - - $table->addColumn( - 'nid', 'bigint', - [ - 'autoincrement' => true, - 'length' => 11, - 'unsigned' => true, - 'customSchemaOptions' => [ - 'unique' => true - ] - ] - ); - - $table->addUniqueIndex(['id_prim']); - } - - - /** - * @param ISchemaWrapper $schema - */ - private function createClient(ISchemaWrapper $schema) { - if ($schema->hasTable('social_3_client')) { - return; - } - - $table = $schema->createTable('social_3_client'); - $table->addColumn( - 'id', 'integer', - [ - 'autoincrement' => true, - 'notnull' => true, - 'length' => 7, - 'unsigned' => true, - ] - ); - $table->addColumn( - 'app_name', 'string', - [ - 'notnull' => false, - 'length' => 127, - 'default' => '' - ] - ); - $table->addColumn( - 'app_website', 'string', - [ - 'notnull' => false, - 'length' => 255, - 'default' => '' - ] - ); - $table->addColumn( - 'app_redirect_uris', 'text', - [ - 'notnull' => false, - 'default' => '' - ] - ); - $table->addColumn( - 'app_client_id', 'string', - [ - 'notnull' => false, - 'length' => 63, - 'default' => '' - ] - ); - $table->addColumn( - 'app_client_secret', 'string', - [ - 'notnull' => false, - 'length' => 63, - 'default' => '' - ] - ); - $table->addColumn( - 'app_scopes', 'text', - [ - 'notnull' => false - ] - ); - - $table->addColumn( - 'auth_scopes', 'text', - [ - 'notnull' => false - ] - ); - $table->addColumn( - 'auth_account', 'string', - [ - 'notnull' => false, - 'length' => 127, - 'default' => '' - ] - ); - $table->addColumn( - 'auth_user_id', 'string', - [ - 'notnull' => false, - 'length' => 127, - 'default' => '' - ] - ); - $table->addColumn( - 'auth_code', 'string', - [ - 'notnull' => false, - 'length' => 127, - 'default' => '' - ] - ); - $table->addColumn( - 'token', 'string', - [ - 'notnull' => false, - 'length' => 127, - 'default' => '' - ] - ); - $table->addColumn( - 'last_update', 'datetime', - [ - 'notnull' => false, - ] - ); - $table->addColumn( - 'creation', 'datetime', - [ - 'notnull' => false, - ] - ); - - $table->setPrimaryKey(['id']); - $table->addUniqueIndex(['auth_code', 'token', 'app_client_id', 'app_client_secret']); - } - - - /** - * @param ISchemaWrapper $schema - */ - private function createInstance(ISchemaWrapper $schema) { - if ($schema->hasTable('social_3_instance')) { - return; - } - - $table = $schema->createTable('social_3_instance'); - $table->addColumn( - 'local', 'smallint', - [ - 'notnull' => false, - 'length' => 1, - 'default' => 0, - 'unsigned' => true - ] - ); - $table->addColumn( - 'uri', 'string', - [ - 'notnull' => false, - 'length' => 255, - ] - ); - $table->addColumn( - 'title', 'string', - [ - 'notnull' => false, - 'length' => 255, - 'default' => '' - ] - ); - $table->addColumn( - 'version', 'string', - [ - 'notnull' => false, - 'length' => 31, - 'default' => '' - ] - ); - $table->addColumn( - 'short_description', 'text', - [ - 'notnull' => false, - 'default' => '' - ] - ); - $table->addColumn( - 'description', 'text', - [ - 'notnull' => false, - 'default' => '' - ] - ); - $table->addColumn( - 'email', 'string', - [ - 'notnull' => false, - 'length' => 255, - 'default' => '' - ] - ); - $table->addColumn( - 'urls', 'text', - [ - 'notnull' => false, - 'default' => '[]' - ] - ); - $table->addColumn( - 'stats', 'text', - [ - 'notnull' => false, - 'default' => '[]' - ] - ); - $table->addColumn( - 'usage', 'text', - [ - 'notnull' => false, - 'default' => '[]' - ] - ); - $table->addColumn( - 'image', 'string', - [ - 'notnull' => false, - 'length' => 255, - 'default' => '' - ] - ); - $table->addColumn( - 'languages', 'text', - [ - 'notnull' => false, - 'default' => '[]' - ] - ); - $table->addColumn( - 'contact', 'string', - [ - 'notnull' => false, - 'length' => 127, - 'default' => '' - ] - ); - $table->addColumn( - 'account_prim', 'string', - [ - 'notnull' => false, - 'length' => 128, - 'default' => '' - ] - ); - $table->addColumn( - 'creation', 'datetime', - [ - 'notnull' => false, - ] - ); - - $table->setPrimaryKey(['uri']); - $table->addIndex(['local', 'uri', 'account_prim']); - } - - - /** - * @param ISchemaWrapper $schema - * @param string $tableName - * @param string $indexName - * - * @throws SchemaException - */ - private function addChunkToTable(ISchemaWrapper $schema, string $tableName, string $indexName) { - if (!$schema->hasTable($tableName)) { - return; - } - - $table = $schema->getTable($tableName); - if ($table->hasColumn('chunk')) { - return; - } - - $table->addColumn( - 'chunk', Type::SMALLINT, - [ - 'default' => 1, - 'length' => 1, - 'unsigned' => true - ] - ); - - if (!$table->hasIndex('chunk' . $indexName)) { - $table->addIndex(['chunk'], 'chunk' . $indexName); - } - } -} diff --git a/lib/Migration/Version0003Date20200921103342.php b/lib/Migration/Version0003Date20200921103342.php deleted file mode 100644 index ba2f2406..00000000 --- a/lib/Migration/Version0003Date20200921103342.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright 2018, Maxence Lange - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - -namespace OCA\Social\Migration; - -use Closure; -use Doctrine\DBAL\Schema\SchemaException; -use OCP\DB\ISchemaWrapper; -use OCP\IDBConnection; -use OCP\Migration\IOutput; -use OCP\Migration\SimpleMigrationStep; - -/** - * Class Version0003Date20200921103342 - * - * @package OCA\Social\Migration - */ -class Version0003Date20200921103342 extends SimpleMigrationStep { - private IDBConnection $connection; - - - /** - * @param IDBConnection $connection - */ - public function __construct(IDBConnection $connection) { - $this->connection = $connection; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * - * @return ISchemaWrapper - * @throws SchemaException - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options - ): ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - $table = $schema->getTable('social_3_stream'); - - $column = $table->getColumn('nid'); - if (!$column->getAutoincrement()) { - $table->changeColumn( - 'nid', [ - 'autoincrement' => true, 'customSchemaOptions' => [ - 'unique' => true - ] - ] - ); - } - - return $schema; - } -} diff --git a/lib/Migration/Version0003Date20200611000001.php b/lib/Migration/Version1000Date20221118000001.php similarity index 74% rename from lib/Migration/Version0003Date20200611000001.php rename to lib/Migration/Version1000Date20221118000001.php index 29edfa9a..1f44e082 100644 --- a/lib/Migration/Version0003Date20200611000001.php +++ b/lib/Migration/Version1000Date20221118000001.php @@ -32,10 +32,10 @@ declare(strict_types=1); namespace OCA\Social\Migration; use Closure; -use OCP\DB\Types; +use Doctrine\DBAL\Schema\SchemaException; use Exception; use OCP\DB\ISchemaWrapper; -use OCP\IDBConnection; +use OCP\DB\Types; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; @@ -44,16 +44,7 @@ use OCP\Migration\SimpleMigrationStep; * * @package OCA\Social\Migration */ -class Version0003Date20200611000001 extends SimpleMigrationStep { - private IDBConnection $connection; - - - /** - * @param IDBConnection $connection - */ - public function __construct(IDBConnection $connection) { - $this->connection = $connection; - } +class Version1000Date20221118000001 extends SimpleMigrationStep { /** @@ -62,9 +53,9 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { * @param array $options * * @return ISchemaWrapper + * @throws SchemaException */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options - ): ISchemaWrapper { + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); @@ -101,29 +92,30 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws SchemaException */ private function createActions(ISchemaWrapper $schema) { - if ($schema->hasTable('social_3_action')) { + if ($schema->hasTable('social_action')) { return; } - $table = $schema->createTable('social_3_action'); + $table = $schema->createTable('social_action'); $table->addColumn( - 'id', 'string', + 'id', Types::TEXT, [ - 'notnull' => false, - 'length' => 1000 + 'notnull' => false ] ); $table->addColumn( - 'id_prim', 'string', + 'id_prim', Types::STRING, [ 'notnull' => false, 'length' => 128 ] ); $table->addColumn( - 'type', 'string', + 'type', Types::STRING, [ 'notnull' => false, 'length' => 31, @@ -131,15 +123,14 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'actor_id', 'string', + 'actor_id', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'actor_id_prim', 'string', + 'actor_id_prim', Types::STRING, [ 'notnull' => false, 'length' => 128, @@ -147,15 +138,14 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'object_id', 'string', + 'object_id', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'object_id_prim', 'string', + 'object_id_prim', Types::STRING, [ 'notnull' => false, 'length' => 128, @@ -163,7 +153,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'creation', 'datetime', + 'creation', Types::DATETIME, [ 'notnull' => false, ] @@ -176,44 +166,45 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws SchemaException */ private function createActors(ISchemaWrapper $schema) { - if ($schema->hasTable('social_3_actor')) { + if ($schema->hasTable('social_actor')) { return; } - $table = $schema->createTable('social_3_actor'); + $table = $schema->createTable('social_actor'); $table->addColumn( - 'id', 'string', + 'id', Types::TEXT, [ - 'notnull' => false, - 'length' => 1000 + 'notnull' => false ] ); $table->addColumn( - 'id_prim', 'string', + 'id_prim', Types::STRING, [ 'notnull' => false, 'length' => 128 ] ); $table->addColumn( - 'user_id', 'string', + 'user_id', Types::STRING, [ 'notnull' => false, 'length' => 63, ] ); $table->addColumn( - 'preferred_username', 'string', + 'preferred_username', Types::STRING, [ 'notnull' => false, 'length' => 127, ] ); $table->addColumn( - 'name', 'string', + 'name', Types::STRING, [ 'notnull' => false, 'length' => 127, @@ -240,14 +231,14 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'avatar_version', 'integer', + 'avatar_version', Types::INTEGER, [ 'notnull' => false, 'length' => 2, ] ); $table->addColumn( - 'creation', 'datetime', + 'creation', Types::DATETIME, [ 'notnull' => false, ] @@ -259,29 +250,30 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws SchemaException */ private function createFollows(ISchemaWrapper $schema) { - if ($schema->hasTable('social_3_follow')) { + if ($schema->hasTable('social_follow')) { return; } - $table = $schema->createTable('social_3_follow'); + $table = $schema->createTable('social_follow'); $table->addColumn( - 'id', 'string', + 'id', Types::TEXT, [ - 'notnull' => false, - 'length' => 1000 + 'notnull' => false ] ); $table->addColumn( - 'id_prim', 'string', + 'id_prim', Types::STRING, [ 'notnull' => false, 'length' => 128 ] ); $table->addColumn( - 'type', 'string', + 'type', Types::STRING, [ 'notnull' => false, 'length' => 31, @@ -289,15 +281,14 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'actor_id', 'string', + 'actor_id', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'actor_id_prim', 'string', + 'actor_id_prim', Types::STRING, [ 'notnull' => false, 'length' => 128, @@ -305,15 +296,14 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'object_id', 'string', + 'object_id', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'object_id_prim', 'string', + 'object_id_prim', Types::STRING, [ 'notnull' => false, 'length' => 128, @@ -321,15 +311,14 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'follow_id', 'string', + 'follow_id', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'follow_id_prim', 'string', + 'follow_id_prim', Types::STRING, [ 'notnull' => false, 'length' => 128, @@ -337,14 +326,14 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'accepted', 'boolean', + 'accepted', Types::BOOLEAN, [ 'notnull' => true, 'default' => false ] ); $table->addColumn( - 'creation', 'datetime', + 'creation', Types::DATETIME, [ 'notnull' => false, ] @@ -358,25 +347,26 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws SchemaException */ private function createHashtags(ISchemaWrapper $schema) { - if ($schema->hasTable('social_3_hashtag')) { + if ($schema->hasTable('social_hashtag')) { return; } - $table = $schema->createTable('social_3_hashtag'); + $table = $schema->createTable('social_hashtag'); $table->addColumn( - 'hashtag', 'string', + 'hashtag', Types::STRING, [ 'notnull' => false, 'length' => 63 ] ); $table->addColumn( - 'trend', 'string', + 'trend', Types::TEXT, [ 'notnull' => false, - 'length' => 500, 'default' => '' ] ); @@ -387,15 +377,17 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws SchemaException */ private function createInstance(ISchemaWrapper $schema) { - if ($schema->hasTable('social_3_instance')) { + if ($schema->hasTable('social_instance')) { return; } - $table = $schema->createTable('social_3_instance'); + $table = $schema->createTable('social_instance'); $table->addColumn( - 'local', 'smallint', + 'local', Types::SMALLINT, [ 'notnull' => false, 'length' => 1, @@ -404,14 +396,14 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'uri', 'string', + 'uri', Types::STRING, [ 'notnull' => false, 'length' => 255, ] ); $table->addColumn( - 'title', 'string', + 'title', Types::STRING, [ 'notnull' => false, 'length' => 255, @@ -419,7 +411,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'version', 'string', + 'version', Types::STRING, [ 'notnull' => false, 'length' => 31, @@ -427,21 +419,21 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'short_description', 'text', + 'short_description', Types::TEXT, [ 'notnull' => false, 'default' => '' ] ); $table->addColumn( - 'description', 'text', + 'description', Types::TEXT, [ 'notnull' => false, 'default' => '' ] ); $table->addColumn( - 'email', 'string', + 'email', Types::STRING, [ 'notnull' => false, 'length' => 255, @@ -449,28 +441,28 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'urls', 'text', + 'urls', Types::TEXT, [ 'notnull' => false, 'default' => '[]' ] ); $table->addColumn( - 'stats', 'text', + 'stats', Types::TEXT, [ 'notnull' => false, 'default' => '[]' ] ); $table->addColumn( - 'usage', 'text', + 'usage', Types::TEXT, [ 'notnull' => false, 'default' => '[]' ] ); $table->addColumn( - 'image', 'string', + 'image', Types::STRING, [ 'notnull' => false, 'length' => 255, @@ -478,14 +470,14 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'languages', 'text', + 'languages', Types::TEXT, [ 'notnull' => false, 'default' => '[]' ] ); $table->addColumn( - 'contact', 'string', + 'contact', Types::STRING, [ 'notnull' => false, 'length' => 127, @@ -493,7 +485,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'account_prim', 'string', + 'account_prim', Types::STRING, [ 'notnull' => false, 'length' => 128, @@ -501,7 +493,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'creation', 'datetime', + 'creation', Types::DATETIME, [ 'notnull' => false, ] @@ -514,45 +506,42 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws SchemaException */ private function createStreams(ISchemaWrapper $schema) { - if ($schema->hasTable('social_3_stream')) { + if ($schema->hasTable('social_stream')) { return; } - $table = $schema->createTable('social_3_stream'); + $table = $schema->createTable('social_stream'); $table->addColumn( - 'nid', 'bigint', + 'nid', Types::BIGINT, [ - 'length' => 11, - 'unsigned' => true, - ] - ); - $table->addColumn( - 'id', 'string', - [ - 'notnull' => false, - 'length' => 1000 - ] - ); - $table->addColumn( - 'chunk', Types::SMALLINT, - [ - 'default' => 1, - 'length' => 1, + 'length' => 20, 'unsigned' => true +// 'autoincrement' => true, +// 'customSchemaOptions' => [ +// 'unique' => true +// ] ] ); $table->addColumn( - 'id_prim', 'string', + 'id', Types::TEXT, + [ + 'notnull' => false + ] + ); + $table->addColumn( + 'id_prim', Types::STRING, [ 'notnull' => false, 'length' => 128 ] ); $table->addColumn( - 'type', 'string', + 'type', Types::STRING, [ 'notnull' => false, 'length' => 31, @@ -568,10 +557,9 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'to', 'string', + 'to', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); @@ -611,7 +599,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'published', 'string', + 'published', Types::STRING, [ 'notnull' => false, 'length' => 31, @@ -619,21 +607,20 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'published_time', 'datetime', + 'published_time', Types::DATETIME, [ 'notnull' => false, ] ); $table->addColumn( - 'attributed_to', 'string', + 'attributed_to', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'attributed_to_prim', 'string', + 'attributed_to_prim', Types::STRING, [ 'notnull' => false, 'length' => 128, @@ -641,15 +628,14 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'in_reply_to', 'string', + 'in_reply_to', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'in_reply_to_prim', 'string', + 'in_reply_to_prim', Types::STRING, [ 'notnull' => false, 'length' => 128, @@ -657,23 +643,21 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'activity_id', 'string', + 'activity_id', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'object_id', 'string', + 'object_id', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'object_id_prim', 'string', + 'object_id_prim', Types::STRING, [ 'notnull' => false, 'length' => 128, @@ -723,29 +707,29 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'creation', 'datetime', + 'creation', Types::DATETIME, [ 'notnull' => false, ] ); $table->addColumn( - 'local', 'boolean', + 'local', Types::BOOLEAN, [ 'notnull' => false, 'default' => false ] ); $table->addColumn( - 'filter_duplicate', 'boolean', + 'filter_duplicate', Types::BOOLEAN, [ 'notnull' => false, 'default' => false ] ); + $table->setPrimaryKey(['nid']); $table->addUniqueIndex(['id_prim']); $table->addUniqueIndex(['nid']); - $table->addIndex(['chunk'], 'chunk'); $table->addUniqueIndex( [ 'id_prim', @@ -764,37 +748,38 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws SchemaException */ private function createCacheActors(ISchemaWrapper $schema) { - if ($schema->hasTable('social_3_cache_actor')) { + if ($schema->hasTable('social_cache_actor')) { return; } - $table = $schema->createTable('social_3_cache_actor'); + $table = $schema->createTable('social_cache_actor'); +// $table->addColumn( +// 'nid', Types::BIGINT, +// [ +// 'autoincrement' => true, +// 'length' => 11, +// 'unsigned' => true, +// ] +// ); $table->addColumn( - 'nid', 'bigint', + 'id', Types::TEXT, [ - 'autoincrement' => true, - 'length' => 11, - 'unsigned' => true, + 'notnull' => false ] ); $table->addColumn( - 'id', 'string', - [ - 'notnull' => false, - 'length' => 1000 - ] - ); - $table->addColumn( - 'id_prim', 'string', + 'id_prim', Types::STRING, [ 'notnull' => false, 'length' => 128 ] ); $table->addColumn( - 'type', 'string', + 'type', Types::STRING, [ 'notnull' => false, 'length' => 31, @@ -802,7 +787,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'account', 'string', + 'account', Types::STRING, [ 'notnull' => false, 'length' => 127, @@ -810,70 +795,63 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'local', 'boolean', + 'local', Types::BOOLEAN, [ 'notnull' => true, 'default' => false ] ); $table->addColumn( - 'following', 'string', + 'following', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'followers', 'string', + 'followers', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'inbox', 'string', + 'inbox', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'shared_inbox', 'string', + 'shared_inbox', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'outbox', 'string', + 'outbox', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'featured', 'string', + 'featured', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'url', 'string', + 'url', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'preferred_username', 'string', + 'preferred_username', Types::STRING, [ 'notnull' => false, 'length' => 127, @@ -881,7 +859,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'name', 'string', + 'name', Types::STRING, [ 'notnull' => false, 'length' => 127, @@ -889,10 +867,9 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'icon_id', 'string', + 'icon_id', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); @@ -924,42 +901,44 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'creation', 'datetime', + 'creation', Types::DATETIME, [ 'notnull' => false, ] ); + $table->setPrimaryKey(['id_prim']); $table->addUniqueIndex(['id_prim']); - $table->addUniqueIndex(['nid']); +// $table->addUniqueIndex(['nid']); } /** * @param ISchemaWrapper $schema + * + * @throws SchemaException */ private function createCacheDocuments(ISchemaWrapper $schema) { - if ($schema->hasTable('social_3_cache_doc')) { + if ($schema->hasTable('social_cache_doc')) { return; } - $table = $schema->createTable('social_3_cache_doc'); + $table = $schema->createTable('social_cache_doc'); $table->addColumn( - 'id', 'string', + 'id', Types::TEXT, [ - 'notnull' => false, - 'length' => 1000 + 'notnull' => false ] ); $table->addColumn( - 'id_prim', 'string', + 'id_prim', Types::STRING, [ 'notnull' => false, 'length' => 128 ] ); $table->addColumn( - 'type', 'string', + 'type', Types::STRING, [ 'notnull' => false, 'length' => 31, @@ -967,15 +946,14 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'parent_id', 'string', + 'parent_id', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '', ] ); $table->addColumn( - 'media_type', 'string', + 'media_type', Types::STRING, [ 'notnull' => false, 'length' => 63, @@ -983,7 +961,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'mime_type', 'string', + 'mime_type', Types::STRING, [ 'notnull' => false, 'length' => 63, @@ -991,18 +969,16 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'url', 'string', + 'url', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'local_copy', 'string', + 'local_copy', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); @@ -1014,27 +990,27 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'public', 'boolean', + 'public', Types::BOOLEAN, [ 'notnull' => false, 'default' => false ] ); $table->addColumn( - 'error', 'smallint', + 'error', Types::SMALLINT, [ 'notnull' => false, 'length' => 1, ] ); $table->addColumn( - 'creation', 'datetime', + 'creation', Types::DATETIME, [ 'notnull' => false, ] ); $table->addColumn( - 'caching', 'datetime', + 'caching', Types::DATETIME, [ 'notnull' => false, ] @@ -1046,15 +1022,17 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws SchemaException */ private function createClient(ISchemaWrapper $schema) { - if ($schema->hasTable('social_3_client')) { + if ($schema->hasTable('social_client')) { return; } - $table = $schema->createTable('social_3_client'); + $table = $schema->createTable('social_client'); $table->addColumn( - 'id', 'integer', + 'id', Types::INTEGER, [ 'autoincrement' => true, 'notnull' => true, @@ -1063,7 +1041,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'app_name', 'string', + 'app_name', Types::STRING, [ 'notnull' => false, 'length' => 127, @@ -1071,7 +1049,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'app_website', 'string', + 'app_website', Types::STRING, [ 'notnull' => false, 'length' => 255, @@ -1079,14 +1057,14 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'app_redirect_uris', 'text', + 'app_redirect_uris', Types::TEXT, [ 'notnull' => false, 'default' => '' ] ); $table->addColumn( - 'app_client_id', 'string', + 'app_client_id', Types::STRING, [ 'notnull' => false, 'length' => 63, @@ -1094,7 +1072,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'app_client_secret', 'string', + 'app_client_secret', Types::STRING, [ 'notnull' => false, 'length' => 63, @@ -1102,20 +1080,20 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'app_scopes', 'text', + 'app_scopes', Types::TEXT, [ 'notnull' => false ] ); $table->addColumn( - 'auth_scopes', 'text', + 'auth_scopes', Types::TEXT, [ 'notnull' => false ] ); $table->addColumn( - 'auth_account', 'string', + 'auth_account', Types::STRING, [ 'notnull' => false, 'length' => 127, @@ -1123,7 +1101,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'auth_user_id', 'string', + 'auth_user_id', Types::STRING, [ 'notnull' => false, 'length' => 127, @@ -1131,7 +1109,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'auth_code', 'string', + 'auth_code', Types::STRING, [ 'notnull' => false, 'length' => 127, @@ -1139,7 +1117,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'token', 'string', + 'token', Types::STRING, [ 'notnull' => false, 'length' => 127, @@ -1147,13 +1125,13 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'last_update', 'datetime', + 'last_update', Types::DATETIME, [ 'notnull' => false, ] ); $table->addColumn( - 'creation', 'datetime', + 'creation', Types::DATETIME, [ 'notnull' => false, ] @@ -1166,15 +1144,17 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws SchemaException */ private function createRequestQueue(ISchemaWrapper $schema) { - if ($schema->hasTable('social_3_req_queue')) { + if ($schema->hasTable('social_req_queue')) { return; } - $table = $schema->createTable('social_3_req_queue'); + $table = $schema->createTable('social_req_queue'); $table->addColumn( - 'id', 'bigint', + 'id', Types::BIGINT, [ 'autoincrement' => true, 'notnull' => true, @@ -1183,17 +1163,16 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'token', 'string', + 'token', Types::STRING, [ 'notnull' => false, 'length' => 63, ] ); $table->addColumn( - 'author', 'string', + 'author', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); @@ -1208,12 +1187,11 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { 'instance', Types::TEXT, [ 'notnull' => false, - 'length' => 500, 'default' => '' ] ); $table->addColumn( - 'priority', 'smallint', + 'priority', Types::SMALLINT, [ 'notnull' => false, 'length' => 1, @@ -1221,7 +1199,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'status', 'smallint', + 'status', Types::SMALLINT, [ 'notnull' => false, 'length' => 1, @@ -1229,7 +1207,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'tries', 'smallint', + 'tries', Types::SMALLINT, [ 'notnull' => false, 'length' => 2, @@ -1237,7 +1215,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'last', 'datetime', + 'last', Types::DATETIME, [ 'notnull' => false, ] @@ -1249,13 +1227,15 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws SchemaException */ private function createStreamActions(ISchemaWrapper $schema) { - if ($schema->hasTable('social_3_stream_act')) { + if ($schema->hasTable('social_stream_act')) { return; } - $table = $schema->createTable('social_3_stream_act'); + $table = $schema->createTable('social_stream_act'); $table->addColumn( 'id', Types::INTEGER, @@ -1267,23 +1247,14 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'chunk', Types::SMALLINT, - [ - 'default' => 1, - 'length' => 1, - 'unsigned' => true - ] - ); - $table->addColumn( - 'actor_id', 'string', + 'actor_id', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'actor_id_prim', 'string', + 'actor_id_prim', Types::STRING, [ 'notnull' => false, 'length' => 128, @@ -1291,24 +1262,23 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'stream_id', 'string', + 'stream_id', Types::TEXT, [ 'notnull' => false, - 'length' => 1000, 'default' => '' ] ); $table->addColumn( - 'stream_id_prim', 'string', + 'stream_id_prim', Types::STRING, [ 'notnull' => false, 'length' => 128, 'default' => '' ] ); - $table->addColumn('liked', 'boolean', ['default' => false]); - $table->addColumn('boosted', 'boolean', ['default' => false]); - $table->addColumn('replied', 'boolean', ['default' => false]); + $table->addColumn('liked', Types::BOOLEAN, ['default' => false]); + $table->addColumn('boosted', Types::BOOLEAN, ['default' => false]); + $table->addColumn('replied', Types::BOOLEAN, ['default' => false]); $table->addColumn( 'values', Types::TEXT, [ @@ -1318,30 +1288,23 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ); $table->setPrimaryKey(['id']); - $table->addIndex(['chunk'], 'chunk_act'); $table->addUniqueIndex(['stream_id_prim', 'actor_id_prim'], 'sa'); } /** * @param ISchemaWrapper $schema + * + * @throws SchemaException */ private function createStreamDest(ISchemaWrapper $schema) { - if ($schema->hasTable('social_3_stream_dest')) { + if ($schema->hasTable('social_stream_dest')) { return; } - $table = $schema->createTable('social_3_stream_dest'); + $table = $schema->createTable('social_stream_dest'); $table->addColumn( - 'chunk', Types::SMALLINT, - [ - 'default' => 1, - 'length' => 1, - 'unsigned' => true - ] - ); - $table->addColumn( - 'stream_id', 'string', + 'stream_id', Types::STRING, [ 'notnull' => false, 'length' => 128, @@ -1349,7 +1312,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'actor_id', 'string', + 'actor_id', Types::STRING, [ 'notnull' => false, 'length' => 128, @@ -1357,7 +1320,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'type', 'string', + 'type', Types::STRING, [ 'notnull' => false, 'length' => 15, @@ -1365,7 +1328,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'subtype', 'string', + 'subtype', Types::STRING, [ 'notnull' => false, 'length' => 7, @@ -1373,7 +1336,6 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); - $table->addIndex(['chunk'], 'chunk_dest'); $table->addUniqueIndex(['stream_id', 'actor_id', 'type'], 'sat'); $table->addIndex(['type', 'subtype'], 'ts'); } @@ -1381,15 +1343,17 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { /** * @param ISchemaWrapper $schema + * + * @throws SchemaException */ private function createStreamQueue(ISchemaWrapper $schema) { - if ($schema->hasTable('social_3_stream_queue')) { + if ($schema->hasTable('social_stream_queue')) { return; } - $table = $schema->createTable('social_3_stream_queue'); + $table = $schema->createTable('social_stream_queue'); $table->addColumn( - 'id', 'bigint', + 'id', Types::BIGINT, [ 'autoincrement' => true, 'notnull' => true, @@ -1398,14 +1362,14 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'token', 'string', + 'token', Types::STRING, [ 'notnull' => false, 'length' => 63 ] ); $table->addColumn( - 'stream_id', 'string', + 'stream_id', Types::STRING, [ 'notnull' => false, 'length' => 255, @@ -1413,7 +1377,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'type', 'string', + 'type', Types::STRING, [ 'notnull' => false, 'length' => 31, @@ -1421,7 +1385,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'status', 'smallint', + 'status', Types::SMALLINT, [ 'notnull' => false, 'length' => 1, @@ -1429,7 +1393,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'tries', 'smallint', + 'tries', Types::SMALLINT, [ 'notnull' => false, 'length' => 2, @@ -1437,7 +1401,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'last', 'datetime', + 'last', Types::DATETIME, [ 'notnull' => false, ] @@ -1450,14 +1414,14 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { * @param ISchemaWrapper $schema */ private function createStreamTags(ISchemaWrapper $schema) { - if ($schema->hasTable('social_3_stream_tag')) { + if ($schema->hasTable('social_stream_tag')) { return; } - $table = $schema->createTable('social_3_stream_tag'); + $table = $schema->createTable('social_stream_tag'); $table->addColumn( - 'stream_id', 'string', + 'stream_id', Types::STRING, [ 'notnull' => false, 'length' => 128, @@ -1465,7 +1429,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ] ); $table->addColumn( - 'hashtag', 'string', + 'hashtag', Types::STRING, [ 'notnull' => false, 'length' => 127, diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php index 6f6f41ff..8ab275bd 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -55,7 +55,6 @@ class ConfigService { public const CLOUD_URL = 'cloud_url'; public const SOCIAL_URL = 'social_url'; public const SOCIAL_ADDRESS = 'social_address'; - public const DATABASE_CHUNK_SIZE = 'db_chunk_size'; public const SOCIAL_SERVICE = 'service'; public const SOCIAL_MAX_SIZE = 'max_size'; @@ -78,8 +77,7 @@ class ConfigService { self::SOCIAL_MAX_SIZE => 10, self::SOCIAL_ACCESS_TYPE => 'all_but', self::SOCIAL_ACCESS_LIST => '[]', - self::SOCIAL_SELF_SIGNED => '0', - self::DATABASE_CHUNK_SIZE => 10000 + self::SOCIAL_SELF_SIGNED => '0' ]; public array $accessTypeList = [ From 1adf04fcc127e7f9b1bbe83ef0055de605d645aa Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Mon, 21 Nov 2022 10:22:42 +0100 Subject: [PATCH 3/4] Fix cs Signed-off-by: Carl Schwan --- lib/Command/Fediverse.php | 4 +- lib/Command/MigrateAlpha3.php | 4 +- lib/Command/NoteCreate.php | 12 +++--- lib/Command/QueueStatus.php | 2 +- lib/Db/ActorsRequest.php | 6 +-- lib/Db/ActorsRequestBuilder.php | 2 +- lib/Db/CacheActorsRequest.php | 4 +- lib/Db/ClientRequest.php | 2 +- lib/Db/CoreRequestBuilder.php | 4 +- lib/Db/RequestQueueRequest.php | 10 ++--- lib/Db/SocialCrossQueryBuilder.php | 4 +- lib/Db/StreamActionsRequest.php | 6 +-- lib/Db/StreamQueueRequest.php | 4 +- lib/Db/StreamRequest.php | 38 +++++++++---------- lib/Db/StreamRequestBuilder.php | 8 ++-- .../Version1000Date20221118000001.php | 8 ++-- lib/Tools/Traits/TNCLogger.php | 24 ++++++------ 17 files changed, 71 insertions(+), 71 deletions(-) diff --git a/lib/Command/Fediverse.php b/lib/Command/Fediverse.php index f4c11956..be6770b4 100644 --- a/lib/Command/Fediverse.php +++ b/lib/Command/Fediverse.php @@ -58,8 +58,8 @@ class Fediverse extends Base { parent::configure(); $this->setName('social:fediverse') ->addOption( - 'type', 't', InputArgument::OPTIONAL, - 'Change the type of access management', '' + 'type', 't', InputArgument::OPTIONAL, + 'Change the type of access management', '' ) ->addArgument('action', InputArgument::OPTIONAL, 'add/remove/test address', '') ->addArgument('address', InputArgument::OPTIONAL, 'address/host', '') diff --git a/lib/Command/MigrateAlpha3.php b/lib/Command/MigrateAlpha3.php index e59e9a99..95e74a6b 100644 --- a/lib/Command/MigrateAlpha3.php +++ b/lib/Command/MigrateAlpha3.php @@ -119,10 +119,10 @@ class MigrateAlpha3 extends Base { $this->setName('social:migrate:alpha3') ->setDescription('Trying to migrate old data to Alpha3') ->addOption( - 'remove-migrated-tables', '', InputOption::VALUE_NONE, 'Remove old table once copy is done' + 'remove-migrated-tables', '', InputOption::VALUE_NONE, 'Remove old table once copy is done' ) ->addOption( - 'force-remove-old-tables', '', InputOption::VALUE_NONE, 'Force remove old tables' + 'force-remove-old-tables', '', InputOption::VALUE_NONE, 'Force remove old tables' ); } diff --git a/lib/Command/NoteCreate.php b/lib/Command/NoteCreate.php index b0e990b9..34810e0e 100644 --- a/lib/Command/NoteCreate.php +++ b/lib/Command/NoteCreate.php @@ -96,18 +96,18 @@ class NoteCreate extends Base { parent::configure(); $this->setName('social:note:create') ->addOption( - 'replyTo', 'r', InputOption::VALUE_OPTIONAL, 'in reply to an existing thread' + 'replyTo', 'r', InputOption::VALUE_OPTIONAL, 'in reply to an existing thread' ) ->addOption( - 'to', 't', InputOption::VALUE_OPTIONAL, 'mentioning people' + 'to', 't', InputOption::VALUE_OPTIONAL, 'mentioning people' ) ->addOption( - 'type', 'y', InputOption::VALUE_OPTIONAL, - 'type: public (default), followers, unlisted, direct' + 'type', 'y', InputOption::VALUE_OPTIONAL, + 'type: public (default), followers, unlisted, direct' ) ->addOption( - 'hashtag', 'g', InputOption::VALUE_OPTIONAL, - 'hashtag, without the leading #' + 'hashtag', 'g', InputOption::VALUE_OPTIONAL, + 'hashtag, without the leading #' ) ->addArgument('user_id', InputArgument::REQUIRED, 'userId of the author') ->addArgument('content', InputArgument::REQUIRED, 'content of the post') diff --git a/lib/Command/QueueStatus.php b/lib/Command/QueueStatus.php index 67e256be..094ab68a 100644 --- a/lib/Command/QueueStatus.php +++ b/lib/Command/QueueStatus.php @@ -73,7 +73,7 @@ class QueueStatus extends Base { parent::configure(); $this->setName('social:queue:status') ->addOption( - 'token', 't', InputOption::VALUE_OPTIONAL, 'token of a request' + 'token', 't', InputOption::VALUE_OPTIONAL, 'token of a request' ) ->setDescription('Return status on the request queue'); } diff --git a/lib/Db/ActorsRequest.php b/lib/Db/ActorsRequest.php index f0b6178c..51ff87ad 100644 --- a/lib/Db/ActorsRequest.php +++ b/lib/Db/ActorsRequest.php @@ -53,13 +53,13 @@ class ActorsRequest extends ActorsRequestBuilder { ->setValue('summary', $qb->createNamedParameter($actor->getSummary())) ->setValue('avatar_version', $qb->createNamedParameter($actor->getAvatarVersion())) ->setValue( - 'preferred_username', $qb->createNamedParameter($actor->getPreferredUsername()) + 'preferred_username', $qb->createNamedParameter($actor->getPreferredUsername()) ) ->setValue('public_key', $qb->createNamedParameter($actor->getPublicKey())) ->setValue('private_key', $qb->createNamedParameter($actor->getPrivateKey())) ->setValue( - 'creation', - $qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE) + 'creation', + $qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE) ); $qb->executeStatement(); diff --git a/lib/Db/ActorsRequestBuilder.php b/lib/Db/ActorsRequestBuilder.php index ee6ad7b0..f8aa7e4b 100644 --- a/lib/Db/ActorsRequestBuilder.php +++ b/lib/Db/ActorsRequestBuilder.php @@ -121,7 +121,7 @@ class ActorsRequestBuilder extends CoreRequestBuilder { ->setLocal(true) ->setAvatarVersion($this->getInt('avatar_version', $data, -1)) ->setAccount( - $actor->getPreferredUsername() . '@' . $this->configService->getSocialAddress() + $actor->getPreferredUsername() . '@' . $this->configService->getSocialAddress() ); $actor->setUrlSocial($root) ->setUrl($actor->getId()); diff --git a/lib/Db/CacheActorsRequest.php b/lib/Db/CacheActorsRequest.php index 0027545d..4903a5f4 100644 --- a/lib/Db/CacheActorsRequest.php +++ b/lib/Db/CacheActorsRequest.php @@ -59,7 +59,7 @@ class CacheActorsRequest extends CacheActorsRequestBuilder { ->setValue('featured', $qb->createNamedParameter($actor->getFeatured())) ->setValue('url', $qb->createNamedParameter($actor->getUrl())) ->setValue( - 'preferred_username', $qb->createNamedParameter($actor->getPreferredUsername()) + 'preferred_username', $qb->createNamedParameter($actor->getPreferredUsername()) ) ->setValue('name', $qb->createNamedParameter($actor->getName())) ->setValue('summary', $qb->createNamedParameter($actor->getSummary())) @@ -112,7 +112,7 @@ class CacheActorsRequest extends CacheActorsRequestBuilder { ->set('featured', $qb->createNamedParameter($actor->getFeatured())) ->set('url', $qb->createNamedParameter($actor->getUrl())) ->set( - 'preferred_username', $qb->createNamedParameter($actor->getPreferredUsername()) + 'preferred_username', $qb->createNamedParameter($actor->getPreferredUsername()) ) ->set('name', $qb->createNamedParameter($actor->getName())) ->set('summary', $qb->createNamedParameter($actor->getSummary())) diff --git a/lib/Db/ClientRequest.php b/lib/Db/ClientRequest.php index 162caada..f6432882 100644 --- a/lib/Db/ClientRequest.php +++ b/lib/Db/ClientRequest.php @@ -56,7 +56,7 @@ class ClientRequest extends ClientRequestBuilder { $qb->setValue('app_name', $qb->createNamedParameter($client->getAppName())) ->setValue('app_website', $qb->createNamedParameter($client->getAppWebsite())) ->setValue( - 'app_redirect_uris', $qb->createNamedParameter(json_encode($client->getAppRedirectUris())) + 'app_redirect_uris', $qb->createNamedParameter(json_encode($client->getAppRedirectUris())) ) ->setValue('app_client_id', $qb->createNamedParameter($client->getAppClientId())) ->setValue('app_client_secret', $qb->createNamedParameter($client->getAppClientSecret())) diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php index 1b5a73ba..012b0e9a 100644 --- a/lib/Db/CoreRequestBuilder.php +++ b/lib/Db/CoreRequestBuilder.php @@ -1054,8 +1054,8 @@ class CoreRequestBuilder { ->selectAlias($prefix . '_f.follow_id', $prefix . '_follow_id') ->selectAlias($prefix . '_f.creation', $prefix . '_creation') ->leftJoin( - $this->defaultSelectAlias, CoreRequestBuilder::TABLE_FOLLOWS, $prefix . '_f', - $andX + $this->defaultSelectAlias, CoreRequestBuilder::TABLE_FOLLOWS, $prefix . '_f', + $andX ); } diff --git a/lib/Db/RequestQueueRequest.php b/lib/Db/RequestQueueRequest.php index 9cb1f908..119dd88d 100644 --- a/lib/Db/RequestQueueRequest.php +++ b/lib/Db/RequestQueueRequest.php @@ -66,9 +66,9 @@ class RequestQueueRequest extends RequestQueueRequestBuilder { ->setValue('author', $qb->createNamedParameter($queue->getAuthor())) ->setValue('activity', $qb->createNamedParameter($queue->getActivity())) ->setValue( - 'instance', $qb->createNamedParameter( - json_encode($queue->getInstance(), JSON_UNESCAPED_SLASHES) - ) + 'instance', $qb->createNamedParameter( + json_encode($queue->getInstance(), JSON_UNESCAPED_SLASHES) + ) ) ->setValue('priority', $qb->createNamedParameter($queue->getPriority())) ->setValue('status', $qb->createNamedParameter($queue->getStatus())) @@ -133,8 +133,8 @@ class RequestQueueRequest extends RequestQueueRequestBuilder { $qb = $this->getRequestQueueUpdateSql(); $qb->set('status', $qb->createNamedParameter(RequestQueue::STATUS_RUNNING)) ->set( - 'last', - $qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE) + 'last', + $qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE) ); $this->limitToId($qb, $queue->getId()); $this->limitToStatus($qb, RequestQueue::STATUS_STANDBY); diff --git a/lib/Db/SocialCrossQueryBuilder.php b/lib/Db/SocialCrossQueryBuilder.php index 3bc16b12..830d6146 100644 --- a/lib/Db/SocialCrossQueryBuilder.php +++ b/lib/Db/SocialCrossQueryBuilder.php @@ -183,8 +183,8 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder { ->selectAlias('cd.error', 'cachedocument_error') ->selectAlias('cd.creation', 'cachedocument_creation') ->leftJoin( - $this->getDefaultSelectAlias(), CoreRequestBuilder::TABLE_CACHE_DOCUMENTS, 'cd', - $expr->eq($func->lower($pf . '.' . $fieldDocumentId), $func->lower('cd.id')) + $this->getDefaultSelectAlias(), CoreRequestBuilder::TABLE_CACHE_DOCUMENTS, 'cd', + $expr->eq($func->lower($pf . '.' . $fieldDocumentId), $func->lower('cd.id')) ); } diff --git a/lib/Db/StreamActionsRequest.php b/lib/Db/StreamActionsRequest.php index cbea36a0..c228f7bb 100644 --- a/lib/Db/StreamActionsRequest.php +++ b/lib/Db/StreamActionsRequest.php @@ -56,9 +56,9 @@ class StreamActionsRequest extends StreamActionsRequestBuilder { ->setValue('stream_id', $qb->createNamedParameter($action->getStreamId())) ->setValue('stream_id_prim', $qb->createNamedParameter($this->prim($action->getStreamId()))) ->setValue( - 'values', $qb->createNamedParameter( - json_encode($values, JSON_UNESCAPED_SLASHES) - ) + 'values', $qb->createNamedParameter( + json_encode($values, JSON_UNESCAPED_SLASHES) + ) ) ->setValue('liked', $qb->createNamedParameter(($liked) ? 1 : 0)) ->setValue('boosted', $qb->createNamedParameter(($boosted) ? 1 : 0)) diff --git a/lib/Db/StreamQueueRequest.php b/lib/Db/StreamQueueRequest.php index 1bfadf32..0ad3855e 100644 --- a/lib/Db/StreamQueueRequest.php +++ b/lib/Db/StreamQueueRequest.php @@ -110,8 +110,8 @@ class StreamQueueRequest extends StreamQueueRequestBuilder { $qb = $this->getStreamQueueUpdateSql(); $qb->set('status', $qb->createNamedParameter(StreamQueue::STATUS_RUNNING)) ->set( - 'last', - $qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE) + 'last', + $qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE) ); $this->limitToId($qb, $queue->getId()); $this->limitToStatus($qb, StreamQueue::STATUS_STANDBY); diff --git a/lib/Db/StreamRequest.php b/lib/Db/StreamRequest.php index 5da6c922..ce73b640 100644 --- a/lib/Db/StreamRequest.php +++ b/lib/Db/StreamRequest.php @@ -77,9 +77,9 @@ class StreamRequest extends StreamRequestBuilder { /** @var Note $stream */ $qb->setValue('hashtags', $qb->createNamedParameter(json_encode($stream->getHashtags()))) ->setValue( - 'attachments', $qb->createNamedParameter( - json_encode($stream->getAttachments(), JSON_UNESCAPED_SLASHES) - ) + 'attachments', $qb->createNamedParameter( + json_encode($stream->getAttachments(), JSON_UNESCAPED_SLASHES) + ) ); } @@ -707,19 +707,19 @@ class StreamRequest extends StreamRequestBuilder { ->setValue('subtype', $qb->createNamedParameter($stream->getSubType())) ->setValue('to', $qb->createNamedParameter($stream->getTo())) ->setValue( - 'to_array', $qb->createNamedParameter( - json_encode($stream->getToArray(), JSON_UNESCAPED_SLASHES) - ) + 'to_array', $qb->createNamedParameter( + json_encode($stream->getToArray(), JSON_UNESCAPED_SLASHES) + ) ) ->setValue( - 'cc', $qb->createNamedParameter( - json_encode($stream->getCcArray(), JSON_UNESCAPED_SLASHES) - ) + 'cc', $qb->createNamedParameter( + json_encode($stream->getCcArray(), JSON_UNESCAPED_SLASHES) + ) ) ->setValue( - 'bcc', $qb->createNamedParameter( - json_encode($stream->getBccArray(), JSON_UNESCAPED_SLASHES) - ) + 'bcc', $qb->createNamedParameter( + json_encode($stream->getBccArray(), JSON_UNESCAPED_SLASHES) + ) ) ->setValue('content', $qb->createNamedParameter($stream->getContent())) ->setValue('summary', $qb->createNamedParameter($stream->getSummary())) @@ -735,13 +735,13 @@ class StreamRequest extends StreamRequestBuilder { ->setValue('details', $qb->createNamedParameter(json_encode($stream->getDetailsAll()))) ->setValue('cache', $qb->createNamedParameter($cache)) ->setValue( - 'filter_duplicate', - $qb->createNamedParameter(($stream->isFilterDuplicate()) ? '1' : '0') + 'filter_duplicate', + $qb->createNamedParameter(($stream->isFilterDuplicate()) ? '1' : '0') ) ->setValue( - 'instances', $qb->createNamedParameter( - json_encode($stream->getInstancePaths(), JSON_UNESCAPED_SLASHES) - ) + 'instances', $qb->createNamedParameter( + json_encode($stream->getInstancePaths(), JSON_UNESCAPED_SLASHES) + ) ) ->setValue('local', $qb->createNamedParameter(($stream->isLocal()) ? '1' : '0')); @@ -752,8 +752,8 @@ class StreamRequest extends StreamRequestBuilder { 'published_time', $qb->createNamedParameter($dTime, IQueryBuilder::PARAM_DATE) ) ->setValue( - 'creation', - $qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE) + 'creation', + $qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE) ); } catch (Exception $e) { } diff --git a/lib/Db/StreamRequestBuilder.php b/lib/Db/StreamRequestBuilder.php index 634d2db1..5870f1f3 100644 --- a/lib/Db/StreamRequestBuilder.php +++ b/lib/Db/StreamRequestBuilder.php @@ -92,10 +92,10 @@ class StreamRequestBuilder extends CoreRequestBuilder { /** @noinspection PhpMethodParametersCountMismatchInspection */ $qb->selectDistinct('s.id') ->addSelect( - 's.nid', 's.type', 's.subtype', 's.to', 's.to_array', 's.cc', 's.bcc', 's.content', - 's.summary', 's.attachments', 's.published', 's.published_time', 's.cache', - 's.object_id', 's.attributed_to', 's.in_reply_to', 's.source', 's.local', - 's.instances', 's.creation', 's.filter_duplicate', 's.details', 's.hashtags' + 's.nid', 's.type', 's.subtype', 's.to', 's.to_array', 's.cc', 's.bcc', 's.content', + 's.summary', 's.attachments', 's.published', 's.published_time', 's.cache', + 's.object_id', 's.attributed_to', 's.in_reply_to', 's.source', 's.local', + 's.instances', 's.creation', 's.filter_duplicate', 's.details', 's.hashtags' ) ->from(self::TABLE_STREAM, 's'); diff --git a/lib/Migration/Version1000Date20221118000001.php b/lib/Migration/Version1000Date20221118000001.php index 1f44e082..a6ba7162 100644 --- a/lib/Migration/Version1000Date20221118000001.php +++ b/lib/Migration/Version1000Date20221118000001.php @@ -521,10 +521,10 @@ class Version1000Date20221118000001 extends SimpleMigrationStep { [ 'length' => 20, 'unsigned' => true -// 'autoincrement' => true, -// 'customSchemaOptions' => [ -// 'unique' => true -// ] + // 'autoincrement' => true, + // 'customSchemaOptions' => [ + // 'unique' => true + // ] ] ); $table->addColumn( diff --git a/lib/Tools/Traits/TNCLogger.php b/lib/Tools/Traits/TNCLogger.php index 2fa7d451..b58fbd9a 100644 --- a/lib/Tools/Traits/TNCLogger.php +++ b/lib/Tools/Traits/TNCLogger.php @@ -71,12 +71,12 @@ trait TNCLogger { $this->logger() ->log( - $level, - $message, - [ - 'app' => $this->setup('app'), - 'exception' => $t - ] + $level, + $message, + [ + 'app' => $this->setup('app'), + 'exception' => $t + ] ); } @@ -111,12 +111,12 @@ trait TNCLogger { $this->logger() ->log( - $level, - $message, - [ - 'app' => $this->setup('app'), - 'exception' => $e - ] + $level, + $message, + [ + 'app' => $this->setup('app'), + 'exception' => $e + ] ); } From cce31073d1043c0ccbdc3b1e015d4027c2832735 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Mon, 21 Nov 2022 10:26:34 +0100 Subject: [PATCH 4/4] Fix psalm Signed-off-by: Carl Schwan --- psalm.xml | 2 ++ tests/psalm-baseline.xml | 14 +------------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/psalm.xml b/psalm.xml index eac4c173..ebb13347 100644 --- a/psalm.xml +++ b/psalm.xml @@ -25,6 +25,7 @@ + @@ -33,6 +34,7 @@ + diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml index 993ea03b..b8182253 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -1,22 +1,10 @@ - + $level - - - DBALException - - - - - SchemaException - SchemaException - Type - - ['a', 'p', 'span', 'br']