Closed (fixed)
Project:
Autotaggerㅤ
Version:
1.0.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Mar 2024 at 01:12 UTC
Updated:
26 Mar 2024 at 17:09 UTC
Jump to comment: Most recent
When saving a node bundle type that does NOT have SearchInText settings saved, an error is thrown in entityPresave(). Because $settings is derived from ThirdPartySettings that are not set, $settings['autotagger_tag_on_create_only'] returns a null value on the array key. We need to check to see if $settings is empty or not before proceeding.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
brooke_heaton commentedMerge request submitted to 1.0.x branch.
Comment #4
brooke_heaton commentedComment #5
alvar0hurtad0Hello Brooke,
Thank you very much for the MR and raising the issue. Looks good to me but it'll be great if you could use a ternary operation in order to avoid an extra indentation level.
it's something we're trying to do in the whole codebase and it'll make it more homogeneous.
Thank you very much.
Comment #6
brooke_heaton commentedWill do!
Comment #7
brooke_heaton commentedSo I don't think a ternary is possible here. We actually want the entire code below to be conditional and we don't want to run ->tagNode whatsoever if there are no settings. I don't see a way to apply a ternary here, sorry.
Comment #8
brooke_heaton commentedComment #9
alvar0hurtad0let me try :)
Comment #10
alvar0hurtad0sorry, wrong comment.
Comment #12
alvar0hurtad0Thanks @brooke_heaton, I've submited a commit that should fix this issue.
I'll create a new release including also #3424520
Comment #13
alvar0hurtad0removing the assigned field.
Comment #14
brooke_heaton commentedNope. That's not the problem.
See, by setting $create_only to FALSE, you are STILL running a function that should not be ran and results in additional errors.
We want to wrap this in a conditional and NOT run this if there are no settings on a bundle.
If there are no settings on a bundle, why are we tagging the node? The node has no settings and the node is new.
Your ternary is nice and all, but the goal here should be to prevent tagging of nodes of a type that do not have any settings. For that you need a conditional statement to prevent running $this->tagNode if $settings['autotagger_tag_on_create_only'] returns FALSE. BTW Drupal coding standards should have PHP Constants like FALSE in ALL CAPS.
Comment #16
alvar0hurtad0True, thanks for the heads-up.
Now I understand the issue, and I think is fixed.
https://git.drupalcode.org/project/autotagger/-/commit/bbb0d3a47222b42f5...
Comment #17
alvar0hurtad0Comment #18
brooke_heaton commentedSure. Works for me.
Comment #19
alvar0hurtad0Thanks a lot Brooke, for me is a great feeling to know the module is useful for someone else.