0

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.

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.