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

Fix race condition where ComponentTemplateParser.php.inc can be loaded instead of ComponentTemplateParser.php, causing the custom template code to not work. #13

Closed
silbinarywolf opened this issue May 18, 2018 · 1 comment

Comments

@silbinarywolf
Copy link
Contributor

silbinarywolf commented May 18, 2018

The problem
The class manifest is scanning the module directory for classes. However it seems that it's scanning both ComponentTemplateParser.php and ComponentTemplateParser.php.inc (used to generate *.php version).

It will sometimes use that class instead of the generated class, causing templates to not load/work properly. This can result in ArrayData / SS_List calling forTemplate() errors in a way that's incredibly hard to debug.

EDIT: It seems whats happening is the PSR-4 autoload of Composer is picking up the .php.inc file. The SilverStripe class manifest scanner only works on *.php files.

The solution
Rename ComposerTemplateParser.php.inc to ComposerTemplateParser.peg. This is what SilverStripe 4+ does and this should stop the ClassManifest from picking up the file.

.gitattributes also needs to be updated to ignore exporting the newly renamed *.peg file.

Affected versions

  • 1.0.0 (SilverStripe 3)
  • 2.0.0 (SilverStripe 4)
@silbinarywolf silbinarywolf changed the title Move .inc file outside of code area to avoid it being picked up by config manifest Fix race condition where ComponentTemplateParser.php.inc can be loaded instead of ComponentTemplateParser.php, causing the custom template code to not work. May 19, 2018
silbinarywolf added a commit that referenced this issue May 19, 2018
…teParser.php.inc can be loaded instead of ComponentTemplateParser.php, causing the custom template code to not work. - Github Issue #13
silbinarywolf added a commit that referenced this issue May 19, 2018
…teParser.php.inc can be loaded instead of ComponentTemplateParser.php, causing the custom template code to not work. - Github Issue #13
silbinarywolf added a commit that referenced this issue May 19, 2018
…teParser.php.inc can be loaded instead of ComponentTemplateParser.php, causing the custom template code to not work. - Github Issue #13
silbinarywolf added a commit that referenced this issue May 19, 2018
…teParser.php.inc can be loaded instead of ComponentTemplateParser.php, causing the custom template code to not work. - Github Issue #13
silbinarywolf added a commit that referenced this issue May 19, 2018
…teParser.php.inc can be loaded instead of ComponentTemplateParser.php, causing the custom template code to not work. - Github Issue #13
@silbinarywolf
Copy link
Contributor Author

This is now fixed in:

  • 1.0.1 (SilverStripe 3)
  • 2.0.1 (SilverStripe 4)

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

No branches or pull requests

1 participant