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: “Call to a member function result() on null” when running blocks_set_block_order hook on ignored cha

Status Resolved
Add-on / Version Publisher Lite 2.7.3
Severity
EE Version 3.5.15

David Clough

Jan 29, 2018

We have Publisher Lite installed with Bloqs (3.3.3) and I am running against a number of problems.

We have a channel with a bloqs field. The channel in question is in the Publisher “ignored” list.

However, when we update a channel entry we first see the exception “Call to a member function result() on null” on …/system/user/addons/publisher/legacy/libraries/hooks/Publisher_bloqs_hooks.php:409. Upon refreshing the page the content of the bloqs field has been lost.

Do these hooks need to run, even for channels set as to be ignored by Publisher?

#1

BoldMinded (Brian)

Sounds like I haven’t tested it with ignored fields or channels. Make this change to the beginning of that hook call and see what happens:

public function blocks_set_block_order($queryString, $queryReplacements, $siteId, $entryId, $fieldId)
    {
        /** @var \BoldMinded\Publisher\Service\Entry\Entry $entryService */
        $entryService = ee(\BoldMinded\Publisher\Service\Entry\Entry::NAME);

        if ($entryService->isIgnored($entryId, $fieldId)) {
            return null;
        }
#2

BoldMinded (Brian)

Actually, scratch that. Just a few lines down where it starts the conditional

if ($exists->num_rows() == 0) {

Change it to this:

if ($exists->num_rows() == 0 && !$this->entry->isIgnored($entryId, $fieldId)) {
#3

BoldMinded (Brian)

To answer your question, no I can’t just not trigger the hooks at all b/c some things do still need to execute, just not all of it.

#4

David Clough

Adding that code block stops the error, but still clears out the bloqs in the entry after save. Making the following change allows the bloqs to be kept and updated

public function blocks_pre_save_blocks($entryId, $fieldId, $fieldData = [])
    {
        /** @var \BoldMinded\Publisher\Service\Entry\Entry $entryService */
        $entryService = ee(\BoldMinded\Publisher\Service\Entry\Entry::NAME);

        if ($entryService->isIgnored($entryId, $fieldId)) {
            return $fieldData;
        }

The exception being if the bloq has a relationship field in it’s settings, after saving the relationship is removed

#5

BoldMinded (Brian)

Comment has been marked private.

#6

BoldMinded (Brian)

Comment has been marked private.

#7

David Clough

I have uploaded the provided amended file, along with the code changes described in previous comments. It is working better but bloqs with relationship fields are still an issue.

If I change the relationship value and save the entry the save completes but the relationship is lost, if I try and save the entry without changing the relationship i get the following exception:

Error thrown with message "Call to a member function setSetting() on null"

Stacktrace:
#17 Error in system/user/addons/bloqs/libraries/EEBlocks/Controller/PublishController.php:330
#16 EEBlocks\Controller\PublishController:publishAtom in system/user/addons/bloqs/libraries/EEBlocks/Controller/PublishController.php:221
#15 EEBlocks\Controller\PublishController:displayValidatedField in system/user/addons/bloqs/ft.bloqs.php:185
#14 Bloqs_ft:display_field in system/ee/legacy/fieldtypes/EE_Fieldtype.php:359
#13 EE_Fieldtype:display_publish_field in system/ee/legacy/libraries/api/Api_channel_fields.php:409
#12 Api_channel_fields:apply in system/ee/EllisLab/ExpressionEngine/Model/Content/FieldFacade.php:205
#11 EllisLab\ExpressionEngine\Model\Content\FieldFacade:getForm in system/ee/EllisLab/ExpressionEngine/Model/Content/Display/FieldDisplay.php:59
#10 EllisLab\ExpressionEngine\Model\Content\Display\FieldDisplay:getForm in system/ee/EllisLab/ExpressionEngine/View/publish/entry.php:146
#9 include in system/ee/EllisLab/ExpressionEngine/Service/View/View.php:145
#8 EllisLab\ExpressionEngine\Service\View\View:parse in system/ee/EllisLab/ExpressionEngine/Service/View/View.php:110
#7 EllisLab\ExpressionEngine\Service\View\View:render in system/ee/legacy/libraries/View.php:51
#6 View:render in system/ee/legacy/libraries/Cp.php:241
#5 Cp:render in system/ee/EllisLab/ExpressionEngine/Controller/Publish/Edit.php:509
#4 EllisLab\ExpressionEngine\Controller\Publish\Edit:entry in system/ee/EllisLab/ExpressionEngine/Core/Core.php:189
#3 call_user_func_array in system/ee/EllisLab/ExpressionEngine/Core/Core.php:189
#2 EllisLab\ExpressionEngine\Core\Core:runController in system/ee/EllisLab/ExpressionEngine/Core/Core.php:94
#1 EllisLab\ExpressionEngine\Core\Core:run in system/ee/EllisLab/ExpressionEngine/Boot/boot.php:151
#0 require_once in admin.php:143
#8

BoldMinded (Brian)

That sounds like a fieldtype that Bloqs doesn’t recognize, or a fieldtype that might have been in a 2.x install and does not exist for EE 3, or a fieldtype was uninstalled but it didn’t remove its data from Bloqs. Add this to the file at line 329:

if ($fieldtype === null) {
      var_dump($atomDefinition); die;
        }

https://d.pr/i/ANXboI

#9

David Clough

system/user/addons/bloqs/libraries/EEBlocks/Controller/PublishController.php:330:null
#10

BoldMinded (Brian)

Change that var_dump to var_dump($blockId, $entryId, $rowId, $data);

Is this happening on every entry or one specific entry? Does it happen in non-ignored channels?

#11

BoldMinded (Brian)

I just tested in EE4 and blocks save fine in an ignored channel. The Bloqs and Publisher codebases are the same in EE3 and 4, so I don’t expect anything there to be different. I’ll try to test on EE3 at some point today too.

#12

David Clough

system/user/addons/bloqs/libraries/EEBlocks/Controller/PublishController.php:330:string '15' (length=2)
system/user/addons/bloqs/libraries/EEBlocks/Controller/PublishController.php:330:int 15
system/user/addons/bloqs/libraries/EEBlocks/Controller/PublishController.php:330:string 'blocks_block_id_15' (length=18)
system/user/addons/bloqs/libraries/EEBlocks/Controller/PublishController.php:330:string '' (length=0)
#13

BoldMinded (Brian)

In your exp_blocks_block table do you have one with the ID of 15?

#14

BoldMinded (Brian)

Comment has been marked private.

#15

David Clough

Regarding your query with the exp_blocks_block table

There is no entry with the id is 15

There is one row with blockdefinition_id is 15

#16

BoldMinded (Brian)

Can you provide CP access to a development site where the issue is occurring so I can take a look? If there is no row in the exp_blocks_block table with the id of 15, then it shouldn’t be trying to load a block with the id of 15.

#17

BoldMinded (Brian)

Comment has been marked private.

#18

David Clough

Comment has been marked private.

#19

BoldMinded (Brian)

The CP login doesn’t seem to work.

#20

David Clough

Comment has been marked private.

#21

David Clough

Getting close to a resolution to the relationships issue with the following change

diff --git a/system/user/addons/publisher/legacy/libraries/hooks/Publisher_relationship_hooks.php b/system/user/addons/publisher/legacy/libraries/hooks/Publisher_relationship_hooks.php
index 11f4ea15..e3a74596 100644
--- a/system/user/addons/publisher/legacy/libraries/hooks/Publisher_relationship_hooks.php
+++ b/system/user/addons/publisher/legacy/libraries/hooks/Publisher_relationship_hooks.php
@@ -331,7 +331,7 @@ class Publisher_relationship_hooks extends Publisher_hooks_base
             // Ignored fields/channels won't save Relationships correctly, mostly because
             // in Publisher_relationships the transaction to sync the tables just ends up
             // deleting everything b/c of the delete statements below.
-            if ($this->channelField->getType($grid_field_id) == 'blocks') {
+            if ($this->channelField->getType($grid_field_id) == 'bloqs') {
                 $grid_field_id = FALSE;
             }

Will the change looking for the field type ‘bloqs’ instead of ‘blocks’ should be sufficient. Or is there a problem on our database end where references to ‘bloqs’ should be ‘blocks’.

#22

BoldMinded (Brian)

David, I just stumbled upon this myself and came back to the ticket to give you an update, but it looks like you already found the fix. There is a small change in that getType method for EE4 fields not in a group, but other than that it appears to be working for me locally (I was able to replicate the issue).

#23

BoldMinded (Brian)

Comment has been marked private.

#24

BoldMinded (Brian)

Comment has been marked private.

#25

David Clough

Hi Brian,

This issue has re-appeared again in the most recent build (2.8.2). Any suggestions would be greatly appreciated.

#26

BoldMinded (Brian)

David, can you provide more information? Are you getting the exact same error reported in the original ticket? The last time I heard from you was in February… what has changed since then? Did you upgrade Publisher or Bloqs between now and then? If so what versions? What was the last version that worked correctly?

#27

David Clough

Hi,

Using recent public builds of Publisher Lite and Bloqs (2.8.2/4.0.3) and latest Expression Engine (4.3.1).

Issue is not as initially reported, but how the issue developed across this thread. Here are the steps to recreate.

  • Add a relationship field to a channel. Issue occurs if field is in or outside a bloqs field.

  • Enable Publisher, but add channel to ignores list

  • Relationship does not save

Access details provided earlier in the thread should still be valid.

#28

BoldMinded (Brian)

But it sounds like this issue was fixed, but started occurring again since Feb 17th with Publisher 2.7.5. If that is the case, you should have those previous zip files. Have you tried reverting one version at a time to see which version may have specifically broken it?

Also, access previously provided was deleted from the database when the ticket was first closed.

#29

David Clough

I have had a quick look at the cause and it looks like the relationships are being stored in the ‘field/relationships’ request cache, but the cache is never used because the channel is ignored the afterChannelEntrySave function for the Relationship field type is never called to actually save the relationships.

I have a temporary workaround by commenting out line 433 in system/user/addons/publisher/ext.publisher.php (the after_channel_entry_save extension call). Thoughts on a more permanent solution to stop relationship data being deleted on ignored channels would be greatly appreciated.

#30

BoldMinded (Brian)

Comment has been marked private.

#31

BoldMinded (Brian)

Note that this fix is included in the 2.8.3 release.

Login to reply