Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enh: file fields: sort_order #6593

Merged
merged 2 commits into from
Sep 26, 2023

Conversation

martin-rueegg
Copy link
Contributor

@martin-rueegg martin-rueegg commented Sep 23, 2023

Adds sort_order field to File table/model.

What kind of change does this PR introduce?

  • Feature

Does this PR introduce a breaking change?

  • No

The PR fulfills these requirements

  • It's submitted to the develop branch, not the master branch if no hotfix
  • All tests are passing
  • New/updated tests are included
  • Changelog was modified

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

Depends on/includes:

@CLAassistant
Copy link

CLAassistant commented Sep 23, 2023

CLA assistant check
All committers have signed the CLA.

@martin-rueegg martin-rueegg changed the base branch from master to develop September 23, 2023 14:08
@martin-rueegg martin-rueegg marked this pull request as ready for review September 23, 2023 15:01
Copy link
Contributor

@luke- luke- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far we always use sort_order as a free/non unqiue numeric field for individual sorting. If a value is used multiple times, it will be sorted by a second field like ID or filename.

I would stay on this approach for files as well for now.

I am aware that it also has disadvantages. But I want to stay consistent here for now. Especially so shortly before the release.

Copy link
Contributor

@luke- luke- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change. Please see my remark regarding updateAll().

protected/humhub/modules/file/models/File.php Outdated Show resolved Hide resolved
@luke- luke- added this pull request to the merge queue Sep 26, 2023
Merged via the queue into humhub:develop with commit 2a9968b Sep 26, 2023
6 checks passed
@martin-rueegg martin-rueegg deleted the enh/file-preliminary-fields-sorting branch September 26, 2023 22:44
luke- added a commit that referenced this pull request Sep 27, 2023
* Fix mimetype of converted preview svg file to png after uploading (#6599)

* Enh: `file` fields: `sort_order` (#6593)

* Add `File.sort_order`

* Apply requested changes

* Enh Testing: Backport #6553 (#6588)

* Fix humhub test case would fail on skipped tests (#6516)

* Fix skipped test handling

* Fix error while sending mails from the queue

```
- ReadableContentQueryTest: Global content guest non guest mode  Destroying application
  Starting application
  [ConnectionWatcher] watching new connections
  [Fixtures] Loading fixtures
  [ConnectionWatcher] watching new connections
  [ConnectionWatcher] no longer watching new connections
  [ConnectionWatcher] closing all (0) connections
  [Fixtures] Done
  [yii\web\Session::open] 'Session started'
  [queue] 'Could not execute queued job! Message: Argument 2 passed to Symfony\\Component\\Mime\\Address::__construct() must be of the type string, null given, called in /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2-symfonymailer/src/Message.php on line 368 Trace:#0 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2-symfonymailer/src/Message.php(368): Symfony\\Component\\Mime\\Address->__construct()
  #1 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2-symfonymailer/src/Message.php(51): yii\\symfonymailer\\Message->convertStringsToAddresses()
  #2 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/notification/targets/MailTarget.php(71): yii\\symfonymailer\\Message->setFrom()
  #3 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/notification/targets/BaseTarget.php(161): humhub\\modules\\notification\\targets\\MailTarget->handle()
  #4 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/notification/components/NotificationManager.php(101): humhub\\modules\\notification\\targets\\BaseTarget->send()
  #5 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/notification/jobs/SendBulkNotification.php(38): humhub\\modules\\notification\\components\\NotificationManager->sendBulk()
  #6 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/queue/ActiveJob.php(33): humhub\\modules\\notification\\jobs\\SendBulkNotification->run()
  #7 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2-queue/src/Queue.php(246): humhub\\modules\\queue\\ActiveJob->execute()
  #8 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/queue/driver/Instant.php(31): yii\\queue\\Queue->handleMessage()
  #9 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2-queue/src/Queue.php(196): humhub\\modules\\queue\\driver\\Instant->pushMessage()
  #10 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/notification/components/BaseNotification.php(210): yii\\queue\\Queue->push()
  #11 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/content/models/Content.php(370): humhub\\modules\\notification\\components\\BaseNotification->sendBulk()
  #12 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/content/models/Content.php(321): humhub\\modules\\content\\models\\Content->notifyContentCreated()
  #13 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/content/models/Content.php(268): humhub\\modules\\content\\models\\Content->processNewContent()
  #14 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2/db/ActiveRecord.php(615): humhub\\modules\\content\\models\\Content->afterSave()
  #15 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2/db/ActiveRecord.php(570): yii\\db\\ActiveRecord->insertInternal()
  #16 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2/db/BaseActiveRecord.php(676): yii\\db\\ActiveRecord->insert()
  #17 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/content/components/ContentActiveRecord.php(476): yii\\db\\BaseActiveRecord->save()
  #18 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/post/models/Post.php(97): humhub\\modules\\content\\components\\ContentActiveRecord->afterSave()
  #19 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2/db/ActiveRecord.php(615): humhub\\modules\\post\\models\\Post->afterSave()
  #20 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2/db/ActiveRecord.php(570): yii\\db\\ActiveRecord->insertInternal()
  #21 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2/db/BaseActiveRecord.php(676): yii\\db\\ActiveRecord->insert()
  #22 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/content/tests/codeception/unit/ReadableContentQueryTest.php(70): yii\\db\\BaseActiveRecord->save()
  #23 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/src/Codeception/Test/Unit.php(57): tests\\codeception\\unit\\modules\\content\\ReadableContentQueryTest->_before()
  #24 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/phpunit-wrapper/src/TestCase.php(12): Codeception\\Test\\Unit->_setUp()
  #25 /home/mdr/projects/humhub/htdocs/protected/humhub/tests/codeception/_support/HumHubDbTestCase.php(60): Codeception\\PHPUnit\\TestCase->setUp()
  #26 /home/mdr/projects/humhub/htdocs/protected/vendor/phpunit/phpunit/src/Framework/TestCase.php(1207): tests\\codeception\\_support\\HumHubDbTestCase->setUp()
  #27 /home/mdr/projects/humhub/htdocs/protected/vendor/phpunit/phpunit/src/Framework/TestResult.php(728): PHPUnit\\Framework\\TestCase->runBare()
  #28 /home/mdr/projects/humhub/htdocs/protected/vendor/phpunit/phpunit/src/Framework/TestCase.php(964): PHPUnit\\Framework\\TestResult->run()
  #29 /home/mdr/projects/humhub/htdocs/protected/vendor/phpunit/phpunit/src/Framework/TestSuite.php(684): PHPUnit\\Framework\\TestCase->run()
  #30 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/phpunit-wrapper/src/Runner.php(117): PHPUnit\\Framework\\TestSuite->run()
  #31 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/src/Codeception/SuiteManager.php(161): Codeception\\PHPUnit\\Runner->doEnhancedRun()
  #32 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/src/Codeception/Codecept.php(208): Codeception\\SuiteManager->run()
  #33 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/src/Codeception/Codecept.php(162): Codeception\\Codecept->runSuite()
  #34 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/src/Codeception/Command/Run.php(401): Codeception\\Codecept->run()
  #35 /home/mdr/projects/humhub/htdocs/protected/vendor/symfony/console/Command/Command.php(298): Codeception\\Command\\Run->execute()
  #36 /home/mdr/projects/humhub/htdocs/protected/vendor/symfony/console/Application.php(1040): Symfony\\Component\\Console\\Command\\Command->run()
  #37 /home/mdr/projects/humhub/htdocs/protected/vendor/symfony/console/Application.php(301): Symfony\\Component\\Console\\Application->doRunCommand()
  #38 /home/mdr/projects/humhub/htdocs/protected/vendor/symfony/console/Application.php(171): Symfony\\Component\\Console\\Application->doRun()
  #39 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/src/Codeception/Application.php(117): Symfony\\Component\\Console\\Application->run()
  #40 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/app.php(46): Codeception\\Application->run()
  #41 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/app.php(47): {closure}()
  #42 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/codecept(6): require(\'/home/mdr/proje...\')
  #43 /home/mdr/projects/humhub/htdocs/protected/vendor/bin/codecept(112): include(\'/home/mdr/proje...\')
  #44 {main}'
  [queue] 'Could not execute queued job! Message: Argument 2 passed to Symfony\\Component\\Mime\\Address::__construct() must be of the type string, null given, called in /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2-symfonymailer/src/Message.php on line 368 Trace:#0 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2-symfonymailer/src/Message.php(368): Symfony\\Component\\Mime\\Address->__construct()
  #1 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2-symfonymailer/src/Message.php(51): yii\\symfonymailer\\Message->convertStringsToAddresses()
  #2 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/notification/targets/MailTarget.php(71): yii\\symfonymailer\\Message->setFrom()
  #3 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/notification/targets/BaseTarget.php(161): humhub\\modules\\notification\\targets\\MailTarget->handle()
  #4 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/notification/components/NotificationManager.php(101): humhub\\modules\\notification\\targets\\BaseTarget->send()
  #5 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/notification/jobs/SendBulkNotification.php(38): humhub\\modules\\notification\\components\\NotificationManager->sendBulk()
  #6 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/queue/ActiveJob.php(33): humhub\\modules\\notification\\jobs\\SendBulkNotification->run()
  #7 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2-queue/src/Queue.php(246): humhub\\modules\\queue\\ActiveJob->execute()
  #8 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/queue/driver/Instant.php(31): yii\\queue\\Queue->handleMessage()
  #9 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2-queue/src/Queue.php(196): humhub\\modules\\queue\\driver\\Instant->pushMessage()
  #10 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/notification/components/BaseNotification.php(210): yii\\queue\\Queue->push()
  #11 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/content/models/Content.php(370): humhub\\modules\\notification\\components\\BaseNotification->sendBulk()
  #12 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/content/models/Content.php(321): humhub\\modules\\content\\models\\Content->notifyContentCreated()
  #13 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/content/models/Content.php(268): humhub\\modules\\content\\models\\Content->processNewContent()
  #14 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2/db/ActiveRecord.php(615): humhub\\modules\\content\\models\\Content->afterSave()
  #15 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2/db/ActiveRecord.php(570): yii\\db\\ActiveRecord->insertInternal()
  #16 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2/db/BaseActiveRecord.php(676): yii\\db\\ActiveRecord->insert()
  #17 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/content/components/ContentActiveRecord.php(476): yii\\db\\BaseActiveRecord->save()
  #18 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/post/models/Post.php(97): humhub\\modules\\content\\components\\ContentActiveRecord->afterSave()
  #19 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2/db/ActiveRecord.php(615): humhub\\modules\\post\\models\\Post->afterSave()
  #20 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2/db/ActiveRecord.php(570): yii\\db\\ActiveRecord->insertInternal()
  #21 /home/mdr/projects/humhub/htdocs/protected/vendor/yiisoft/yii2/db/BaseActiveRecord.php(676): yii\\db\\ActiveRecord->insert()
  #22 /home/mdr/projects/humhub/htdocs/protected/humhub/modules/content/tests/codeception/unit/ReadableContentQueryTest.php(76): yii\\db\\BaseActiveRecord->save()
  #23 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/src/Codeception/Test/Unit.php(57): tests\\codeception\\unit\\modules\\content\\ReadableContentQueryTest->_before()
  #24 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/phpunit-wrapper/src/TestCase.php(12): Codeception\\Test\\Unit->_setUp()
  #25 /home/mdr/projects/humhub/htdocs/protected/humhub/tests/codeception/_support/HumHubDbTestCase.php(60): Codeception\\PHPUnit\\TestCase->setUp()
  #26 /home/mdr/projects/humhub/htdocs/protected/vendor/phpunit/phpunit/src/Framework/TestCase.php(1207): tests\\codeception\\_support\\HumHubDbTestCase->setUp()
  #27 /home/mdr/projects/humhub/htdocs/protected/vendor/phpunit/phpunit/src/Framework/TestResult.php(728): PHPUnit\\Framework\\TestCase->runBare()
  #28 /home/mdr/projects/humhub/htdocs/protected/vendor/phpunit/phpunit/src/Framework/TestCase.php(964): PHPUnit\\Framework\\TestResult->run()
  #29 /home/mdr/projects/humhub/htdocs/protected/vendor/phpunit/phpunit/src/Framework/TestSuite.php(684): PHPUnit\\Framework\\TestCase->run()
  #30 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/phpunit-wrapper/src/Runner.php(117): PHPUnit\\Framework\\TestSuite->run()
  #31 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/src/Codeception/SuiteManager.php(161): Codeception\\PHPUnit\\Runner->doEnhancedRun()
  #32 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/src/Codeception/Codecept.php(208): Codeception\\SuiteManager->run()
  #33 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/src/Codeception/Codecept.php(162): Codeception\\Codecept->runSuite()
  #34 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/src/Codeception/Command/Run.php(401): Codeception\\Codecept->run()
  #35 /home/mdr/projects/humhub/htdocs/protected/vendor/symfony/console/Command/Command.php(298): Codeception\\Command\\Run->execute()
  #36 /home/mdr/projects/humhub/htdocs/protected/vendor/symfony/console/Application.php(1040): Symfony\\Component\\Console\\Command\\Command->run()
  #37 /home/mdr/projects/humhub/htdocs/protected/vendor/symfony/console/Application.php(301): Symfony\\Component\\Console\\Application->doRunCommand()
  #38 /home/mdr/projects/humhub/htdocs/protected/vendor/symfony/console/Application.php(171): Symfony\\Component\\Console\\Application->doRun()
  #39 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/src/Codeception/Application.php(117): Symfony\\Component\\Console\\Application->run()
  #40 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/app.php(46): Codeception\\Application->run()
  #41 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/app.php(47): {closure}()
  #42 /home/mdr/projects/humhub/htdocs/protected/vendor/codeception/codeception/codecept(6): require(\'/home/mdr/proje...\')
  #43 /home/mdr/projects/humhub/htdocs/protected/vendor/bin/codecept(112): include(\'/home/mdr/proje...\')
  #44 {main}'
  [tests\codeception\_support\HumHubDbTestCase::setUp] Initializing Modules
  [tests\codeception\_support\HumHubDbTestCase::setUp] Reloading settings
  [tests\codeception\_support\HumHubDbTestCase::setUp] Flushing cache
  [tests\codeception\_support\HumHubDbTestCase::setUp] Deleting mails
  [yii\mail\BaseMailer::send] 'Sending email "Sara Tester just wrote post "Public Space Public Post" in space Space 3" to "user1@example.com"'
  [yii\mail\BaseMailer::send] 'Sending email "Sara Tester just wrote post "Public Space Private Post" in space Space 3" to "user1@example.com"'
  [yii\web\User::logout] 'User \'2\' logged out from .'
✔ ReadableContentQueryTest: Global content guest non guest mode (3.06s)
^
```

rather than

```
- ReadableContentQueryTest: Global content guest non guest mode  Destroying application
  Starting application
  [ConnectionWatcher] watching new connections
  [Fixtures] Loading fixtures
  [ConnectionWatcher] watching new connections
  [ConnectionWatcher] no longer watching new connections
  [ConnectionWatcher] closing all (0) connections
  [Fixtures] Done
  [tests\codeception\_support\HumHubDbTestCase::setUp] Initializing Modules
  [tests\codeception\_support\HumHubDbTestCase::setUp] Reloading settings
  [tests\codeception\_support\HumHubDbTestCase::setUp] Flushing cache
  [tests\codeception\_support\HumHubDbTestCase::setUp] Deleting mails
  [yii\web\Session::open] 'Session started'
  [yii\mail\BaseMailer::send] 'Sending email "Sara Tester just wrote post "Public Space Public Post" in space Space 3" to "user1@example.com"'
  [yii\mail\BaseMailer::send] 'Sending email "Sara Tester just wrote post "Public Space Private Post" in space Space 3" to "user1@example.com"'
  [yii\web\User::logout] 'User \'2\' logged out from .'
✔ ReadableContentQueryTest: Global content guest non guest mode (1.51s)
  Destroying application
  [ConnectionWatcher] no longer watching new connections
  [ConnectionWatcher] closing all (0) connections
-
```

* Support log assertions (#6553)

* Make methods static where possible, so they can be used in class setup and teardown

* Revert extracting DB helper functions to DbHelper.php

* fixup! Enh UUID validator

* fixup! Revert extracting DB helper functions to DbHelper.php

---------

Co-authored-by: Yuriy Bakhtin <yurabakhtin@users.noreply.github.com>
Co-authored-by: Lucas Bartholemy <lucas@bartholemy.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants