BlackbitDigitalCommerce / pimcore-data-director

Import Bundle for Pimcore
16 stars 3 forks source link

Call to a member function isAllowed() on null #49

Open betterapp opened 2 years ago

betterapp commented 2 years ago

On one project we use DD 2.8.7.

When we manually try to start DataPort we got message:

Call to a member function isAllowed() on null

BlackbitDevs commented 2 years ago

Please update to latest stable. We do not support 2.8 anymore. Or is there a reason why you do not update?

betterapp commented 2 years ago

We have such configuration. Will it work without change in 3.X ?

image image

BlackbitDevs commented 2 years ago

Yes, everything which worked in version 2. also works in 3. - we only released a new major version because we introduced the new saving mechanism which is much faster than Pimcore's default saving mechanism. But for existing dataports the "legacy mode" will be enabled and thus Pimcore's default saving mechanism will get used.

Beware that the data query selector FileSystemPath will only work in Pimcore < 10 because with the flysystem support for asset storage, the getFileSystemPath() method got removed. Currently thinking about supporting it anyway in Data Director for backwards compatibility if local storage is used with Flysystem... Alternatively you could use data query selector "url" to get the URL of the asset. This can also be assigned to the Stream field for imports with target class Asset.

betterapp commented 2 years ago

After upgrade to 3.1.4 I get error in log:

[2022-09-06 08:34:10] php.CRITICAL: Uncaught Error: Class 'Composer\InstalledVersions' not found {"exception":"[object] (Error(code: 0): Class 'Composer\InstalledVersions' not found at /var/www/el.pimcore/www/vendor/blackbit/data-director/Controller/ImportController.php:493)"} []

When I open old DataPort I get: image

We do not use Composer 2.

BlackbitDevs commented 2 years ago

Since 3.1.5 there is a fallback class at vendor/blackbit/data-director/fallback/Composer/InstalledVersions.php which gets used if not Composer 2 gets used. Any reason why you did not update to latest stable 3.1.14?

betterapp commented 2 years ago

I will update it.

betterapp commented 2 years ago

I have a problem. When I try to upgrade to 3.1.15 I got error on clearCache

Pimcore\Composer::clearCache

Fatal error: Uncaught Symfony\Component\Debug\Exception\UndefinedMethodException: Attempted to call an undefined method named "getRawData" of class "Composer\InstalledVersions". in /home/daniel/Web/extra.pim/vendor/friendsofphp/proxy-manager-lts/src/ProxyManager/Generator/Util/IdentifierSuffixer.php:60 Stack trace:

0 /home/daniel/Web/extra.pim/vendor/friendsofphp/proxy-manager-lts/src/ProxyManager/Generator/Util/IdentifierSuffixer.php(41): ProxyManager\Generator\Util\IdentifierSuffixer::loadBaseHashSalt()

1 /home/daniel/Web/extra.pim/vendor/friendsofphp/proxy-manager-lts/src/ProxyManager/ProxyGenerator/PropertyGenerator/PublicPropertiesMap.php(25): ProxyManager\Generator\Util\IdentifierSuffixer::getIdentifier()

2 /home/daniel/Web/extra.pim/vendor/friendsofphp/proxy-manager-lts/src/ProxyManager/ProxyGenerator/LazyLoadingValueHolderGenerator.php(71): ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap->__construct()

3 /home/daniel/Web/extra.pim/vendor/symfony/symfony/src/Symfony/Br in /home/daniel/Web/extra.pim/vendor/friendsofphp/proxy-manager-lts/src/ProxyManager/Generator/Util/IdentifierSuffixer.php on line 60

BlackbitDevs commented 2 years ago

Hmm, never had this. Can you simply call rm -rf <Pimcore root folder>/var/cache/* and afterwards try again bin/console cache:clear. Sometimes the Symfony cache is damaged which prevents even bin/console cache:clear to work properly.

betterapp commented 2 years ago

It will not help.

Your fallback function have only one method:

`<?php

namespace Composer;

use Pimcore\Version;

class InstalledVersions { public static function getVersion() { return Version::getVersion(); } } `

And In our cases this code is runned:

` if (! class_exists(InstalledVersions::class)) { return self::class; }

    return sha1(serialize(
        method_exists(InstalledVersions::class, 'getAllRawData')
            ? InstalledVersions::getAllRawData() // Composer >= 2.0.14
            : InstalledVersions::getRawData()
    ));

`

BlackbitDevs commented 2 years ago

You will have to change your code to

if (! class_exists(InstalledVersions::class) || !method_exists(InstalledVersions::class, 'getRawData')) {
    return self::class;
}

Alternatively I could mock all the functions from InstalledVersions class. But would this help you (e.g. InstalledVersions::getRawData() would return [] then). I think it makes more sense if you changed your code.

betterapp commented 2 years ago

But this is not my code but some package code.

BlackbitDevs commented 2 years ago

Ok, I will change the DD code to not use the fallabck class but will add a wrapper class which checks if InstalledVersions exists and if it does, then use it, otherwise return Version::getVersion();...

betterapp commented 2 years ago

let's check this out

betterapp commented 2 years ago

when it will be available for production ?

BlackbitDevs commented 2 years ago

Have just released 3.1.16 which does not create the fallback class for Composer\InstalledVersions anymore.

betterapp commented 2 years ago

Hmm.

Now when I open DataPort (or when I save it) I got the same error like before:

image

betterapp commented 2 years ago

When I run the dataport the log is not created but dataport is runned.

BlackbitDevs commented 2 years ago

Do you have a call stack? Perhaps I have missed one spot.

Edit: Indeed, I forgot one. Have updated 3.1.16, please try again.

betterapp commented 2 years ago

Can You push this change as new TAG ?

BlackbitDevs commented 2 years ago

Done, please try 3.1.17

betterapp commented 2 years ago

Working. Thanks!