backdrop-contrib / entity_plus

This module wraps in a variety of additional entity-related functionality from various sources. Partial port of D7 Entity API.
https://backdropcms.org/project/entity_plus
GNU General Public License v2.0
3 stars 11 forks source link

Error: Undefined constant "COMMENT_NODE_OPEN" when Comments are disabled #173

Closed argiepiano closed 5 months ago

argiepiano commented 5 months ago

Originally reported on Zulip.

In certain conditions, for example, when using Views Bulk Operations, this error is thrown when:

  1. Creating a View of nodes
  2. Adding a VBO field
  3. Selecting "Modify entity values"
  4. Disabling the Comment module
  5. Selecting a node in the View and trying to execute the VBO action

The issue started with #149. (Mea culpa). The node property info 'comment' should not be added at this point. In fact, that property info is correctly added in the function entity_plus_metadata_comment_entity_property_info_alter() in the file comment.info.inc, which runs only if comment is enabled.

149 was added as an attempt to allow for the three states of that property. In D7, this was a boolean (on/off). Now, in Backdrop, there are three possible states: COMMENT_NODE_OPEN, COMMENT_NODE_CLOSED and COMMENT_NODE_HIDDEN.

While the addition of these 3 states is correct, those should be have been as an option list callback in entity_plus_metadata_comment_entity_property_info_alter().

PR submitted in a moment.

argiepiano commented 5 months ago

@laryn, @hosef, PR provided and ready for testing and review.

I basically removed the comment node property info definition from node.info.inc, and modified the exiting comment node property definition in comment.info.inc to account for the fact that this property needs a select box with the three options for comments in Backdrop (open, closed, and closed & hidden).

Removing the property definition from node.info.inc prevents the fatal error that was reported above when the comment module was disabled.

laryn commented 5 months ago

@argiepiano Tested and reviewed. LGTM so I will go ahead and merge.

Wylbur commented 4 months ago

We found this issue today while working with the Views Bulk Operations module. This also fixed our issue: Error: Undefined constant "COMMENT_NODE_OPEN" in entity_plus_metadata_node_comment_settings_options_list() (line 137 of /home/wilbur/wbd/docroot/modules/entity_plus/modules/callbacks.inc).

Will this be added to a new release soon?

Thanks!

argiepiano commented 4 months ago

@laryn, @hosef, I think we should do a new release. Are you OK with that?