jhass / nextcloud-keeweb

Integrate Keeweb into Nextcloud
Other
415 stars 49 forks source link

Undefined constant OCA\Keeweb\Migration\RegisterMimeType trace during Update attempt to Nectcloud 28 #236

Open c-schwamborn opened 10 months ago

c-schwamborn commented 10 months ago

during an attempt to upgrade our Nextcloud instance from 27.1.5 to 28.0.1 I got the following trace:

`An unhandled exception has been thrown: Error: Undefined constant OCA\Keeweb\Migration\RegisterMimeType::CUSTOM_MIMETYPEALIASES in /var/www/nextcloud/apps/keeweb/lib/Migration/RegisterMimeType.php:25 Stack trace:

0 /var/www/nextcloud/apps/keeweb/lib/Migration/RegisterMimeType.php(41): OCA\Keeweb\Migration\RegisterMimeType->registerForNewFiles()

1 /var/www/nextcloud/lib/private/Repair.php(127): OCA\Keeweb\Migration\RegisterMimeType->run()

2 /var/www/nextcloud/lib/private/legacy/OC_App.php(836): OC\Repair->run()

3 /var/www/nextcloud/lib/private/Installer.php(166): OC_App::executeRepairSteps()

4 /var/www/nextcloud/lib/private/legacy/OC_App.php(264): OC\Installer->installApp()

5 /var/www/nextcloud/lib/private/Updater.php(431): OC_App->enable()

6 /var/www/nextcloud/lib/private/Updater.php(284): OC\Updater->upgradeAppStoreApps()

7 /var/www/nextcloud/lib/private/Updater.php(140): OC\Updater->doUpgrade()

8 /var/www/nextcloud/core/Command/Upgrade.php(222): OC\Updater->upgrade()

9 /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php(298): OC\Core\Command\Upgrade->execute()

10 /var/www/nextcloud/3rdparty/symfony/console/Application.php(1040): Symfony\Component\Console\Command\Command->run()

11 /var/www/nextcloud/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand()

12 /var/www/nextcloud/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()

13 /var/www/nextcloud/lib/private/Console/Application.php(206): Symfony\Component\Console\Application->run()

14 /var/www/nextcloud/console.php(100): OC\Console\Application->run()

15 /var/www/nextcloud/occ(11): require_once('...')

16 {main}

` So I rolled back the whole update for now. Has anyone seen this before?

arnowelzel commented 10 months ago

Indeed, this constant is not defined. I wonder why this didn't show up earlier. Thanks for pointing this out, I'll have a look into it as soon as possible.

c-schwamborn commented 10 months ago

thanks for the quick answer.

arnowelzel commented 10 months ago

I stand corrected - no, the constant is defined. I don't understand, how this error can happen at all.

namespace OCA\Keeweb\Migration;

...

class RegisterMimeType extends MimeTypeMigration
{

...

    private function registerForNewFiles()
    {
        $configDir = \OC::$configDir;
        $mimetypealiasesFile = $configDir . self::CUSTOM_MIMETYPEALIASES;
        $mimetypemappingFile = $configDir . self::CUSTOM_MIMETYPEMAPPING;

        $this->appendToFile($mimetypealiasesFile, ['application/x-kdbx' => 'kdbx']);
        $this->appendToFile($mimetypemappingFile, ['kdbx' => ['application/x-kdbx']]);
    }

and the base class MimeTypeMigration:

namespace OCA\Keeweb\Migration;

...

abstract class MimeTypeMigration implements IRepairStep
{
    const CUSTOM_MIMETYPEMAPPING = 'mimetypemapping.json';
    const CUSTOM_MIMETYPEALIASES = 'mimetypealiases.json';

I have no idea why this should not work.

arnowelzel commented 10 months ago

I suggest you remove the app first, then upgrade Nextcloud to NC 28 and then install the app again - this should work. I assume, the app is not updated first prior to the NC 28 upgrade - but this is needed since older Keeweb version will not work with NC 28 at all.

c-schwamborn commented 10 months ago

I will try this next week and let you know how it went. Are there any user settings vanishing due to the removal of Keeweb, or do they simply remain in the database and are updated/migrated later upon reinstalling Keeweb again?

arnowelzel commented 10 months ago

Keeweb does not have any settings which are stored in Nextcloud. All settings are only stored locally in the browser, in which you use it. But Nextcloud also does not delete settings from the database when an app is removed. So removing an app and installing the latest version again after an upgrade of Nextcloud should bring it back as it was before.

c-schwamborn commented 10 months ago

thanks, good to know.

c-schwamborn commented 10 months ago

Hello and a good Monday morning. Removing Keeweb ahead of the update and reinstalling it afterwards seems to work. At least I didn't noticed any error messages or issues with some quick tests in Keeweb, at least nothing related to Keeweb. Thanks again for the help.

mMuck commented 9 months ago

Hi. I experienced the same issue while upgrading and now the code integrity check fails 😢

Update app keeweb from App Store
Repair step: Register MIME type for "application/x-kdbx"
Repair info: Registering the mimetype...
An unhandled exception has been thrown:
Error: Undefined constant OCA\Keeweb\Migration\RegisterMimeType::CUSTOM_MIMETYPEALIASES in /var/www/virtual/nc/html/apps/keeweb/lib/Migration/RegisterMimeType.php:25
Stack trace:
#0 /var/www/virtual/nc/html/apps/keeweb/lib/Migration/RegisterMimeType.php(41): OCA\Keeweb\Migration\RegisterMimeType->registerForNewFiles()
#1 /var/www/virtual/nc/html/lib/private/Repair.php(127): OCA\Keeweb\Migration\RegisterMimeType->run(Object(OC\Repair))
#2 /var/www/virtual/nc/html/lib/private/legacy/OC_App.php(836): OC\Repair->run()
#3 /var/www/virtual/nc/html/lib/private/Installer.php(166): OC_App::executeRepairSteps('keeweb', Array)
#4 /var/www/virtual/nc/html/lib/private/legacy/OC_App.php(264): OC\Installer->installApp('keeweb')
#5 /var/www/virtual/nc/html/lib/private/Updater.php(429): OC_App->enable('keeweb', Array)
#6 /var/www/virtual/nc/html/lib/private/Updater.php(284): OC\Updater->upgradeAppStoreApps(Array, Array)
#7 /var/www/virtual/nc/html/lib/private/Updater.php(140): OC\Updater->doUpgrade('28.0.1.1', '27.1.6.2')
#8 /var/www/virtual/nc/html/core/Command/Upgrade.php(222): OC\Updater->upgrade()
#9 /var/www/virtual/nc/html/3rdparty/symfony/console/Command/Command.php(298): OC\Core\Command\Upgrade->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/virtual/nc/html/3rdparty/symfony/console/Application.php(1040): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/virtual/nc/html/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(OC\Core\Command\Upgrade), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/virtual/nc/html/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/virtual/nc/html/lib/private/Console/Application.php(206): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/virtual/nc/html/console.php(100): OC\Console\Application->run()
#15 /var/www/virtual/nc/html/occ(11): require_once('/var/www/virtua...')
#16 {main}
Results
=======
- core
    - INVALID_HASH
        - core/js/mimetypelist.js
    - EXTRA_FILE
        - core/img/filetypes/drawio.svg
        - core/img/filetypes/dwb.svg

Raw output
==========
Array
(
    [core] => Array
        (
            [INVALID_HASH] => Array
                (
                    [core/js/mimetypelist.js] => Array
                        (
                            [expected] => 550ab566d30693bfa24ec4b15d9df87731ae8a3be8f79dabf94757e5b8b20eec6e4b678f17af1718297f2872f6b04519eeb024d1dff11947f29da431c7f11201
                            [current] => 301654cbbe168b8723530db88fd2e40ad688f4e6b0bdaeade5b4fe34bd94d9d3cfe760821e97dc792e585d4b6ccff838597bfd46466bb07d30ff84df4cb79518
                        )
                )
            [EXTRA_FILE] => Array
                (
                    [core/img/filetypes/drawio.svg] => Array
                        (
                            [expected] => 
                            [current] => 92e0974cf869bf8ab969c3442dc2b80d55fde36441d22924db74916a06b407520aa2a9dc39336f9157195ebede697ffac0e639360879255ab91932d406e1897d
                        )

                    [core/img/filetypes/dwb.svg] => Array
                        (
                            [expected] => 
                            [current] => 43731dd5f17a048112ea5109b40b02ec019b3ee2324385a0f448e3bd2264cb13dc160ab018d893f92f8e2f168fd09009b51578c8c6b97a02a1617c67ac087701
                        )
                )
        )
)

Is this related? I tried to remove keeweb and draw.io and added them after that but the check still fails. I'll try to replace mimetypelist.js

arnowelzel commented 9 months ago

Sorry, I don't have any solution for this and KeeWeb itself is outdated and not maintained any longer anyway. I will add a deprecation warning to the app that it should not be used any longer.

Edit: the problems with Draw.io are not related - that's another issue cuased by Draw.io itself.

Benedikt81 commented 8 months ago

I had the same problem when updating to NC 28. I didn't need to revert the upgrade, though, but instead restarted the upgrade via the occ command. Maybe that saves someone else some time.

c-schwamborn commented 8 months ago

The revert was merely a precaution until I knew what went wrong during the upgrade. Frankly, the v28 is the most buggy release so far, keeweb was the least of its issues.

On 07/03/2024 08.58, Benedikt Nyqvist wrote:

I had the same problem when updating to NC 28. I didn't need to revert the upgrade, though, but instead restarted the upgrade via the occ command. Maybe that saves someone else some time.