Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework the actions system (CMI) #168

Closed
jenlampton opened this issue Feb 7, 2014 · 6 comments · Fixed by backdrop/backdrop#543
Closed

Rework the actions system (CMI) #168

jenlampton opened this issue Feb 7, 2014 · 6 comments · Fixed by backdrop/backdrop#543

Comments

@jenlampton
Copy link
Member

We need to take data that's currently stored in the actions table and save each entry as a config file instead.*

*Not every action needs to have a config file. Actions that are NOT configurable (for example, module-defined actions such as publishing a node or deleting a comment) should not have config files OR entries in the database table.

The actions database table (hook_schema, and all associated code) should be deleted.

@quicksketch
Copy link
Member

Related issue that should be addressed as part of this conversion: #351

@quicksketch
Copy link
Member

Taking a look at this issue, I think we're confronted with a larger problem about what we should do with configurable actions in the first place. We currently have a number of non-configurable actions, including:

Publish comment
Unpublish comment
Make content sticky
Make content unsticky
Promote content to front page
Publish content
Remove content from front page
Unpublish content
Block current user

And then we have configurable actions, including:

Display a message to the user
Send e-mail
Redirect to URL
Change the author of content
Unpublish content containing keyword(s)
Unpublish comment containing keyword(s)

Because we have removed Trigger module from core, there is currently no way to use any of these configurable actions. You set them up, but then they can't actually be executed. We do have support for Views Bulk Operations to execute the non-configurable commands, so if you set up a View, you can do things like bulk unpublish nodes or content.

Rules module, for example, has found the core system too restrictive to be much use, and redefines its own set of actions using a separate API and UI. Because actions are so limited in core already, what I'd like to do is remove the entire concept of a configurable action, as well as the UI for actions from System module. We'd retain all the non-configurable actions and even expand them, since we need them for Views Bulk Operations like Cancel user account (see #149). The UI and entire config storage for configurable actions would be done through contrib, with integration into the core action system through hook_config_info().

@quicksketch
Copy link
Member

I filed a PR at backdrop/backdrop#543 for this.

The PR is aggressive in this "conversion" to CMI, where it just removes the concept of configurable actions entirely and the need for any configuration at all in the process. This sets us up for doing more comprehensive conversions in #149, where we'll need to change the user and node management pages to use VBO.

@jenlampton
Copy link
Member Author

I actually really like this proposal. If there's no way to use configurable actions in core, doesn't mean they are also untestable? If contrib in Drupal 7 hasn't found a way to make them useful by now, then they have essentially proven their lack of worth. Why keep them around?

What we'll have in Backdrop core are actions that are "triggered" by the admin forms (content list, comment list, user list, etc).

To improve on these, contrib could make a multi-step actions module (VBO does this currently for D7. Update field value, for example: select nodes (step 1) select value (step 2) confirm (step 3). Or, if someone did really want actions to be configurable (not likely) they could create a configurable actions module that restores the UI and actions we're removing.

@quicksketch
Copy link
Member

Excellent. We'll need to put more work into the actions system when we consolidate the node and comment bulk operations pages. This basically strips our actions system down to a simple base. We'll build it up again in #150 and #149.

@quicksketch
Copy link
Member

Merged in backdrop/backdrop#543.

This will need a change notice. Actions are no longer configurable in core.

Old:

function hook_action_info() {
  return array(
    'comment_unpublish_action' => array(
      'type' => 'comment',
      'label' => t('Unpublish comment'),
      'configurable' => FALSE,
      'behavior' => array('changes_property'),
      'triggers' => array('comment_presave', 'comment_insert', 'comment_update'),
    ),
}

New:

function hook_action_info() {
  return array(
    'comment_unpublish_action' => array(
      'type' => 'comment',
      'label' => t('Unpublish comment'),
      'callback' => 'comment_unpublish_action',
    ),
  );
}
  • hook_action_info() now explicitly specifies the "callback" property.
  • hook_action_info() no longer has properties for "configurable", "behavior", or "triggers".
  • Action callbacks themselves now immediately save the entity they effect.
  • Function for saving/updating/deleting actions are removed.
  • actions_do() has been removed. actions_execute() has been put in its place, but it can only execute a single action instead of a chain of actions.
    Old:
        foreach ($entities as $entity) {
          actions_execute($aid, $entity, $context);
        }

New:

        foreach ($entities as $entity) {
          actions_execute($action_name, $entity, $context);
        }
  • Actions no longer have "action IDs" (aid), instead they are always referred to by their their machine name, as provided by the action's array key in hook_action_info().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants