Publisher does not support the Fluid field type. Please do not contact asking when support will be available.
If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.
Ticket: Adding any new bloqs to my master template throws an error
Status | Resolved |
Add-on / Version | Bloqs 5.0.11 |
Severity | |
EE Version | 7.2.11 |
Jaywing Developers
Sep 17, 2023Hi,
It’s been some time since we’ve been required to add any new bloqs to our clients website. Recently I’ve noticed that adding any new bloqs seems to throw an error, regardless of the bloq setup within the CMS. We have a current setup where we have a “Master” template that handles all of the bloqs, for example:
{if bloq_a}
// Grab the template for bloq_a
{bloq_a_template}
{/if}
{if bloq_b}
// Grab the template for bloq_b
{bloq_b_template}
{/if}
This does contain many bloqs (around 40 or so) however even if I reduce the total number of bloqs (all the way to just the new one) I still get the error. The specific bit of code that can be removed to prevent the error is the template embed itself, for example:
{if bloq_a}
// Removing the template embed stops the error
{/if}
It appears that adding any new bloq triggers a simple conditionals bit of code within EE’s core LegacyParser.php file (/system/ee/ExpressionEngine/Service/Template/Variables/LegacyParser.php), specifically the following code (Found on line 267):
// simple conditionals
if (stristr($val, '\|') && substr($val, 0, 6) != 'switch' && substr($val, 0, 11) != 'multi_field') {
$var_single[$val] = $this->fetch_simple_conditions($val);
}
Commenting out the above code actually fixes the error although I’m skeptical to call it a fix as it’s modifying the core EE files. Can you possibly think of any reason why this would occur? Please let me know if there’s anything additional I can provide to assist with looking into this - unfortunately I cannot provide any access to development, staging or live environments as this contains confidential client data.
Thanks,
Jaywing Developers
Sep 17, 2023
I’m yet to thoroughly test but upgrading EE to 7.3.12 appears to fix the issue on the front end, just adding here for clarity.
Jaywing Developers
Sep 18, 2023
Hi,
We are now receiving an error after editing any pages that include bloqs, I’ve updated my original screenshot to include the one with the errors - please could this be looked into as soon as possible?
Thanks,
BoldMinded (Brian)
Sep 18, 2023
If a conditional in EE’s code is causing unexpected behavior then there isn’t anything I can do to fix that.
A bloqs field won’t render if nothing is in it, same for a bloq, so why have the extra {if} conditional around the template include? Just include the template.
Jaywing Developers
Sep 18, 2023
Hi Brian,
the original issue was somewhat resolved as i mentioned in my last comment, however now with the latest version of bloqs and the latest version of ee I get the error in the screenshot I posted in the original ticket. Can you please comment on that issue?
thanks,
BoldMinded (Brian)
Sep 18, 2023
What version of PHP are you using? Have you reduced the template down to just the code that causes the error? If so what types of fields in the bloq(s) is it trying to render? The error is b/c it can’t call a method on a field type file.
Jaywing Developers
Sep 18, 2023
Hi,
The error occurs when going to edit any entry where Bloqs is present, this isn’t something that’s present on the front end, to be clear this error is from the CMS. It happens on both our development and local environments. Development is running on PHP 7.4.32 and local is running on PHP 8.2.8
Thnks,
Jaywing Developers
Sep 18, 2023
Hi Brian
We are still unable to resolve this. I cannot find any reference to the block_display_field() method in our codebase nor can I find any mention of it within our database. This issue occurred following upgrading EE from version 7.2.11 -> 7.3.12 and also updating bloqs from 5.0.7 -> 5.0.11.
We are able to view/edit/save entries that do not contain any Bloqs, please let me know anything I can provide to assist with solving this.
Thanks,
BoldMinded (Brian)
Sep 18, 2023
You’ll need to do some debugging for me. Line 294 of the FieldTypeWrapper.php file is calling method_exists on an object, so it thinks whatever $ft is that it has a valid method called block_display_field. var_dump($ft) so we know what field type is trying to call that method.
BoldMinded (Brian)
Sep 18, 2023
Sorry line 293.
Jaywing Developers
Sep 18, 2023
<pre><code>object(Text_ft)#5330 (16) {
[“field_id”]=> int(1)
[“field_name”]=> string(8) “col_id_1”
[“row”]=> NULL
[“var_id”]=> NULL
[“EE”:protected]=> NULL
[“settings”]=> array(17) {
[“field_maxl”]=> string(3) “256”
[“col_required”]=> string(1) “n”
[“field_text_direction”]=> string(3) “ltr”
[“field_fmt”]=> string(4) “none”
[“field_content_type”]=> string(3) “all”
[“col_search”]=> string(1) “n”
[“field_label”]=> string(16) “Custom CSS Class”
[“field_required”]=> string(1) “n”
[“col_id”]=> int(1)
[“col_name”]=> string(16) “custom_css_class”
[“entry_id”]=> int(395)
[“grid_field_id”]=> int(7)
[“grid_row_id”]=> int(82107)
[“grid_row_name”]=> NULL
[“blocks_atom_id”]=> int(7)
[“blocks_block_id”]=> int(82107)
[“blocks_block_name”]=> NULL
}
[“field_fmt”]=> NULL
[“id”:protected]=> int(1)
[“name”:protected]=> string(8) “col_id_1”
[“content_id”:protected]=> int(395)
[“content_type”:protected]=> string(4) “grid”
[“info”]=> array(2) {
[“name”]=> string(10) “Text Input”
[“version”]=> string(5) “1.0.0”
}
[“field_content_types”]=> NULL
[“has_array_data”]=> bool(false)
[“defaultEvaluationRule”]=> string(10) “isNotEmpty”
[“default_field_content_type”:protected]=> string(3) “all”
}<pre><code>
Jaywing Developers
Sep 18, 2023
Hi Brian,
I also just noticed when checking the bloq that field above belonged too I can’t view/edit the it in the CMS along with all the other bloqs, stack trace below for the error:
BoldMinded (Brian)
Sep 18, 2023
Based on the generally broad error message, and the fact that I can’t replicate this locally, and no one else is reporting a similar issue, it leads me to believe there is something unique happening in your environment that is out of my purview. Have you tried setting up a clean EE install with only Bloqs installed to replicate the issue? Do you a field that is the same name as a bloq? Or a Grid column the same name as a bloq?
Jaywing Developers
Sep 19, 2023
Hi Brian,
I’ve tried a fresh copy of expression engine, bloqs and then copied across all of our remaining addons (Structure, Publisher Lite, Wyvern) along with our project setup and templates and also a backed up version of the database prior to the issue and unfortunately the issue still persists. This is probably about as close as I can get with a fresh install. The problem is that we have a site with over 400 entries and around 50 bloqs, if data migration in expression engine was easy then I’d be happy to go with a fresh install but as you can imagine recreating a site like that manually would take a very long time (time isn’t something we have unfortunately).
It feels like somewhere along the way the database might have become corrupted in some form - if that’s the case could you possibly advise on anything for us to try?
In relation to your final questions, no we don’t have any fields named the same as bloqs and we don’t use any grid columns on the site at all.
Thanks,
Jaywing Developers
Sep 19, 2023
Hi Brian,
Is there a paid support option we could pursue for this? If so, is there a more personal means to contact you in order to speed up the process - we’ve almost exhausted things on our end and a site rebuild would be a massive undertaking.
Thanks,
BoldMinded (Brian)
Sep 19, 2023
I’m not asking you to create a fresh install of the site and copy over all content and add-ons, that defeats the purpose. A fresh install of _just_ EE and Bloqs with the bare minimum channels, custom fields, and templates necessary to recreate the issue. If the issue can be re-created in that environment, then it is easier to determine what the issue is. If it can’t be replicated in that environment then it may indicate there is a conflict with another add-on, or something was configured differently, or there is some other factor I’m unaware of in your original environment.
No I don’t have paid support plans. I work a full-time job and support the add-ons when I can find the time.
BoldMinded (Brian)
Sep 19, 2023
The error is coming from the ModifiableTrait class, which means you likely have a variable modifier in your template. Have you tried stripping down your template to the bare minimum, e.g. removing any modifiers, and then adding them back to determine what part of the template is causing the problem?
Jaywing Developers
Sep 19, 2023
Hi Brian,
We reverted back to what’s on our live installation currently to try and work forwards from there which is running EE version 7.2.11 and Bloqs 5.0.7. For reference our master template contains Template partials, not embeds - which I should have mentioned before. When I strip it down to it’s absolute barebones of what’s required, this consists of a “row_block” with a nested test block “bloq_test_new”, in order to replicate how our layout typically operates. Our master template looks like this:
The partial that’s referenced “bloq_test_new_template” looks like this:
The output of the page in this situation is:
Notable takeaways from the above:
- I’m not sure where the “test” text is coming from.
- I’m also not sure why the closing bloq tag “{/bloq_test_new}” is returning.
- Despite it rendering it appears there was an issue as the comment suggests.
Thanks again for your help.
Jaywing Developers
Sep 19, 2023
Hi,
Changing the test bloq name to “testing_blocks” and then altering the template layout to the following appears to have resolved the issue:
BoldMinded (Brian)
6 days ago
It resolves the issue b/c of what I think is a long standing issue with EE’s template parser. You had a template prefixed with bloq_test_new_, and a bloq also named bloq_test_new, and it gets confused and botches the parsing. I don’t know if there is much I can do about this in Bloqs itself, but this seems to come up once or twice a year, so maybe I’ll have to see if it’s fixable from the Bloqs side of things. I think it stems back to this issue https://github.com/ExpressionEngine/ExpressionEngine/issues/55