Skip to content

Commit

Permalink
Cleanup tags and Share component
Browse files Browse the repository at this point in the history
- Port to LoggerInterface
- Use IDBConnection and IQueryBuilder instead of raw SQL and OC_DB
- Use IEventListener instead of hooks
- Remove the now unused OC_DB and OC_DB_StatementWrapper legacy utils

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
  • Loading branch information
CarlSchwan committed Apr 19, 2022
1 parent 0824f44 commit 31c03d6
Show file tree
Hide file tree
Showing 14 changed files with 577 additions and 871 deletions.
17 changes: 0 additions & 17 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4119,12 +4119,6 @@
</ParamNameMismatch>
</file>
<file src="lib/private/Share/Share.php">
<FalsableReturnStatement occurrences="1">
<code>false</code>
</FalsableReturnStatement>
<InvalidArgument occurrences="1">
<code>$arguments</code>
</InvalidArgument>
<InvalidOperand occurrences="1">
<code>!self::isResharingAllowed()</code>
</InvalidOperand>
Expand Down Expand Up @@ -4276,9 +4270,6 @@
</NullableReturnStatement>
</file>
<file src="lib/private/Tags.php">
<InvalidArgument occurrences="1">
<code>[$this-&gt;user, $this-&gt;type, $chunk]</code>
</InvalidArgument>
<InvalidScalarArgument occurrences="2">
<code>$from</code>
<code>$names</code>
Expand Down Expand Up @@ -4488,14 +4479,6 @@
<code>$appId === null</code>
</TypeDoesNotContainNull>
</file>
<file src="lib/private/legacy/OC_DB.php">
<InvalidReturnStatement occurrences="1">
<code>$result</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>OC_DB_StatementWrapper</code>
</InvalidReturnType>
</file>
<file src="lib/private/legacy/OC_FileChunking.php">
<UndefinedDocblockClass occurrences="1">
<code>\OC\InsufficientStorageException</code>
Expand Down
14 changes: 10 additions & 4 deletions core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
use OC\DB\MissingPrimaryKeyInformation;
use OC\DB\SchemaWrapper;
use OC\Metadata\FileEventListener;
use OC\TagManager;
use OCP\AppFramework\App;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\Node\NodeDeletedEvent;
Expand Down Expand Up @@ -307,14 +308,19 @@ function (GenericEvent $event) use ($container) {
$eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedFilesCleanupListener::class);
$eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedWebAuthnCleanupListener::class);

/** @var IEventDispatcher $eventDispatcher */
$newEventDispatcher = \OC::$server->get(IEventDispatcher::class);

// Metadata
/** @var IConfig $config */
$config = $container->get(IConfig::class);
if ($config->getSystemValueBool('enable_file_metadata', true)) {
$eventDispatcher = \OC::$server->get(IEventDispatcher::class);
$eventDispatcher->addServiceListener(NodeDeletedEvent::class, FileEventListener::class);
$eventDispatcher->addServiceListener(NodeRemovedFromCache::class, FileEventListener::class);
$eventDispatcher->addServiceListener(NodeWrittenEvent::class, FileEventListener::class);
$newEventDispatcher->addServiceListener(NodeDeletedEvent::class, FileEventListener::class);
$newEventDispatcher->addServiceListener(NodeRemovedFromCache::class, FileEventListener::class);
$newEventDispatcher->addServiceListener(NodeWrittenEvent::class, FileEventListener::class);
}

// Tags
$newEventDispatcher->addServiceListener(UserDeletedEvent::class, TagManager::class);
}
}
2 changes: 0 additions & 2 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1547,8 +1547,6 @@
'OC\\User\\User' => $baseDir . '/lib/private/User/User.php',
'OC_API' => $baseDir . '/lib/private/legacy/OC_API.php',
'OC_App' => $baseDir . '/lib/private/legacy/OC_App.php',
'OC_DB' => $baseDir . '/lib/private/legacy/OC_DB.php',
'OC_DB_StatementWrapper' => $baseDir . '/lib/private/legacy/OC_DB_StatementWrapper.php',
'OC_Defaults' => $baseDir . '/lib/private/legacy/OC_Defaults.php',
'OC_EventSource' => $baseDir . '/lib/private/legacy/OC_EventSource.php',
'OC_FileChunking' => $baseDir . '/lib/private/legacy/OC_FileChunking.php',
Expand Down
2 changes: 0 additions & 2 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -1576,8 +1576,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\User\\User' => __DIR__ . '/../../..' . '/lib/private/User/User.php',
'OC_API' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_API.php',
'OC_App' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_App.php',
'OC_DB' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_DB.php',
'OC_DB_StatementWrapper' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_DB_StatementWrapper.php',
'OC_Defaults' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_Defaults.php',
'OC_EventSource' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_EventSource.php',
'OC_FileChunking' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_FileChunking.php',
Expand Down
1 change: 0 additions & 1 deletion lib/private/Setup/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ private function createDatabase($connection) {
try {
$name = $this->dbName;
$user = $this->dbUser;
//we can't use OC_DB functions here because we need to connect as the administrative user.
$characterSet = $this->config->getValue('mysql.utf8mb4', false) ? 'utf8mb4' : 'utf8';
$query = "CREATE DATABASE IF NOT EXISTS `$name` CHARACTER SET $characterSet COLLATE ${characterSet}_bin;";
$connection->executeUpdate($query);
Expand Down
Loading

0 comments on commit 31c03d6

Please sign in to comment.