eZ Community » Forums » eZ Publish 5 Platform » ConfigResolver and console command...
expandshrink

ConfigResolver and console command siteaccess issue

ConfigResolver and console command siteaccess issue

Saturday 11 July 2015 6:34:42 am - 4 replies

I have the created the above command and when running I have an issue with:

Argument 'BinaryFile::id' is invalid: 'var/consumer_site/storage/images/sitedefault/media/hello/1548-1-eng-CA/hello.jpg' is wrong value in class 'BinaryFile' 

Tracking this down it looks like eZ\Publish\Core\IO\UrlDecorator\Prefix is not getting the correct prefix from the config resolver.  It is getting var/storage instead of the var/consumer_site/storage from the default siteaccess as the prefix.
Here are the relevant site access settings:

ezpublish:
    siteaccess:
        default_siteaccess: eng
        groups:
            consumer_site_group:
                - eng

    system:
        consumer_site_group:
            var_dir: var/consumer_site
        eng:
            languages:
                - eng-CA

If I uncomment out the code in the command to show what the active site access is it is correct.

Any ideas why this is happening?  Is there an issue with the configresolver and the cli?

Tuesday 14 July 2015 8:58:50 am

I believe it is not not about ConfigResolver.

Similar problem was found in issue tracker: https://jira.ez.no/browse/EZP-23470

I've made a workaround to continue with my task in the file vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/IO/UrlDecorator/Prefix.php

Line 35:

$this->prefix = rtrim( $prefix, '/' ) . '/';

Of course it would be better to fix it properly and create a pull request, but I'm not sure that my solution doesn't break something else.

Tuesday 14 July 2015 9:02:57 pm

I get this same issue regardless of line 35 uses trim or rtrim.

on line 55 of vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/IO/UrlDecorator/Prefix.php the prefix that is being looked for is var/storage yet it should be var/consumer_site/storage.  This is why I suspect the configresolver.  It is using the value of ezsettings.default.io.legacy_url_prefix which is defined as ezsettings.default.io.legacy_url_prefix: "$var_dir$/$storage_dir$".  So for some reason $var_dir$ is not resolving to the var_dir defined in the the site access even though I can confirm the correct siteaccess is matched.

To test I have created the command

The out put shows the site has been matched but the wrong io.legacy_url_prefix is returned.

Tuesday 14 July 2015 10:15:47 pm

I believe I have found the issue. When siteaccess set commands do not dispatch the DynamicSettingsListener.  If I add the following to my script it works.

 
 
/** @var </span><span>$eventDispatcher EventDispatcher */
$eventDispatcher = $this->getContainer()->get( 'event_dispatcher' );
$eventDispatcher->dispatch( MVCEvents::CONFIG_SCOPE_CHANGE, new ScopeChangeEvent( $sa ) );

Modified on Tuesday 14 July 2015 10:17:31 pm by Douglas Hammond

Tuesday 28 July 2015 11:22:54 am

Hi,

I've had a similar issue, because I forgot to add my admin siteaccess to the siteaccess group where I declared the new var directory in the yml.

Hope that helps...

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from