Magento2: Unable to save page and block changes using Page Builder with enabled js minification.

Created on 15 Nov 2019  路  13Comments  路  Source: magento/magento2

Preconditions (*)

  1. Magento 2.3.3 EE

Steps to reproduce (*)

  1. Stores->Settings->Configuration->Advanced->Developer->JavaScript Settings->Minify JavaScript Files = Yes
  2. Set production bin/magento deploy:mode:set production
  3. Go to Content->Elements->Blocks\Pages->Edit
  4. Make changes and Save

Expected result (*)

  1. Possibility to edit and save blocks and pages.

Actual result (*)

  1. Changes are not saved.

Additional Information

  1. I can see in browser console that Page Builder tries to load not minified resources. Since we have js minification enabled in static content exists only minified js.
Format is valid

Most helpful comment

@sdzhepa I just want to thank you for carefully responding to the OP about this issue. There has been a habit of closing issues raised that mention Commerce Edition. Instead you chose to provide guidance _anyway_, and I think that's an example for Adobe to follow when dealing with the community, since Open-Source and Commerce are (for the time being) very closely related.

All 13 comments

Hi @LordHansolo. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@LordHansolo do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

Hi @engcom-Echo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

Hello @LordHansolo

Thank you for contribution and collaboration!

This issue related to Page Builder functionality which is not part of Magento Open Source.

Current repository and issue tracker aimed at Magento Open Source version only and the main focus is community contribution/collaboration. It described in Issue reporting guidelines and it is a part of the issue report template:

Verify, that the issue you are about to report does not relate to the Magento Commerce. GitHub is intended for Magento Open Source users to report on issues related to Open Source only. There are no account management services associated with GitHub. You can report Commerce-related issues in one of two ways:

  • You can use the Support portal associated with your account
  • If you are a Partner reporting on behalf of a merchant, use the Partner portal.

But I have asked internal Magento team(who is working on Page Builder) about this issue and

  • This issue has been fixed and will be available with next release 2.3.4
  • The same issue was reported into the private repository related to Page Builder on Oct 25 2019 and was fixed and delivered with internal Pull Request #304.

Preconditions (*)

  1. Magento 2.3.3 EE

Steps to reproduce (*)

  1. Stores->Settings->Configuration->Advanced->Developer->JavaScript Settings->Minify JavaScript Files = Yes
  2. Set production bin/magento deploy:mode:set production
  3. Go to Content->Elements->Blocks\Pages->Edit
  4. Make changes and Save

Expected result (*)

  1. Possibility to edit and save blocks and pages.

Actual result (*)

  1. Changes are not saved.

Additional Information

  1. I can see in browser console that Page Builder tries to load not minified resources. Since we have js minification enabled in static content exists only minified js.

Hi Lordhansolo
Have you fixed this issue now?

Thank You @sdzhepa.
Hello @mugua.
Yes I fixed it. I will provide You part of code and places where they should appear.

In my module I created block that extends Magento\PageBuilder\Block\Adminhtml\Stage\Render and adds two additional methods isJsMinificationEnabled and getMinResolverAssetUrl.

<?php

namespace Fix\PageBuilder\Block\Adminhtml\Stage;

use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\View\Asset\Minification;
use Magento\Framework\View\Element\Template\Context;
use Magento\PageBuilder\Block\Adminhtml\Stage\Render as ParentRender;
use Magento\PageBuilder\Model\Stage\Config;
use Magento\RequireJs\Model\FileManager;

/**
 * Class Render
 */
class Render extends ParentRender
{
    /**
     * @var FileManager
     */
    private $fileManager;

    /**
     * @var Minification
     */
    private $minification;

    /**
     * Class constructor
     *
     * @param Context $context
     * @param FileManager $fileManager
     * @param Config $config
     * @param Json $json
     * @param Minification $minification
     * @param array $data
     */
    public function __construct(
        Context $context,
        FileManager $fileManager,
        Config $config,
        Json $json,
        Minification $minification,
        array $data = []
    ) {
        parent::__construct($context, $fileManager, $config, $json, $data);

        $this->fileManager = $fileManager;
        $this->minification = $minification;
    }

    /**
     * Check that js minification is enabled
     *
     * @return boolean
     */
    public function isJsMinificationEnabled()
    {
        return $this->minification->isEnabled('js');
    }

    /**
     * Get min resolver asset url
     *
     * @return string
     */
    public function getMinResolverAssetUrl()
    {
        $minResolver = $this->fileManager->createMinResolverAsset();
        $url = $minResolver ? $minResolver->getUrl() : '';

        return $url;
    }
}

Next I created template in My module scope view/adminhtml/templates/stage/render.phtml with content from <magento_root>/vendor/magento/module-page-builder/view/adminhtml/templates/stage/render.phtml and add code below after <script src="<?= $block->escapeUrl($block->getRequireJsUrl()); ?>"></script>.

<?php if ($block->isJsMinificationEnabled()) : ?>
    <script src="<?= $block->escapeUrl($block->getMinResolverAssetUrl()); ?>"></script>
<?php endif ?>

Next I created Controller that extends Magento\PageBuilder\Controller\Adminhtml\Stage\Render. Copy entire execute method and override part below.

$renderBlock = $layout->createBlock(
    \Fix\PageBuilder\Block\Adminhtml\Stage\Render::class,
    'stage_render'
);
$renderBlock->setTemplate('Fix_PageBuilder::stage/render.phtml');

Next I created adminhtml/di.xml to set preference for Magento\PageBuilder\Controller\Adminhtml\Stage\Render.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\PageBuilder\Controller\Adminhtml\Stage\Render" type="Fix\PageBuilder\Controller\Adminhtml\Stage\Render" />
</config>

Next in module.xml I add Magento_PageBuilder to sequence.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Fix_PageBuilder" setup_version="1.0.0">
        <sequence>
            <module name="Magento_PageBuilder"/>
        </sequence>
    </module>
</config>

Thats all. Now Page Builder should work fine with enabled js minification.

@LordHansolo, Could you add my Skype: john.[email protected] or offer yours, Thanks.
I have a little confuse about this, Thanks.

@mugua @LordHansolo If you have an active Magento Commerce subscription you can just ask the Commerce support and they'll send you a patch.

I have made module based on @LordHansolo reply,, it is working perfectly.
https://github.com/kushaljindal92/magentoee-pagebuilder-fix

@Parakoopa Is this patch not listed in the Downloads section our accounts on Magento.com?

@dfelton As far as I know you have to open a support ticket and reference this GitHub issue. That's what we did and they sent us a patch.

@sdzhepa I just want to thank you for carefully responding to the OP about this issue. There has been a habit of closing issues raised that mention Commerce Edition. Instead you chose to provide guidance _anyway_, and I think that's an example for Adobe to follow when dealing with the community, since Open-Source and Commerce are (for the time being) very closely related.

Does anyone have a patch to fix this, I have try to fix it but it still doesn't work? I have used @kushaljindal92's module but it only fix js errors, it still can't save

Does Magento just not test? It seems pretty common for production instances to minify js files.

Was this page helpful?
0 / 5 - 0 ratings