mxgross / EasyBackupBundle

Kimai 2 Plugin for easier backups
MIT License
24 stars 6 forks source link

Fail during first accesss. #11

Closed roerigdalgaard closed 4 years ago

roerigdalgaard commented 4 years ago

When try to use easybackup first time on a quite fresh KIMAI2 installation the application fails. I can use kimai2 normal but when try to use the easyBackup the server throws an error 500.

Logdump below: [2020-01-07 09:42:11] request.INFO: Matched route "easy_backup". {"route":"easy_backup","route_parameters":{"_route":"easy_backup","_controller":"KimaiPlugin\EasyBackupBundle\Controller\EasyBackupController::indexAction","_locale":"en"},"request_uri":"http://localhost:8080/en/admin/easy-backup","method":"GET"} [] [2020-01-07 09:42:11] security.DEBUG: Read existing security token from the session. {"key":"_security_secured_area","token_class":"Symfony\Component\Security\Core\Authentication\Token\RememberMeToken"} [] [2020-01-07 09:42:11] php.INFO: User Deprecated: Checking for the AdvancedUserInterface in "Symfony\Component\Security\Core\Authentication\Token\AbstractToken::hasUserChanged()" is deprecated since Symfony 4.1 and support for it will be removed in 5.0. Implement the Symfony\Component\Security\Core\User\EquatableInterface to check if the user has been changed, {"exception":"[object] (ErrorException(code: 0): User Deprecated: Checking for the AdvancedUserInterface in \"Symfony\Component\Security\Core\Authentication\Token\AbstractToken::hasUserChanged()\" is deprecated since Symfony 4.1 and support for it will be removed in 5.0. Implement the Symfony\Component\Security\Core\User\EquatableInterface to check if the user has been changed, at /var/www/kimai2/vendor/symfony/security-core/Authentication/Token/AbstractToken.php:325)"} [] [2020-01-07 09:42:11] php.INFO: User Deprecated: Checking for the AdvancedUserInterface in "Symfony\Component\Security\Core\Authentication\Token\AbstractToken::hasUserChanged()" is deprecated since Symfony 4.1 and support for it will be removed in 5.0. Implement the Symfony\Component\Security\Core\User\EquatableInterface to check if the user has been changed, {"exception":"[object] (ErrorException(code: 0): User Deprecated: Checking for the AdvancedUserInterface in \"Symfony\Component\Security\Core\Authentication\Token\AbstractToken::hasUserChanged()\" is deprecated since Symfony 4.1 and support for it will be removed in 5.0. Implement the Symfony\Component\Security\Core\User\EquatableInterface to check if the user has been changed, at /var/www/kimai2/vendor/symfony/security-core/Authentication/Token/AbstractToken.php:325)"} [] [2020-01-07 09:42:11] security.DEBUG: User was reloaded from a user provider. {"provider":"Symfony\Component\Security\Core\User\ChainUserProvider","username":"rdc"} [] [2020-01-07 09:42:11] security.DEBUG: Checking for guard authentication credentials. {"firewall_key":"secured_area","authenticators":1} [] [2020-01-07 09:42:11] security.DEBUG: Checking support on guard authenticator. {"firewall_key":"secured_area","authenticator":"App\Security\TokenAuthenticator"} [] [2020-01-07 09:42:11] security.DEBUG: Guard authenticator does not support the request. {"firewall_key":"secured_area","authenticator":"App\Security\TokenAuthenticator"} [] [2020-01-07 09:42:11] php.CRITICAL: Class 'Symfony\Component\Process\Process' not found {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Class 'Symfony\Component\Process\Process' not found at /var/www/kimai2/var/plugins/EasyBackupBundle/Controller/EasyBackupController.php:333)"} [] [2020-01-07 09:42:20] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\ClassNotFoundException: "Attempted to load class "Process" from namespace "Symfony\Component\Process". Did you forget a "use" statement for another namespace?" at /var/www/kimai2/var/plugins/EasyBackupBundle/Controller/EasyBackupController.php line 333 {"exception":"[object] (Symfony\Component\Debug\Exception\ClassNotFoundException(code: 0): Attempted to load class \"Process\" from namespace \"Symfony\Component\Process\".\nDid you forget a \"use\" statement for another namespace? at /var/www/kimai2/var/plugins/EasyBackupBundle/Controller/EasyBackupController.php:333)"} [] [2020-01-07 09:42:20] security.DEBUG: Stored the security token in the session. {"key":"_security_secured_area"} []

mxgross commented 4 years ago

Hey, thanks for reporting. There seems to be some problem with the usage of 'Process' even if the right use statement is defined in the controller: use Symfony\Component\Process\Process;

Please can you provide some more information about your system:

And you could try to run composer update and composer require symfony/process maybe.

Thanks

kevinpapst commented 4 years ago

Sorry, I didn't notice that as well, but when I install composer without dev dependencies, symfony/process will be removed:

composer install --no-dev
Loading composer repositories with package information
Installing dependencies from lock file
Package operations: 0 installs, 0 updates, 51 removals
  - Removing theseer/tokenizer (1.1.3)
  - Removing symfony/process (v4.3.9)
  - Removing symfony/phpunit-bridge (v4.4.2)
  - Removing symfony/maker-bundle (v1.14.3)
  - Removing symfony/dom-crawler (v4.3.9)
  ...

You could rewrite the plugin to use the native functions like exec, passthru, shell_exec and system.

mxgross commented 4 years ago

Thanks a lot Kevin! I will try to provide a fix as soon as possible, maybe this evening, maybe in a few days.

A fast workaround for @roerigdalgaard may be to edit the Easybackup/Bundle/composer.json and add a require entry for process as mentioned in this example: https://github.com/lukaswhite/screenshotter/issues/3

kevinpapst commented 4 years ago

Don't mess with the composer settings from Kimai, this will only lead to unpredictable update problems and more support requests in my repo ;-)

mxgross commented 4 years ago

I updated the composer.json but cannot test it. Can anyone of you verify if it is working now? I added a entry: "require": { "kimai/kimai2-composer": "*", "symfony/process": "~4.3.9" },

Maybe it helps as shorttime workaround.

mxgross commented 4 years ago

Sorry Kevin, I meant the plugins composer.json, or would this be useless. I don't know.

kevinpapst commented 4 years ago

Useless, as this composer.json is currently not used during the normal composer installation. Better solution is to fix it properly in the bundle - I guess @roerigdalgaard can wait a bit longer

mxgross commented 4 years ago

@kevinpapst I implemented a fix but when I'm testing the plugin in a production installation/environment, then I receive another error now:

CRITICAL  [php] Class 'App\Plugin\AbstractPluginExtension' not found ["exception" => Symfony\Component\Debug\Exception\FatalThrowableError^ { …}]

In EasyBackupExtension.php line 18:

  Attempted to load class "AbstractPluginExtension" from namespace "App\Plugi  
  n".                                                                          
  Did you forget a "use" statement for another namespace?  

But as far as I can see, my use statement looks okay and I compared many classes to the ones to other plugins but did not find any solution. use App\Plugin\AbstractPluginExtension;

kevinpapst commented 4 years ago

This class is rather new. If your production environment is not latest version, then it might simply not exist?! Did you check your filesystem if it is there?

Edit: or do you mean you simply switched to APP_ENV=prod ?

mxgross commented 4 years ago

Oh okay, I didn't expect that this class is so new. You are right It doesn't exist in my prod installation yet. I will try to update my prod environment installation and test it again, but this issue should then be resolved already.

roerigdalgaard commented 4 years ago

Thanks.

Removed old version and installed new one and it works now 😊

Med venlig hilsen

Martin Rörig-Dalgaard

Martin Rörig-Dalgaard

Gl Amtsvej 7

DK-3450 Allerød

www.roerig-dalgaard.dk

Tel.: +45 45 88 20 28

Mob.: +45 29 90 37 70

mailto:martin@roerig-dalgaard.dk martin@roerig-dalgaard.dk

www.FlyingEye.dk

Fra: mgross notifications@github.com Sendt: 7. januar 2020 18:17 Til: mxgross/EasyBackupBundle EasyBackupBundle@noreply.github.com Cc: roerigdalgaard martin@roerig-dalgaard.dk; Mention mention@noreply.github.com Emne: Re: [mxgross/EasyBackupBundle] Fail during first accesss. (#11)

Oh okay, I didn't expect that this class is so new. You are right It doesn't exist in my prod installation yet. I will try to update my prod environment installation and test it again, but this issue should then be resolved already.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mxgross/EasyBackupBundle/issues/11?email_source=notifications&email_token=ANLDXPLGFZZ345OW2RPM46DQ4S2HRA5CNFSM4KDUZ6N2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIJTFKQ#issuecomment-571683498 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ANLDXPMHK6UYT6VKHG2UMWDQ4S2HRANCNFSM4KDUZ6NQ . https://github.com/notifications/beacon/ANLDXPLAYCWOYMB2RZ6C5VLQ4S2HRA5CNFSM4KDUZ6N2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIJTFKQ.gif