Skip to content

Commit

Permalink
Merge pull request #2607 from nextcloud/backport/2593/stable30
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Aug 14, 2024
2 parents 9cf23ae + 75df4c6 commit 22ca62d
Show file tree
Hide file tree
Showing 8 changed files with 322 additions and 138 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ cypress/videos
cypress/snapshots
cypress/downloads

js/*hot-update.*
js/*hot-update.*
tests/.phpunit.result.cache
3 changes: 1 addition & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<name>Photos</name>
<summary>Your memories under your control</summary>
<description>Your memories under your control</description>
<version>3.0.1</version>
<version>3.0.2</version>
<licence>agpl</licence>
<author mail="[email protected]">John Molakvoæ</author>
<namespace>Photos</namespace>
Expand All @@ -22,7 +22,6 @@
<website>https://github.com/nextcloud/photos</website>
<bugs>https://github.com/nextcloud/photos/issues</bugs>
<repository>https://github.com/nextcloud/photos.git</repository>
<default_enable />
<dependencies>
<nextcloud min-version="30" max-version="30" />
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"psalm:update-baseline": "psalm.phar --threads=1 --update-baseline",
"psalm:clear": "psalm.phar --clear-cache && psalm --clear-global-cache",
"psalm:fix": "psalm.phar --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType",
"test:unit": "echo 'Only testing installation of the app'"
"test:unit": "vendor/bin/phpunit -c tests/phpunit.xml --color --fail-on-warning --fail-on-risky"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

/**
* Migrate the photosSourceFolder user config to photosSourceFolders
*/
class Version30000Date20240417075404 extends SimpleMigrationStep {
class Version30000Date20240417075405 extends SimpleMigrationStep {
public function __construct(
private IDBConnection $db,
) {
Expand All @@ -36,13 +37,26 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array
->where($select->expr()->eq('appid', $select->expr()->literal('photos')))
->andWhere($select->expr()->eq('configkey', $select->expr()->literal('photosSourceFolders')));

$result = $select->executeQuery();
$alreadyMigrated = array_map(static fn (array $row) => $row['userid'], $result->fetchAll());
$result->closeCursor();

// Remove old entries for users who already have the new one
$delete = $this->db->getQueryBuilder();
$delete->delete('preferences')
->where($delete->expr()->eq('appid', $delete->expr()->literal('photos')))
->andWhere($delete->expr()->eq('configkey', $delete->expr()->literal('photosSourceFolder')))
->andWhere($delete->expr()->in('userid', $delete->createFunction($select->getSQL())))
->executeStatement();
->andWhere($delete->expr()->in(
'userid',
$delete->createParameter('chunk'),
IQueryBuilder::PARAM_STR
));

$chunks = array_chunk($alreadyMigrated, 1000);
foreach ($chunks as $chunk) {
$delete->setParameter('chunk', $chunk, IQueryBuilder::PARAM_STR_ARRAY);
$delete->executeStatement();
}

// Update remaining old entries to new ones
$update = $this->db->getQueryBuilder();
Expand Down
Loading

0 comments on commit 22ca62d

Please sign in to comment.