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

Unable to save page and block changes using Page Builder with enabled js minification. #25620

Closed
LordHansolo opened this issue Nov 15, 2019 · 29 comments
Labels
Adobe Commerce The issue related to the Adobe Commerce(EE) or B2B functionality Area: Content Component: PageBuilder Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.3.3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@LordHansolo
Copy link

LordHansolo commented Nov 15, 2019

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.
@m2-assistant
Copy link

m2-assistant bot commented Nov 15, 2019

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

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Nov 15, 2019
@LordHansolo LordHansolo changed the title Unable to save Pages and Blocks changes using Page Builder with enabled js minification. Unable to save pages and blocks changes using Page Builder with enabled js minification. Nov 15, 2019
@LordHansolo LordHansolo changed the title Unable to save pages and blocks changes using Page Builder with enabled js minification. Unable to save page and block changes using Page Builder with enabled js minification. Nov 15, 2019
@engcom-Echo engcom-Echo self-assigned this Nov 18, 2019
@m2-assistant
Copy link

m2-assistant bot commented Nov 18, 2019

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: 👇

  • 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.

@engcom-Echo engcom-Echo removed their assignment Nov 18, 2019
@sdzhepa
Copy link
Contributor

sdzhepa commented Nov 18, 2019

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.

@mugua
Copy link

mugua commented Dec 14, 2019

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?

@LordHansolo
Copy link
Author

LordHansolo commented Dec 14, 2019

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.

@mugua
Copy link

mugua commented Dec 14, 2019

@LordHansolo, Could you add my Skype: john.lou@msn.com or offer yours, Thanks.
I have a little confuse about this, Thanks.

@theCapypara
Copy link
Member

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

@kushaljindal92
Copy link

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

@dfelton
Copy link
Contributor

dfelton commented Jan 14, 2020

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

@theCapypara
Copy link
Member

@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.

@vbuck
Copy link

vbuck commented Jan 17, 2020

@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.

@minhducnho
Copy link

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

@sdouma
Copy link

sdouma commented Apr 16, 2020

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

@sunilit42
Copy link
Contributor

@minhducnho any solution

@aamoronatti
Copy link

It's happening to me in Magento 2.4.6

@rejith7
Copy link

rejith7 commented Apr 27, 2023

Issue reported in 2.4.5 EE, especially while using google chrome with magento running on production mode and minified js enabled.

@rejith7
Copy link

rejith7 commented May 2, 2023

@anton-vidext did you use google chrome ? can you try using firefox? I'm beginning to think it's browser related issue

@aamoronatti
Copy link

@anton-vidext did you use google chrome ? can you try using firefox? I'm beginning to think it's browser related issue

I used google chrome, firefox and edge. It was happening in every browser.

Disabled minified JS and CSS and I can now save page builder content.

@Hurrpadurr
Copy link

Issue reported in 2.4.5 EE, especially while using google chrome with magento running on production mode and minified js enabled.

This is excatly what happens for me. Disabling minified doesn't help for me, but it only happens on Chrome.

@VitaliyBoyko VitaliyBoyko reopened this May 9, 2023
@m2-community-project m2-community-project bot removed the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label May 9, 2023
@m2-community-project m2-community-project bot added this to Ready for Confirmation in Issue Confirmation and Triage Board May 9, 2023
@engcom-November engcom-November added Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Component: PageBuilder Area: Content Adobe Commerce The issue related to the Adobe Commerce(EE) or B2B functionality labels May 15, 2023
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Confirmed in Issue Confirmation and Triage Board May 15, 2023
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-8773 is successfully created for this GitHub issue.

@m2-assistant
Copy link

m2-assistant bot commented May 15, 2023

✅ Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@engcom-November engcom-November added the Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. label May 15, 2023
@m2-community-project m2-community-project bot added this to Ready for Development in High Priority Backlog May 15, 2023
@Bilalyounas1234
Copy link

Hi @LordHansolo Could you please explain about the

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

Why did you add this in render.phtml because I have seen this template but I have not seen the script "<script src="escapeUrl($block->getRequireJsUrl()); ?>"></script>" in this template maybe Magento remove this script from the latest version. if you can let me know the reason why you add this code then may I fix it in latest version thanks in advance

@LordHansolo
Copy link
Author

LordHansolo commented Jun 9, 2023

Hello @Bilalyounas1234

In Magento 2.3.3 EE the render template probably looked like in the link below.

https://github.com/magento/magento2-page-builder/blob/v1.1.0/app/code/Magento/PageBuilder/view/adminhtml/templates/stage/render.phtml

Additionally You can see the Controller and the Block classes in version 1.6.0 looks different compared to version 1.1.0.
Below I provide links to the render template, Render Block and Render Controller in version 1.1.0 and 1.6.0.

v.1.1.0

v.1.6.0

Looking at the solution I provided for Page Builder in Magento 2.3.3 EE, the code below was required to load min resolver in case js minification was enabled.

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

@github-jira-sync-bot github-jira-sync-bot added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. and removed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. labels Nov 6, 2023
@github-jira-sync-bot github-jira-sync-bot added Progress: PR Created Indicates that Pull Request has been created to fix issue and removed Progress: ready for grooming labels Dec 11, 2023
@engcom-Bravo
Copy link
Contributor

Hi @LordHansolo,

Tested on the latest 2.4-develop version. Enabled “Minify JavaScript Files” in the JavaScript Settings of Store Configuration. In production mode, attempted to edit a Block/Page and save it. Despite multiple edits, changes were successfully saved. After exhaustive attempts to reproduce this issue, it has been determined that the problem is no longer reproducible. Hence we are closing this issue.

Screen.Recording.2023-12-11.at.1.21.52.PM.mov

Thanks.

@m2-community-project m2-community-project bot moved this from Ready for Development to Done in High Priority Backlog Dec 11, 2023
@m2-community-project m2-community-project bot added Progress: done and removed Progress: PR Created Indicates that Pull Request has been created to fix issue labels Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Adobe Commerce The issue related to the Adobe Commerce(EE) or B2B functionality Area: Content Component: PageBuilder Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.3.3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Development

No branches or pull requests