Skip to content

Incorrect package assumptions cause errors #2

@dcentrica

Description

@dcentrica

silverstripe/framework 5.2.22
goldfinch/enchantment 1.0.20
silverstripe/admin 2.2.13

In a minimal Silverstripe project (see versions above) which does not use following packages, you'll see several errors emitted from EnchantmentAssetsExtension. Other projects will/won't use an entirely different set of packages:

  • silverstripe-versioned-admin
  • silverstripe/cms
  • silverstripe/session-manager

This happens because there are no guards wrapped around every call to Requirements::block() .

Solutions:

1). Wrap all such code-blocks with:

if (
    InstalledVersions::isInstalled(
        'silverstripe/cms',
    )
) {
    Requirements::block(
        'silverstripe/cms: client/dist/styles/bundle.css',
    );
}
  1. Or remove all such code-blocks and allow userland config to control using config system instead, ala:
Goldfinch\Enchantment\Extensions\EnchantmentAssetsExtension:
    block_packages:
        - 'silverstripe-versioned-admin'
        - 'silverstripe/cms'
        - 'silverstripe/session-manager'
foreach ($this->config()->get('block_packages') as $packageName) {
    if (InstalledVersions::isInstalled($packageName)) {
        Requirements::block(sprintf('%s:client/dist/styles/bundle.css', $packageName));
        Requirements::block(sprintf('%s:client/dist/css/GroupedCmsMenu.css', $packageName));
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions