Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
- Download drupal-7.43, entity-7.x-1.7, rules-7.x-2.x-dev.
- Install Drupal core with the minimal install profile, enable rules, rules_ui and all dependencies.
- Log in as the super-administrator.
- 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.
- Name =
- 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
Comment #2
mparker17Clarify that we should be using the minimal install profile.
Comment #3
mparker17Add a bit more information about where this error occurs.
Comment #4
TR CreditAttribution: TR commentedThis 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 ...
Comment #5
miksha CreditAttribution: miksha commentedPlease look at link:
https://www.drupal.org/project/drupal/issues/2239875#comment-12843152
Comment #6
miksha CreditAttribution: miksha commentedMy problem and solution was within Maestro module. Nothing to do with the Rules module. Sorry.
https://www.drupal.org/project/maestro/issues/3011495