Forum
Disappearing Blocks
I've had a client email with an issue of "disappearing" blocks, which I've been able to successfully replicate. It's a bit wonky to describe, but I'll do my best (steps below the diagnostics and template).
I've been able to replicate this issue within the Blog app as well as in vanilla Pages content on a fresh install of 2.8.6.
Here are my diagnostics:
HEALTH CHECK
Perch is up to date
PHP 5.4.4 version is okay, but a little out of date. Consider updating soon.
MySQL 5.5.25 is up to date
Image processing available
SUMMARY INFORMATION
Perch: 2.8.6, PHP: 5.4.4, MySQL: 5.5.25, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (2.8.6), assets (2.8.6), categories (2.8.6), perch_forms (1.8.2)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_forms', );
PERCH_LOGINPATH: /admin
PERCH_PATH: /path/to/admin
PERCH_CORE: /path/to/admin/core
PERCH_RESFILEPATH: /path/to/admin/resources
Image manipulation: GD
PHP limits: Max upload 128M, Max POST 128M, Memory: 512M, Total max file upload: 128M
Resource folder writeable: Yes
HTTP_HOST: local.website.come
DOCUMENT_ROOT: /path/to/website
REQUEST_URI: /admin/core/settings/diagnostics/
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
And here's my testing template code (with strange namespacing to rule out ID conflicts):
<perch:blocks>
<perch:block type="block_test_1" label="Heading">
<h2><perch:content id="block_test_1_text" type="text" label="Heading" /></h2>
</perch:block>
<perch:block type="block_test_2" label="Pull quote">
<blockquote><perch:content id="block_test_2_quote" type="textarea" size="s" label="Quote" /></blockquote>
</perch:block>
<perch:block type="block_test_3" label="Feature image">
<img src="<perch:content id="block_test_3_image" type="image" height="400" width="800" crop="true" label="Image" />" />
</perch:block>
</perch:blocks>
Here's what I've concluded: If a new block is created from an unsaved block, and that initial unsaved block is deleted before saving, all "child" blocks of that unsaved, deleted block are also deleted upon saving.
To replicate the issue (using the above code as an example):
- Add a "Heading" and type in something
- Add a "Pull Quote" and type in something
- Delete the "Heading" block (via the X in the upper-right of the block, so it fades out of view)
- Leave the "Pull Quote" block in place
- Save the region
- The "Pull Quote" block is gone
And it's worth noting that ALL child blocks with a deleted, unsaved parent are lost.
However, if a new child block is created off of a previously-saved parent block, and that previously-saved parent is deleted, the child block is not deleted upon save.
Here's what I mean:
- Add a "Heading" block
- Save the region
- Add a "Pull Quote" block
- Delete the "Heading" block (via the X in the upper-right of the block, so it fades out of view)
- Save the region
- The "Pull Quote" block is NOT gone
In the meantime, I've suggested my client works in "Draft" mode and hits save before deleting any blocks. This will ensure that there is never an unsaved "parent" block that could cause child blocks to disappear. Put another way, as long as the "adding blocks" and "deleting blocks" phases are kept in-between saves, it's safe.
I hope that makes sense -- let me know if I can provide any further information.
What do you mean by parent and child? Blocks can't be nested.
Hey Drew,
I realize blocks can't be nested, so using parent/child was a poor choice of words on my part. Here are my definitions for the purpose of this bug report:
block-add-bar
that is used to spawn another blockblock-add-bar
of a specific blockThis distinction is important because it seems to be directly related to the bug. Which is to say, when the block used to spawn other blocks via the
block-add-bar
is deleted before the region saved, all blocks spawned by it (either directly or indirectly) are gone when the region is saved.Lol. I realize this must look like the ramblings of a crazy person... Blocks spawn child parent spawn delete rarrararrrr! So here's another test to help clarify.
Using the template code in the above post:
block-add-bar
from most recently created block each time to add the next blockYou can take this same test and if you change which block is deleted you'll see the relationship I mean (of course you'll need to start fresh each time you run the test, as once a block is saved the bug no longer exhibits itself).
Here's how it cropped up in the real world, with a client editing a blog post:
Of course the argument could be made that this isn't the best way to write a post, but it happened, and my client was none to please for having his time wasted.
Hope that clears things up.
The concept of blocks spawning other blocks simply doesn't exist. Leave it with me and I'll see if I can reproduce the error.
Whatever you call it, whatever concept exists or doesn't exist, all I know is content is not being saved, and I've been able to replicate it over and over.
As I say, leave it with me and I'll see if I can reproduce the error.
I've managed to reproduce the issue to some extent - what I can't tie down is this scenario where the choice of add-bar used makes any difference.
The 2.8.7 update resolved the issue above within the Pages app, but the problem still exists within Blog. Is an update to the Blog app required and forthcoming?
It should be no different in Blog - it's all the same code.
I've just done a completely fresh install of Perch 2.8.7 and Blog 4.6 for the purpose of testing this bug and the issue is still present in Blog, while it's fixed in Content.
Which is to say, this code "works" in Content:
While this code, added to an otherwise untouched
post.html
template, still exhibits the bug in the Blog app:The only difference between the two blocks of code is the use of
perch:content
andperch:blog
(and different IDs to rule out namespacing). Perhaps this points to the fix?Please let me know if I can provide any further information.
Thanks, we'll take a look at it.
Any updates Drew? Not wanting to be a pest, but anxious to get this update through to my clients.
No, I've not looked at it yet.
Thanks for the quick reply. When will you be looking at it?
I don't know. It's logged to be looked at for a future release.
This should be now fixed in 2.8.8. Thanks for your patience!
Hey Drew. I appreciate the efforts, but it looks like the bug (or a slightly different version of it) is still present in Blog. I've updated my vanilla test build to 2.8.8 and am using the same code as before, in the stock
post.html
template. (I haven't tested from a fresh 2.8.8 build, only from updating 2.8.7.)At first, things look good:
For a moment, I was rejoicing. However, if we start over:
Furthermore (again, starting from a fresh blog post):
Here's my test blocks section again:
And my diagnostics summary for the test build:
Again, I'm only seeing this behaviour in Blog, and not in Pages. Let me know if I can provide any further information.
Another, slightly more worrisome test showing "saved" content disappearing. Starting from a fresh blog post:
So from what I can tell, the first block is safe to delete, whether before OR after saving the region. If any other block is deleted at any time, all blocks below it will disappear.
I'll take another look at it.
This issue appears to be solved in Perch 2.8.11. Thanks Drew!