marius-wieschollek / passwords

A simple, yet feature rich password manager for Nextcloud
GNU Affero General Public License v3.0
215 stars 45 forks source link

Error updating from version 2022.2.10 to 2022.2.20 #477

Closed allan-null closed 2 years ago

allan-null commented 2 years ago

System Information

 Nextcloud Version: 23.0.1.2
 PHP Version: 8.0 FPM
 Database and Version: MariaDB 5.5.5-10.5.12-MariaDB-0+deb11u1
 Server OS and Version: Debian Stable
 Passwords Version: 2022.2.20

Steps to reproduce

  1. Update Nextcloud Passwords from version 2022.2.10 to 2022.2.20.

Expected result

Update the app successfully.

Actual result

It fails and the Nextcloud instance stays in maintenance mode.

Nextcloud log

Nextcloud log ``` An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column '20210800' in 'where clause' ```
allan-null commented 2 years ago

I fixed the issue on my instance by changing the lines 216 and 217 from file src/lib/Migration/Version20220101.php to: 216 ->where($qb->expr()->eq('a.app', $qb->createNamedParameter('passwords'))) 217 ->where($qb->expr()->eq('a.version', $qb->createNamedParameter('20210800')));

FabianLPHD commented 2 years ago

Same here.

I fixed the issue on my instance by changing the lines 216 and 217 from file src/lib/Migration/Version20220101.php to: 216 ->where($qb->expr()->eq('a.app', $qb->createNamedParameter('passwords'))) 217 ->where($qb->expr()->eq('a.version', $qb->createNamedParameter('20210800')));

Doesn't work for me. Did the changes under app/passwords....

Now i get while doing occ upgrade:

Setting log level to debug Turned on maintenance mode Updating database schema Updated database Updating ... An unhandled exception has been thrown: ParseError: syntax error, unexpected 'ConfigurationService' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /var/www/nextcloud/apps/passwords/lib/Migration/CliDatabaseObjectRepair.php:45 Stack trace:

0 /var/www/nextcloud/lib/composer/composer/ClassLoader.php(428): Composer\Autoload\includeFile()

1 [internal function]: Composer\Autoload\ClassLoader->loadClass()

2 [internal function]: spl_autoload_call()

3 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(112): ReflectionClass->__construct()

4 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(131): OC\AppFramework\Utility\SimpleContainer->resolve()

5 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(463): OC\AppFramework\Utility\SimpleContainer->query()

6 /var/www/nextcloud/lib/private/ServerContainer.php(145): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback()

7 /var/www/nextcloud/lib/private/Repair.php(140): OC\ServerContainer->query()

8 /var/www/nextcloud/lib/private/legacy/OC_App.php(1064): OC\Repair->addStep()

9 /var/www/nextcloud/lib/private/legacy/OC_App.php(1013): OC_App::executeRepairSteps()

10 /var/www/nextcloud/lib/private/Updater.php(353): OC_App::updateApp()

11 /var/www/nextcloud/lib/private/Updater.php(265): OC\Updater->doAppUpgrade()

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

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

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

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

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

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

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

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

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

What can i do now?!

allan-null commented 2 years ago

What are the contents of the file /var/www/nextcloud/apps/passwords/lib/Migration/CliDatabaseObjectRepair.php for you?

FabianLPHD commented 2 years ago
<?php
/*
 * @copyright 2022 Passwords App
 *
 * @author Marius David Wieschollek
 * @license AGPL-3.0
 *
 * This file is part of the Passwords App
 * created by Marius David Wieschollek.
 */

namespace OCA\Passwords\Migration;

use JetBrains\PhpStorm\Pure;
use OCA\Passwords\Migration\DatabaseRepair\FolderModelRepair;
use OCA\Passwords\Migration\DatabaseRepair\FolderRevisionRepair;
use OCA\Passwords\Migration\DatabaseRepair\PasswordModelRepair;
use OCA\Passwords\Migration\DatabaseRepair\PasswordRevisionRepair;
use OCA\Passwords\Migration\DatabaseRepair\PasswordTagRelationRepair;
use OCA\Passwords\Migration\DatabaseRepair\TagModelRepair;
use OCA\Passwords\Migration\DatabaseRepair\TagRevisionRepair;
use OCA\Passwords\Services\ConfigurationService;
use OCA\Passwords\Services\EnvironmentService;
use OCP\Migration\IOutput;

class CliDatabaseObjectRepair extends DatabaseObjectRepair {

    /**
     * @var \OCA\Passwords\Services\EnvironmentService
     */
    protected $environmentService;

    /**
     * @param ConfigurationService      $config
     * @param TagModelRepair            $tagModelRepair
     * @param FolderModelRepair         $folderModelRepair
     * @param TagRevisionRepair         $tagRevisionRepair
     * @param EnvironmentService        $environmentService
     * @param PasswordModelRepair       $passwordModelRepair
     * @param FolderRevisionRepair      $folderRevisionRepair
     * @param PasswordRevisionRepair    $passwordRevisionRepair
     * @param PasswordTagRelationRepair $passwordTagRelationRepair
     */
    #[Pure] public function __construct(
        ConfigurationService      $config,
        TagModelRepair            $tagModelRepair,
        FolderModelRepair         $folderModelRepair,
        TagRevisionRepair         $tagRevisionRepair,
        EnvironmentService        $environmentService,
        PasswordModelRepair       $passwordModelRepair,
        FolderRevisionRepair      $folderRevisionRepair,
        PasswordRevisionRepair    $passwordRevisionRepair,
        PasswordTagRelationRepair $passwordTagRelationRepair
    ) {
        parent::__construct($config, $tagModelRepair, $folderModelRepair, $tagRevisionRepair, $passwordModelRepair, $folderRevisionRepair, $passwordRevisionRepair, $passwordTagRelationRepair);
        $this->environmentService = $environmentService;
    }

    /**
     * @param IOutput $output
     *
     * @return void
     * @throws \Exception
     */
    public function run(IOutput $output): void {
        if($this->environmentService->getRunType() === EnvironmentService::TYPE_CLI) {
            parent::run($output);
        }
    }
}

I only use php7.4 because i have extensions that only can run 7.4 atm. Thanks

allan-null commented 2 years ago

I only use php7.4 because i have extensions that only can run 7.4 atm.

So I highly recommend you to run Nextcloud Passwords with PHP 8.0, because they dropped support to older versions of PHP. I also had to upgrade the PHP version, because all my password are in this app I couldn't risk losing access to them. What I did on my server is keep a virtual host on Apache only for Nextcloud, so now it uses PHP 8 and my other applications use other versions of PHP.

FabianLPHD commented 2 years ago

I only use php7.4 because i have extensions that only can run 7.4 atm.

So I highly recommend you to run Nextcloud Passwords with PHP 8.0, because they dropped support to older versions of PHP. I also had to upgrade the PHP version, because all my password are in this app I couldn't risk losing access to them. What I did on my server is keep a virtual host on Apache only for Nextcloud, so now it uses PHP 8 and my other applications use other versions of PHP.

You are my hero!!! php8 update fixed the job, with your code. Now i have to compile myself the library that i need, but i think i will get that running. Thank you!!

marius-wieschollek commented 2 years ago

@allan-null Thanks for the hint, i will release an update version soon

@FabianLPHD PHP 7.4 & 7.3 can still be used with the LSR version. But since this version is created automatically, there can be issues if the process misses something. I added a new rule to remove the #[Pure] annotation since this isn't compatible with PHP 7.4

TheRaven500 commented 2 years ago

Same problem here. Finally i downgraded to 2022.1.10. Why are you dropping support for PHP7.4?! Debian 11 Bullseye does not support PHP8. Of course you can update it, but only with additional sources and this is not recommended. The other thing is that i have other services which are not php8 ready ATM. So please bring back php7.4 support. Thanks.

rmbleeker commented 2 years ago

@marius-wieschollek I'm using the LSR version of the passwords app because I'm also stuck at PHP 7.4. Nextcloud just notified me that there was an update for the app to 2022.2.10 so I tried to apply it, which put my instance in maintenance mode. I've only managed to get it out of maintenance mode again by disabling the app.

@TheRaven500 how did you manage to downgrade the app to 2022.1.10?

lyn1337 commented 2 years ago

Same here.

That aside, I do too believe that the php strategy poses a problem to Debian admins. IIRC they only get to pick between 7.4 (which will be unsupported by passwords) and 8.1 - under which NC will absolutely deny to run.

TheRaven500 commented 2 years ago

@TheRaven500 how did you manage to downgrade the app to 2022.1.10?

Not so easy, try it like this (you have to change the path that it match your setup):

  1. Disable the app via cli to bring NC up -> sudo -u www-data php occ app:disable passwords
  2. Make a copy of password app -> cp nextcloud/apps/passwords nextcloud/apps/passwords_backup
  3. Remove the app with the NC GUI (i am very happy that all my passwords was not deleted in this step! phu!)
  4. Download version 2022.1.10 -> wget https://git.mdns.eu/nextcloud/passwords/-/jobs/13439/artifacts/raw/passwords-lsr.tar.gz
  5. Extract and copy it to nextcloud/apps/passwords (Hint: i used "mc" MidnightCommander for this step)
  6. Change permission -> chown www-data -R nextcloud/apps/passwords;chgrp www-data -R nextcloud/apps/passwords

I hope I have not forgotten anything, it was late yesterday. BTW: This was the second or maybe the third time that the password app shot down my NC. Because of that i am a little bit frustrated, sorry. I really hate this coding languages (php, python, java, dotnet...). On every version jump you have to customize your code. Really stupid if you ask me. Since the jump from python 2 to python 3 a lot of tools doesen't work anymore. :-(