Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page icons not resolving correctly in 4.1.x #2187

Open
colintucker opened this issue Jun 12, 2018 · 2 comments
Open

Page icons not resolving correctly in 4.1.x #2187

colintucker opened this issue Jun 12, 2018 · 2 comments

Comments

@colintucker
Copy link
Contributor

colintucker commented Jun 12, 2018

Affected Version

silverstripe/admin          1.1.1  SilverStripe admin interface
silverstripe/asset-admin    1.1.1  Asset management for the SilverStripe CMS
silverstripe/assets         1.1.1  SilverStripe Assets component
silverstripe/campaign-admin 1.1.1  SilverStripe campaign admin interface
silverstripe/cms            4.1.1  The SilverStripe Content Management System
silverstripe/config         1.0.4  SilverStripe configuration based on YAML and class statics
silverstripe/errorpage      1.1.1  ErrorPage component for SilverStripe CMS
silverstripe/framework      4.1.1  The SilverStripe framework
silverstripe/graphql        1.1.1  GraphQL server for SilverStripe models and other data
silverstripe/reports        4.1.1  Reports module for SilverStripe CMS
silverstripe/siteconfig     4.1.1  Site wide settings administration.
silverstripe/versioned      1.1.1  SilverStripe Versioned component

Description

I noticed after creating a new 4.1 project with the public/ sub-folder that a good number of my page icons have broken in the CMS. All of the objects in question have their $icon defined in module format, i.e.:

private static $icon = 'vendor/module: admin/client/dist/images/icons/PageIcon.png';

...and each module has the admin/client/dist/ folder exposed via composer.json.

Upon investigating the CMS code, it appears the issue lies with when the generatePageIconsCss() method is called from the LeftAndMainPageIconsExtension class. I noticed this method appears to be called twice, once in CMSMain::init() and again in the extension itself, i.e. LeftAndMainPageIconsExtension::init(). Since CMSMain::PAGE_ICONS_ID is used as an identifier, the actual CSS is only generated once by CMSMain.

Now what's weird is, when it's called in CMSMain::init(), it does NOT generate the style classes for my modules. If I comment out that line, and rely on LeftAndMainPageIconsExtension::init(), it DOES generate the correct CSS.

Digging deeper, the generatePageIconsCss() method calls getPageIconURL() on all SiteTree classes. In SiteTree::getPageIconURL(), we can see the resource loader try to find the icon:

$iconResource = ModuleResourceLoader::singleton()->resolveResource($icon);

Now, when CMSMain::init() triggers this code, $iconResource is a string. When LeftAndMainPageIconsExtension::init() triggers it, $iconResource is a ModuleResource. I have no idea why that is happening, but I believe that's why it's breaking.

It probably wasn't noticed before using the separate public/ folder, because the string path still would have resolved in the docroot.

@dajeinc
Copy link

dajeinc commented Aug 8, 2018

This is a problem for me as well. Any solution?

@robbieaverill
Copy link
Contributor

I'm assuming this has been fixed now. Can you confirm @colintucker @dajeinc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants