Skip to content

false-negative "Invaild template file" #3802

@tlaziuk

Description

@tlaziuk

While using the modman I issued error which occurs when a module is placed somewhere outside the Magento 2 root directory. This is not the modman-related things because it can be reproduced to any module which is placed outside the Magento 2 root.

I found out the Magento2 fails where the template is validating against isFile (at \Magento\Framework\View\Element\Template\File\Validator::isValid).

I've also managed to fix that by changing the \Magento\Framework\Filesystem\Directory\Read::isFile method which is used to validate the template file. The problem is that method by default is joining the passed argument $path with the Magento 2 root, while the template file symlink is a resolved path to the real file.

You can preview my changes in the diff file.

Preconditions

  1. Magento 2.

Steps to reproduce

  1. Create module which is using frontend templates and place the code somewhere outside the Magento 2 root directory, but symlink the code to the place under Magento 2 project where it should be.
  2. Setup your new module.

Expected result

  1. If the template file is valid, everything should be working

Actual result

  1. system.log message: main.CRITICAL: Invalid template file: '/home/tlaziuk/git/Example_Module/view/frontend/templates/example.phtml' in module: 'Polcode_GoogleTagManager' block's name: 'googletagmanager' [] []

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: FrontendIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasebug reporttriage wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions