1

I have a problem (duhh) with symlinks inside public_html. Everything stopped working after this patch https://github.com/magento/magento2/commit/202ce32dd4bed272a9ddb1a4618fa0e14a179dcb#diff-643a52d0419707fc6b1a9c95a9b5a632

We use our custom solution for deployment. We redeploy static content inside public_html/deployer/releases/... folder.
After all processes are done, we create symbolic links to three folders

public_html/deployer/generated  to
public_html/deployer/releases/88/generated

public_html/deployer/pub/static  to
public_html/deployer/releases/88/pub/static

public_html/deployer/var/view_preproccessed    
public_html/deployer/releases/88/var/view_preproccessed

Problem happens when minified phtml file is checked whether it is exists or not.
Because it is created in the symlinked folder - it is not found and throws an error. Previously, because filename wasn't using realpath() method to get path, it worked perfectly.
Now realpath() extracts symlink path and file is not found.

Example: File: vendor/magento/framework/View/Element/Template/File/Validator.php:138

My testing script.

$realPathNotWorking = "/public_html/deployer/releases/88/var/view_preprocessed/pub/static/vendor/magento/module-theme/view/frontend/templates/page/js/require_js.phtml";

$realPathWorking = "/public_html/var/view_preprocessed/pub/static/vendor/magento/module-theme/view/frontend/templates/page/js/require_js.phtml";



$directories = [
    "/public_html/var/view_preprocessed/pub/static/",
];

foreach ($directories as $directory) {
    if (0 === strpos($realPathNotWorking, $directory)) {
        echo 'Found';
        die;
    }
}
echo 'Not found';

As you can see $realPathNotWorking is got when realpath is used.
$realPathWorking is got when realpath is not used (as it was before patch)

Question What would be a better solution? Add custom solutions like add my custom directory or remove realpath function? Or maybe my custom static content deployment is not logical?

System info:
Magento open source 2.3.1
Php 7.1.28

P.s. I have also read about allow symlinks option in the admin, but since it is not recommended to use on the production env due to security reasons, we are not enabling it.

  • How did you solve that ? – Bernhard Zürn Jan 10 at 12:03
  • @BernhardZürn I haven't solved it yet ( Other tasks moved along and this was postponed) But idea is that I would wrtie a module that would add my directory to the list of available directories. Not sure if this is going to work, but I'm going to try it in the future. – Macas Jan 13 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.