Publisher is EE6 compatible, but it does not support the Fluid field. 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: Some channel entries display fatal error, some do not. Uncaught TypeError: Return value of Bloqs\Model\BlockDefinition::getShortName() must be of the type string

Status Resolved
Add-on / Version Bloqs 4.9.1
Severity
EE Version 5.4.2

Paul Larson

Oct 20, 2021

Full text of error.

Fatal error: Uncaught TypeError: Return value of BoldMinded\Bloqs\Model\BlockDefinition::getShortName() must be of the type string, null returned in /mydomain/system/user/addons/bloqs/Model/BlockDefinition.php:331 Stack trace: #0 /mydomain/system/user/addons/bloqs/Controller/PublishController.php(461): BoldMinded\Bloqs\Model\BlockDefinition->getShortName() #1 /mydomain/system/user/addons/bloqs/Controller/PublishController.php(114): BoldMinded\Bloqs\Controller\PublishController->createBlockDefinitionsVars() #2 /mydomain/system/user/addons/bloqs/ft.bloqs.php(294): BoldMinded\Bloqs\Controller\PublishController->displayField() #3 /mydomain/system/ee/legacy/fieldtypes/EE_Fieldtype.php(326): Bloqs_ft->display_field() #4 /mydomain/system/ee/legacy/libraries/api/Api_channel_fields.php(410): EE_Fieldtype->display_publish_field() #5 /mydomain/system/ee/EllisLa in /mydomain/system/user/addons/bloqs/Model/BlockDefinition.php on line 331

The error is only thrown on some entries. I’ll follow up with screenshots of the config of the bloq for this channel.

#1

Paul Larson

Oct 20, 2021

Actually, the problem is limited to one channel.

A Ha, the field (editing / viewing the bloq settings in EE) throws this error. Likely same as before, but it’s not entry content that triggers it, but the field itself.

Fatal error: Uncaught TypeError: Return value of BoldMinded\Bloqs\Model\BlockDefinition::getName() must be of the type string, null returned in /mydomain/system/user/addons/bloqs/Model/BlockDefinition.php:350 Stack trace: #0 /mydomain/system/user/addons/bloqs/ft.bloqs.php(720): BoldMinded\Bloqs\Model\BlockDefinition->getName() #1 /mydomain/system/ee/legacy/libraries/api/Api_channel_fields.php(410): Bloqs_ft->display_settings() #2 /mydomain/system/ee/EllisLab/ExpressionEngine/Model/Content/FieldFacade.php(226): Api_channel_fields->apply() #3 /mydomain/system/ee/EllisLab/ExpressionEngine/Model/Content/FieldModel.php(72): EllisLab\ExpressionEngine\Model\Content\FieldFacade->getSettingsForm() #4 /mydomain/system/ee/EllisLab/ExpressionEngine/Controller/Fields/Fields.php(578): EllisLab\ExpressionEngine\Model\Content\FieldModel->getSettingsForm() #5 /var/www/vhosts/mgcdiagnostics.c in /mydomain/system/user/addons/bloqs/Model/BlockDefinition.php on line 350

#2

BoldMinded (Brian)

Oct 20, 2021

Did you recently delete any bloqs? What actions have been performed recently when updating, creating, or deleting bloqs?

#3

BoldMinded (Brian)

Oct 20, 2021

You’re using EE5…. technically I dropped support of EE 5 when 6.1 was released.

#4

Paul Larson

Oct 20, 2021

It might have been because the site relies on cloning, so we are stuck on upgrading to EE6.

#5

BoldMinded (Brian)

Oct 20, 2021

What about my questions though? Did you recently delete any bloqs? What actions have been performed recently when updating, creating, or deleting bloqs?

#6

Paul Larson

Oct 20, 2021

The bloq fields haven’t been changed from the live site in quite some time. Issue exists on the live site too, we’ve discovered. So no changes (rarely have we had to administer or modify the site in months).

Going to try an EE6 upgrade on dev, though. Now that I look I can’t see any module upgrade that is preventing that.

#7

BoldMinded (Brian)

Oct 20, 2021

In this case upgrading to 6 probably won’t fix the error b/c it’s failing trying to get a name value from the block definition object, which should very much exist. Why the name property is not on the block definition object is puzzling. I can’t think of a reason why the name wouldn’t be available. If you look at the exp_blocks_blockdefinition table does every block have a value in the name and short name column?

#8

Paul Larson

Oct 20, 2021

Comment has been marked private.

#9

Paul Larson

Oct 20, 2021

The above screenshot is on the entry. Navigating to the EE Field (bloq) to edit yields this.

TypeError Caught

Return value of BoldMinded\Bloqs\Model\BlockDefinition::getShortName() must be of the type string, null returned

user/addons/bloqs/Model/BlockDefinition.php:331

Stack Trace: Please include when reporting this error

#0 user/addons/bloqs/ft.bloqs.php(721): BoldMinded\Bloqs\Model\BlockDefinition->getShortName()
#1 ee/legacy/libraries/api/Api_channel_fields.php(377): Bloqs_ft->display_settings()
#2 ee/ExpressionEngine/Model/Content/FieldFacade.php(257): Api_channel_fields->apply()
#3 ee/ExpressionEngine/Model/Content/FieldModel.php(68): ExpressionEngine\Model\Content\FieldFacade->getSettingsForm()
#4 ee/ExpressionEngine/Controller/Fields/Fields.php(547): ExpressionEngine\Model\Content\FieldModel->getSettingsForm()
#5 ee/ExpressionEngine/Controller/Fields/Fields.php(394): ExpressionEngine\Controller\Fields\Fields->form()
#6 [internal function]: ExpressionEngine\Controller\Fields\Fields->edit()
#7 ee/ExpressionEngine/Core/Core.php(255): call_user_func_array()
#8 ee/ExpressionEngine/Core/Core.php(111): ExpressionEngine\Core\Core->runController()
#9 ee/ExpressionEngine/Boot/boot.php(161): ExpressionEngine\Core\Core->run()
#10 httpdocs/admin.php(144): require_once(’...’)
#10 httpdocs/admin.php(144): require_once(’...’)

#10

Paul Larson

Oct 20, 2021

Comment has been marked private.

#11

BoldMinded (Brian)

Oct 20, 2021

You’re going to have to so some debugging. This seems like an issue where a block was assigned to a field and then removed at some point? On line 718 of ft.bloqs.php is this line:

foreach ($blockDefinitions as $blockDefinition) {

change it to:

foreach ($blockDefinitions as $blockDefinition) {
var_dump($blockDefinition);

What version of PHP are you using??

#12

Paul Larson

Oct 20, 2021

Comment has been marked private.

#13

BoldMinded (Brian)

Oct 20, 2021

What does your exp_blocks_blockfieldusage table look like?

#14

BoldMinded (Brian)

Oct 20, 2021

Can you run this query on your db and share the results? You can export the results as a csv if you can’t fit it all in a screenshot.

SELECT
    bd.id as bd_id,
    bd.group_id as bd_group_id,
    bd.shortname as bd_shortname,
    bd.name as bd_name,
    bd.instructions as bd_instructions,
    bd.deprecated as bd_deprecated,
    bd.deprecated_note as bd_deprecated_note,
    bd.preview_image as bd_preview_image,
    bd.preview_icon as bd_preview_icon,
    bd.settings as bd_settings,
    bd.is_component as bd_is_component,
    bd.is_editable as bd_is_editable,
    ad.id as ad_id,
    ad.shortname as ad_shortname,
    ad.name as ad_name,
    ad.instructions as ad_instructions,
    ad.order as ad_order,
    ad.type as ad_type,
    ad.settings as ad_settings
FROM exp_blocks_blockdefinition bd
LEFT JOIN exp_blocks_atomdefinition ad
    ON ad.blockdefinition_id = bd.id
LEFT JOIN exp_blocks_blockgroup bg
    ON bd.group_id = bg.id
ORDER BY bg.order DESC, bd.shortname, ad.order
#15

Paul Larson

Oct 20, 2021

Comment has been marked private.

#16

BoldMinded (Brian)

Oct 20, 2021

What about this query? You’ll need to change :fieldId to whatever the int value is for the field you’re editing.

SELECT
    bd.id as bd_id,
    bd.group_id as bd_grouo_id,
    bd.shortname as bd_shortname,
    bd.name as bd_name,
    bd.instructions as bd_instructions,
    bd.deprecated as bd_deprecated,
    bd.deprecated_note as bd_deprecated_note,
    bd.preview_image as bd_preview_image,
    bd.preview_icon as bd_preview_icon,
    bd.settings as bd_settings,
    bd.is_component as bd_is_component,
    bd.is_editable as bd_is_editable,
    ad.id as ad_id,
    ad.shortname as ad_shortname,
    ad.name as ad_name,
    ad.instructions as ad_instructions,
    ad.order as ad_order,
    ad.type as ad_type,
    ad.settings as ad_settings
FROM exp_blocks_blockfieldusage bfu
LEFT JOIN exp_blocks_blockdefinition bd
  ON bd.id = bfu.blockdefinition_id
LEFT JOIN exp_blocks_atomdefinition ad
  ON ad.blockdefinition_id = bd.id
LEFT JOIN exp_blocks_blockgroup bg
  ON bd.group_id = bg.id
WHERE bfu.field_id = :fieldId -- <== CHANGE ME
ORDER BY bg.order DESC, bg.name DESC, bd.group_id DESC, bfu.order, ad.order
#17

Paul Larson

Oct 20, 2021

Attached `WHERE bfu.field_id = 27`

https://www.dropbox.com/s/1eal5nsclel5kh4/bd-2.csv?dl=0

#18

BoldMinded (Brian)

Oct 20, 2021

Ok, those last 2 rows have null values… thats our problem. Now to figure out how that happened.

#19

BoldMinded (Brian)

Oct 20, 2021

What does the exp_blocks_blockfieldusage table look like?

#20

Paul Larson

Oct 20, 2021

#21

BoldMinded (Brian)

Oct 20, 2021

Ok… see that row 2/3 of the way down with blockdefinitin_id of 0? Backup your database then manually delete that row. Not entirely sure how that became to be, but it looks like a bad record. I haven’t seen that behavior before.

I’m wondering if this clears up the other javascript issue you were experiencing too. Delete that row and report back :D

#22

Paul Larson

Oct 20, 2021

Sadly I think it’s still the same error..

#23

BoldMinded (Brian)

Oct 20, 2021

Run that last query again where you added the fieldId of 27. I want to see if there is still a NULL row in the result.

#25

BoldMinded (Brian)

Oct 20, 2021

Check the exp_blocks_atomdefinition table, there might be a row in there with another 0, maybe for blockdefintion_id column. If so delete that row too.

#26

Paul Larson

Oct 20, 2021

exp_blocks_atomdefinition

No ‘0’, but also worth noting I DON’T see the short name of the filename in question, product_tabs-block. (might not be a concern)

———

 

#27

BoldMinded (Brian)

Oct 20, 2021

Is that a block/atom you expect to still exist?

#28

BoldMinded (Brian)

Oct 20, 2021

I’m going to be honest, I’m not sure what state the site is supposed to be in, or how it got to its current state. Something in those db tables isn’t matching up so the query is returning that null row, which is causing the error.

#29

Paul Larson

Oct 20, 2021

Comment has been marked private.

#30

BoldMinded (Brian)

Oct 21, 2021

Paul, are you able to provide CP access to the dev site so I can look at the DB directly instead of going back and forth?

#31

Paul Larson

Oct 21, 2021

Comment has been marked private.

#32

BoldMinded (Brian)

Oct 21, 2021

Paul, can you edit the ticket and use the provided fields for the url, user and pass? When the ticket is closed it is deleted form the database. I don’t want sensitive login info to stay in comments.

#33

Paul Larson

Oct 21, 2021

Sure! Think I did it right? (was on phone so probably didn’t see the option to edit the ticket)

#34

BoldMinded (Brian)

Oct 21, 2021

What page in the control panel do I need to go to see the error? Including the JS errors reported in the other ticket?

#35

BoldMinded (Brian)

Oct 21, 2021

I removed the var_dump on your dev site, and the field isn’t throwing anymore errors. I think this row was the culprit

The block definition of 13 was removed at some point but this row stuck around. Removing this row and that other null row from earlier seems to have cleared up the issue. I went to a product’s entry and didn’t see any JS errors either (referring to the other ticket). If you’re still getting JS errors lets close this ticket and move the conversation to the other ticket.

#36

Paul Larson

Oct 21, 2021

Sorry, was in a meeting! This is great news. The /products channel was where the error was thrown. Seems to be gone now. Huzzah!

I’ll respond about the other ticket.

Login to reply