0

I'm working through Alan Storm's 'No Frills Magento 2 Layout' an internal dev server. He walks the reader through small edit, refresh, another small edit, refresh, see what changes, and so on. There are lots of examples. Then I inserted a typo which I couldn't find, that ended up being whitespace added at the end of 'Magento\Framework\View\Element\Template ' when I copied and paste from the PDF manual.

I then sorted out getting errors enabled, however I managed to get the Magento 2.3.2 install into a bad state where there are white pages on every refresh. Clean the cache and hit F5, the site comes back, but for only one render.

This was a fresh install and I had only executed php bin/magento deploy:mode:set developer as per the install instructions for the module which is part of the book.

I then started an exploration of every command available from the internet in an attempt to be able to hit F5 and just get a page to reload. I issued these two commands:

php bin/magento deploy:mode:set developer
php bin/magento cache:disable

And now the site will refresh with F5 but instead of quickly refreshing, the server grinds for 7 to 10 seconds and then renders Hello World

What mechanism in Magento 2 causes this?
and
What can a person do to get back to how the site was working as expected before all this?

Right now, I believe the solution is to move this M2 and start over by installing a new fresh instance. But that simply is not acceptable; what happens if a live site starts acting like this? Having to clean cache to render one page is not acceptable nor is disabling cache...

1
  • Did a fresh install and this new fresh install fails to render once I get to "Template Blocks" on page 18 of his book. On the former fresh install, I was able to do these steps and it all went sideways on the Layout section. – Chris K Jul 10 '19 at 21:49
0

While it does not fully explain some inconsistencies from my experience leading to the initial question, I have since learned a few things which help explain what happened above.

1. There was a typo I didn't notice. I fell victim to the "didn't have the '/' where it belongs" and it caused an error. Because I did get errors to show up, the output helped me find the problem. On page 20 of Alan's book, the same code is shown twice:
class Template extends \Magento\Framework\View\Element\Template and later on as:
class Template extends Magento\Framework\View\Element\Template
I didn't notice the typo on the second copy of the "same code" and it got me; an expected Magento-kind of coding error. (I did let the author know)

2. Mentioning "cache:clean" was not soon enough. The book begins the mantra of "clean cache and refresh the page" once XML layouts are introduced. F5 works with Controller and Block changes, however when a layout or the blocks instantiated via $layout variable are changed, F5 produces an empty, white, blank page. We might all know you need to clean the cache all the time, but having read the chapter before trying it, I observed the "clean cache and refresh" and didn't think to begin obeying that earlier than the repetitive chant said we must obey.

3. "Blank" or white pages give no feedback. Even with errors reporting correctly, there's no indicator from Magento that it served a blank page because cache needs to be cleaned. No indicator means no errors logged for the webserver or in magento's var/log.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.