Problem/Motivation

When I try to add a rule on a site with no content types (e.g.: minimal install profile), trying to select most events give me the following error:

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /system/ajax
StatusText: OK
ResponseText: 
( ! ) Fatal error: Unsupported operand types in /.../includes/form.inc on line 2759
Call Stack
#TimeMemoryFunctionLocation
10.0257268016{main}(  )../index.php:0
20.08792366256menu_execute_active_handler( ???, ??? )../index.php:21
30.08822367440call_user_func_array:{/.../includes/menu.inc:527}
( ???, ??? )../menu.inc:527
40.08822367672ajax_form_callback(  )../menu.inc:527
50.09102432304drupal_process_form( ???, ???, ??? )../ajax.inc:386
60.12303206144drupal_rebuild_form( ???, ???, ??? )../form.inc:973
70.14493280968form_builder( ???, ???, ??? )../form.inc:510
80.14833303320form_builder( ???, ???, ??? )../form.inc:1926
90.15243342408form_builder( ???, ???, ??? )../form.inc:1926
100.15263345864form_builder( ???, ???, ??? )../form.inc:1926
110.15293356192form_process_select( ???, ???, ??? )../form.inc:1870

Steps to reproduce

  1. Download drupal-7.43, entity-7.x-1.7, rules-7.x-2.x-dev.
  2. Install Drupal core with the minimal install profile, enable rules, rules_ui and all dependencies.
  3. Log in as the super-administrator.
  4. Go to admin/config/workflow/rules/reaction/add , enter:
    • Name = Test rule
    • Machine name = test_rule
    • Leave Tags empty.
    • React on event = Node -> After saving new content.
  5. Expected behaviour: Can still add a rule, just can't restrict by type.
    Actual behaviour: error.

Proposed resolution

The error itself happens in the following line of code:

$element['#options'] = $empty_option + $element['#options'];

In this case, $empty_option is always set to an array, but $element['#options'] is NULL (or FALSE? — can't quite remember) because there are no content types for Rules' "Restrict by type" selectbox, and adding an array to a NULL / boolean causes the error.

Ensuring '#options' is an empty array instead of NULL or FALSE would fix this problem.

Remaining tasks

To be determined.

User interface changes

N/A.

API changes

N/A.

Data model changes

N/A.

Comments

mparker17 created an issue. See original summary.

mparker17’s picture

Issue summary: View changes

Clarify that we should be using the minimal install profile.

mparker17’s picture

Issue summary: View changes

Add a bit more information about where this error occurs.

TR’s picture

Status: Active » Closed (duplicate)

This is a duplicate of #2267341: Unsupported operand types error is thrown if there are no node content types defined. There's a patch in that issue which should solve the problem. You could also post there whether the patch fixed it for you ...

miksha’s picture

miksha’s picture

My problem and solution was within Maestro module. Nothing to do with the Rules module. Sorry.

https://www.drupal.org/project/maestro/issues/3011495