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

The famous <ul id="admin_messages">MESSAGE HERE</ul> #940

Closed
elfeffe opened this issue Sep 11, 2015 · 32 comments
Closed

The famous <ul id="admin_messages">MESSAGE HERE</ul> #940

elfeffe opened this issue Sep 11, 2015 · 32 comments

Comments

@elfeffe
Copy link

elfeffe commented Sep 11, 2015

I have Magento 1.9.1 and Turpentine 0.6.5, with Ultimo Theme.

And I have the same issue as some people had #112 #153. But that issues are from 2013, I don't believe they are not fixed yet.

When I post a review I get

<ul id="admin_messages">MESSAGE HERE</ul>

Is there any way to fix this?
I don't have that error if I disable Turpentine.

My turpentine_esi.xml looks like

 <reference name="global_messages">
            <action method="setEsiOptions">
                <params>
                <method>esi</method>
                    <access>private</access>
                    <flush_events>
                        <core_session_abstract_add_message/>
                    </flush_events>
                </params>
            </action>
        </reference>
    <reference name="messages">
            <action method="setEsiOptions">
                <params>
                <method>esi</method>
                <access>private</access>
                    <flush_events>
                        <core_session_abstract_add_message/>
                    </flush_events>
                </params>
            </action>
        </reference>

Any help will be really appretiated, I'm getting crazy with this.

@miguelbalparda
Copy link
Contributor

I think the fix for this issue is in the devel branch. How did you get Turpentine? Can you please download the devel branch and see if the error persists?

@elfeffe
Copy link
Author

elfeffe commented Sep 11, 2015

Nope, I will explain. Ihave installed it using git, I have switched to devel branch now and.

  1. with this
        <reference name="global_messages">
            <action method="setEsiOptions">
                <params>
                    <method>ajax</method>
                    <access>private</access>
                    <flush_events>
                        <core_session_abstract_add_message/>
                    </flush_events>
                    <only_cache_if>empty</only_cache_if>
                </params>
            </action>
        </reference>
        <reference name="messages">
            <action method="setEsiOptions">
                <params>
                    <method>ajax</method>
                    <access>private</access>
                    <flush_events>
                        <core_session_abstract_add_message/>
                    </flush_events>
                    <only_cache_if>empty</only_cache_if>
                </params>
            </action>
        </reference>

And this
1232f17b3b6d83f0d53875a8713cec70

The block refreshes with ajax and creates this code

<div class="col-main">
                        <!-- AJAX START [global_messages] -->
<div id="turpentine-esi-block-adcb2807a97f6084b951516cc1890a79b7339481fbdcdf10f65fafb6767fce9a"><ul id="admin_messages">Tu opinión ha sido aceptada y enviada para su revisión.</ul></div><!-- AJAX END [global_messages] -->
                        <div id="newsletterajax"></div>


<script type="text/javascript">
    var optionsPrice = new Product.OptionsPrice([]);
</script>
<div id="messages_product_view"><!-- AJAX START [messages] -->
<div id="turpentine-esi-block-59d82f41339ead2a8c2f6d7c21156b41f23f11c47d56b0013c11ff11bd74dd61"></div><!-- AJAX END [messages] -->
</div>

The HTML is wrong the generated message is

<ul id="admin_messages">Tu opinión ha sido aceptada y enviada para su revisión.</ul>
  1. If I leave the ESI xml using Ajax method, but I switch "Enable AJAX Flash Messages" to Disable
    4405d13864b684fafba7c1d50ad471e6

The generated html is

<ul class="messages"><li class="success-msg"><ul><li><span>Tu opinión ha sido aceptada y enviada para su revisión.</span></li></ul></li></ul>

Its ok, but the content is cached and there is no way to refresh it, everytime I visit the product, I get the message

  1. If I switch method to ESI instead of AJAX, and I leave "Enable AJAX Flash Messages" as DISABLED, generated html is correct
<ul class="messages"><li class="success-msg"><ul><li><span>Tu opinión ha sido aceptada y enviada para su revisión.</span></li></ul></li></ul>

But, again, I see the message everytime. It never refreshes
I tried changing to

    <reference name="global_messages">
            <action method="setEsiOptions">
                <params>
                    <method>esi</method>
                    <access>private</access>
                    <flush_events>
                        <core_session_abstract_add_message/>
                    </flush_events>
                    <only_cache_if>no_text</only_cache_if>
                </params>
            </action>
        </reference>
        <reference name="messages">
            <action method="setEsiOptions">
                <params>
                    <method>esi</method>
                    <access>private</access>
                    <flush_events>
                        <core_session_abstract_add_message/>
                    </flush_events>
                    <only_cache_if>no_text</only_cache_if>
                </params>
            </action>
        </reference>

Note the change in "only_cache_if" section
But nothing, it never refreshes.
I also tried applying

<ttl>0</ttl>

But the cache never refreshes

It only refreshes cache if you set method to AJAX and Enable AJAX Flash Messages, but it returns incorrect HTMl as in master branch.

@elfeffe
Copy link
Author

elfeffe commented Sep 12, 2015

I discovered how it works.
What " Enable AJAX Flash Messages" really means is "Use Nexcessnet_Turpentine_Block_Core_Messages class or not", it runs even if the block is AJAX or ESI.

 <ul id="admin_messages">MESSAGE HERE</ul>

And also cache the result
Is there any fix for this?

@elfeffe
Copy link
Author

elfeffe commented Sep 15, 2015

@miguelbalparda sorry Miguel, just to know. Is there any fix or any plan to fix it?
The extension can't be used with this bug, am I the only one with this problem?

@miguelbalparda
Copy link
Contributor

We work hard to fix all the issues. It seems to be you are the only one experiencing this issue for now, so I wouldn’t say the extension can't be used.

@elfeffe
Copy link
Author

elfeffe commented Sep 15, 2015

Ok, I only want to know if it's only me the one with the problem.

@elvinristi
Copy link

Nope, you aren't the only one. getting same. In my case I have multiple texts there and they are in content following each other without html-tags.

@aricwatson
Copy link
Contributor

Try adding another flush event to clear the cache when new products are added:

<reference name="global_messages">
            <action method="setEsiOptions">
                <params>
                    <method>esi</method>
                    <access>private</access>
                    <flush_events>
                        <core_session_abstract_add_message/>
                        <controller_action_predispatch_checkout_cart_add />
                    </flush_events>
                    <only_cache_if>no_text</only_cache_if>
                </params>
            </action>
        </reference>
        <reference name="messages">
            <action method="setEsiOptions">
                <params>
                    <method>esi</method>
                    <access>private</access>
                    <flush_events>
                        <core_session_abstract_add_message/>
                        <controller_action_predispatch_checkout_cart_add />
                    </flush_events>
                    <only_cache_if>no_text</only_cache_if>
                </params>
            </action>
        </reference>

Additionally, do you know steps to replicate this on default install/theme?

@elvinristi
Copy link

Actually this is core bug

--- app/code/core/Mage/Core/Block/Messages-o.php    2015-10-13 20:35:25.000000000 +0000
+++ app/code/core/Mage/Core/Block/Messages.php  2015-10-13 20:40:49.000000000 +0000
@@ -213,7 +213,7 @@
         $html = '<' . $this->_messagesFirstLevelTagName . ' id="admin_messages">';
         foreach ($this->getMessages($type) as $message) {
             $html.= '<' . $this->_messagesSecondLevelTagName . ' class="'.$message->getType().'-msg">'
-                . ($this->_escapeMessageFlag) ? $this->escapeHtml($message->getText()) : $message->getText()
+                . ($this->_escapeMessageFlag ? $this->escapeHtml($message->getText()) : $message->getText())
                 . '</' . $this->_messagesSecondLevelTagName . '>';
         }
         $html .= '</' . $this->_messagesFirstLevelTagName . '>';

Question might be why Turpentine uses "admin_messages" container and when Turpentine is off then this is not being used.

@tdgroot
Copy link

tdgroot commented Jan 15, 2016

Having the same issues..
The messages get added, but they're cached. And nothing seems to flush the block.

The following I tried:

  • Flush events
  • Setting TTL to 1
  • The core bug fix
  • Probably not gonna work because esi_options are only used on Mage_Core_Block_Template descendants..
<reference name="global_messages">
    <action method="setEsiOptions">
        <params>
            <access>private</access>
            <ttl>1</ttl>
            <method>esi</method>
            <scope>page</scope>
            <flush_events>
                <controller_action_predispatch/>
            </flush_events>
        </params>
    </action>
</reference>

<reference name="messages">
    <action method="setEsiOptions">
        <params>
            <access>private</access>
            <ttl>1</ttl>
            <method>esi</method>
            <scope>page</scope>
            <flush_events>
                <controller_action_predispatch/>
            </flush_events>
        </params>
    </action>
</reference>

@elfeffe Did you manage to fix it?

@addison74
Copy link

@elfeffe: You are not alone. I got this issue on "Orders and Returns" page too. The error message when you fill in wrong the form doesn't have the correct Magento css style. I checked the source code and there is a different ul tag used which creates trouble, the one you mentioned in your first post. Please see the images bellow, first the visual style of the tag and how is source code of the page.

This is a VM without Varnish/Turpentine installed:

with_css

This is a VM with Varnish/Turpentine installed:

without_css

@tdgroot
Copy link

tdgroot commented Jan 19, 2016

I got my messages working! This is what I did.

From the docs I quote:

Only blocks that inherit from the Mage_Core_Block_Template class may have caching policies.

Since neither the block Mage_Core_Block_Messages or Nexcessnet_Turpentine_Block_Core_Messages inherit from Mage_Core_Block_Template, no caching policies exist/work for the blocks.

But, we want to define caching policies though. We want it to be dynamic, so we need some wrapper around it. The solution:

In my local.xml

<default>
    <reference name="root">
        <action method="unsetChild">
            <name>global_messages</name>
        </action>
        <action method="unsetChild">
            <name>messages</name>
        </action>
        <block type="core/template" name="message_wrapper" as="message_wrapper" template="custom/message-wrapper.phtml">
            <action method="setEsiOptions">
                <params>
                    <access>private</access>
                    <scope>page</scope>
                    <ttl>0</ttl>
                </params>
            </action>
            <block type="core/messages" name="global_messages" as="global_messages"/>
            <block type="core/messages" name="messages" as="messages"/>
        </block>
    </reference>
</default>

And in my custom/message-wrapper.phtml

<div class="messages-wrapper">
    <?php
        echo $this->getChildHtml('global_messages');
        echo $this->getChildHtml('messages');
    ?>
</div>

@addison74
Copy link

@Desmaster your solution is not working for me. I placed local.xml in my theme layout folder, then custom/message-wrapper.phtml in template. I flushed the cache, restarted varnish, none worked.

Could you please give more details about file locations and changes?

@tdgroot
Copy link

tdgroot commented Feb 1, 2016

Make sure you output the defined block in the root templates(page/1column.phtml etc) like this: echo $this->getChildHtml('messages_wrapper') and get rid of the messages output that's in the root templates already.

@addison74
Copy link

@Desmaster. I followed all your steps and I could not fix it.

  1. I created inside /app/design/frontend/default/mytheme/layout/local.xml with your suggested content.

  2. I created inside /app/design/frontend/default/mytheme/template/custom/message-wrapper.phtml with your suggested content.

  3. I edited /app/design/frontend/default/mytheme/template/page/1 column.phtml as follows:

<div class="col-xs-12">
    <div class="main">
    <?php echo $this->getChildHtml('breadcrumbs') ?>
        <div class="col-main">
            <div class="padding-s">
            <?php echo $this->getChildHtml('global_messages') ?>
            <?php echo $this->getChildHtml('content') ?>
            </div>
        </div>
    </div>
</div>

In line 51 getChildHtml('global_messages') ?> I replaced global_messages with message_wrapper. I flushed the cache and restarted Varnish but there is no positive result, same behavior. To find out if this is the right template file I commented the whole line 51 and the message is not appearing, so this was the right template for editing.

I am getting this issue in "Orders and Returns" page here is a screenshot:

admin_message

@addison74
Copy link

@elvin-vaimo was right. I've made that change in Magento core files and here is the result:

admin_message2

Even it is an error message its class it is "admin_messages" instead of "messages". See how the containers are bonded together. Do a test with login form. You will get this html tag for an error:

<ul class="messages">
    <li class="error-msg">
        <ul><li><span>Invalid login or password.</span></li></ul>
    </li>
</ul>

I would like to know as @elvin-vaimo " why Turpentine uses "admin_messages" container and when Turpentine is off then this is not being used".

@elfeffe
Copy link
Author

elfeffe commented Feb 5, 2016

@miguelbalparda Sorry to bother you Miguel, but you can see I'm not the onlyone with this problem

@npearson72
Copy link

+1

Also having this issue

@aricwatson
Copy link
Contributor

I'd like to take a look at this. Can anyone give me steps to replicate on a default store? I'd like to rule out that it's theme-specific.

@addison74
Copy link

Check my posts.

@geminpak
Copy link

geminpak commented Aug 9, 2016

@addison74 Hello, was wondering what changes you made to Magento's core files in order to correctly display the error messages? I am currently looking at Messages.php in the core files.

@addison74
Copy link

addison74 commented Sep 8, 2016

Check this one: #940 (comment). It is like taking an ax and killing a pig.

For the moment it is some kind a bandage. It is not a proper solution, a more elegant one should come from Turpentine module.

@yoosefi
Copy link

yoosefi commented Nov 15, 2017

We had the same problem and saw that messages were being stashed in core/session instead of customer/session. Putting them in customer/session resolved the issue for us.

Hope that helps anyone.

@treestonemedia
Copy link

+1
Also having this issue

@norgeindian
Copy link

We face the same issue when a customer subscribes for the newsletter in our footer.

The message is not displayed like a usual magento success message, but as an admin_message.
During our debugging we ended up at Nexcessnet_Turpentine_Block_Core_Messages::_real_toHtml()
This function is called in Nexcessnet_Turpentine_Block_Core_Messages::_toHtml() and decides, if the function getHtml or getGroupedHtml shall be called, depending on the name in layout.

And here is the thing, we do not really understand. Disabling turpentine one can see, that usually Mage_Core_Block_Messages::_toHtml() always calls getGroupedHtml().

Does anyone have an idea, why this decision is implemented the way it is?

@elvinristi
Copy link

@norgeindian , see #940 (comment) to fix the core bug there on M1.

@norgeindian
Copy link

@elvinristi , thanks for the hint, but did not work for me. Faced the same issue.
And the question remains, why turpentine calls this function, if the usual way would be getGroupedHtml()

@miguelbalparda
Copy link
Contributor

Am not really sure why this was coded like this, what would be a better way to do it?

@norgeindian
Copy link

@aheadley , as far as I can see it was you who wrote most of the code in these functions. Could you explain the reasons for that?
In my local tests everything works fine, when _real_toHtml just calls getGroupedHtml in every case, but maybe there are issues I don't see right now.

@miguelbalparda
Copy link
Contributor

There is a proposed fix for this in #1508, care to check and report back?

@norgeindian
Copy link

If you could include this fix, this would be great and in my eyes we could then close this issue.

miguelbalparda added a commit that referenced this issue Sep 26, 2018
fixed admin_messages in frontend, fixes #940
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests