- Issue created by @brooke_heaton
- Merge request !17Update SearchInTextFields->entityPresave to check for empty var. → (Open) created by brooke_heaton
- last update
10 months ago 3 pass - Assigned to brooke_heaton
- Status changed to Needs review
10 months ago 1:32am 4 March 2024 - Status changed to Needs work
10 months ago 10:39am 4 March 2024 - 🇪🇸Spain alvar0hurtad0 Cáceres
Hello 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.
- 🇺🇸United States brooke_heaton
So 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.
if (isset($settings)) { $create_only = $settings['autotagger_tag_on_create_only']; if ($node->isNew() || !$create_only) { // If the node is first being created, or the node is set to not only tag // on new, then go ahead and tag it. $this->tagNode($node); }
- Status changed to Needs review
10 months ago 5:21pm 5 March 2024 - Assigned to alvar0hurtad0
- Status changed to Active
10 months ago 5:46pm 5 March 2024 -
alvar0hurtad0 →
committed 303050ed on 1.0.x
Issue #3425276 by brooke_heaton: Warning: Trying to access array offset...
-
alvar0hurtad0 →
committed 303050ed on 1.0.x
- 🇪🇸Spain alvar0hurtad0 Cáceres
Thanks @brooke_heaton, I've submited a commit that should fix this issue.
I'll create a new release including also #3424520
- Issue was unassigned.
- Status changed to Fixed
10 months ago 7:46pm 5 March 2024 - Status changed to Needs work
10 months ago 8:44pm 5 March 2024 - 🇺🇸United States brooke_heaton
Nope. 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.
Warning: Trying to access array offset on value of type null in Drupal\autotagger_search_in_text\Plugin\Autotagger\SearchInTextFields->tagNode() (line 209 of modules/contrib/autotagger/modules/autotagger_search_in_text/src/Plugin/Autotagger/SearchInTextFields.php). Warning: Trying to access array offset on value of type null in Drupal\autotagger_search_in_text\Plugin\Autotagger\SearchInTextFields->tagNode() (line 210 of modules/contrib/autotagger/modules/autotagger_search_in_text/src/Plugin/Autotagger/SearchInTextFields.php).
We want to wrap this in a conditional and NOT run this if there are no settings on a bundle.
if ($node->isNew() || !$create_only) { // If the node is first being created, or the node is set to not only tag // on new, then go ahead and tag it. $this->tagNode($node); }
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 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. →
-
alvar0hurtad0 →
committed bbb0d3a4 on 1.0.x
Issue #3425276 by brooke_heaton: Warning: Trying to access array offset...
-
alvar0hurtad0 →
committed bbb0d3a4 on 1.0.x
- Status changed to Needs review
10 months ago 12:48pm 6 March 2024 - 🇪🇸Spain alvar0hurtad0 Cáceres
True, thanks for the heads-up.
Now I understand the issue, and I think is fixed.
https://git.drupalcode.org/project/autotagger/-/commit/bbb0d3a47222b42f5...
- Status changed to Fixed
10 months ago 3:41pm 12 March 2024 - 🇪🇸Spain alvar0hurtad0 Cáceres
Thanks a lot Broke, for me is a great feeling to know the module is useful for someone else.
Automatically closed - issue fixed for 2 weeks with no activity.