jhass/nextcloud-keeweb

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

c-schwamborn opened this issue · 12 comments

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?

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.

thanks for the quick answer.

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.

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.

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?

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.

thanks, good to know.

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.

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

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.

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.