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.
I have Rules as a part of a installation profile and some modules that have rules as features. When installing this profile I get the error:
"SQLSTATE[HY000]: General error: 1364 Field 'plugin' doesn't have a default value".
The fix for this is to define in the schema the default value, see the patch in comments.
This has been reported before: #1412448: Error using update.php - Field 'plugin' doesn't have a default value: INSERT INTO {rules_config}, but my profile does not have any commerce modules and there is a easy fix.
Comment | File | Size | Author |
---|---|---|---|
#1 | rules-schema-fix-1952170-1.patch | 872 bytes | fluffy |
Comments
Comment #1
fluffy CreditAttribution: fluffy commentedThe patch, adds default value for plugins in the schema.
Comment #2
fluffy CreditAttribution: fluffy commentedComment #4
ohthehugemanatee CreditAttribution: ohthehugemanatee commentedI encountered this problem myself, and discovered the root of it (for me). If you have this problem, please post an export of your rule here!
Here was my rule:
The issue isn't that PLUGIN wasn't declared, it's that the rule label included special characters, and was double-quoted in the Feature export. It tried to evaluate the braces, and I suppose couldn't distinguish that PLUGIN was the next key in the array.
So for me the solution was simply to rename the Rule to avoid the braces (I went with "login redirect for resume-search") and re-export. Or just edit the code and revert. I would expect this to be a problem anywhere that Rules allows special characters which are double quoted in Features. So check your export!
Comment #5
hefox CreditAttribution: hefox commentedThe general issue seems to be invalid json. Havent checked that the importing with latest -dev of entity/rules produces the invalid json, but trying to import the invalid json does and only fails at this stage.
So two problems
1) no warnings about invalid json
2) the export of invalid json
My json was not importing correctly due to a comma
Comment #6
TR CreditAttribution: TR commentedThis issue is very old - is this still a problem with the current version of Rules? There haven't been any further comments or reports of a similar problem for >5 years now.
I looked at this a little, and tried to reproduce some of it.
Specifically, for comment #5 there were two problems mentioned:
For 1), if I try to import the rule from #5, which has invalid JSON, then I AM given an error that the Rule contains invalid JSON.
For 2), when I export a rule with multiple conditions it does NOT add that extra comment that causes problems for you.
Comment #4 says that
"LABEL" : "login redirect (resume-search)",
is invalid JSON because of the braces inside the label text. But that's not so - braces are allowed inside double-quoted strings like this. If that causes an error with Features, then that's a Features issue.As for the original post, reading through the linked issues in the commerce_recurring queue, it seems that individuals have traced their particular problem to other things, such as a missing dependency. Likewise, @fago looked into the need for a default value in #1046250: Plugin field in hook_schema lacks default value and concluded it wasn't required.
Rules uses the Entity API to generate the JSON for the export, and the Entity API uses the core Drupal function drupal_export_json(). So while there could conceivably be a problem with how Rules or the Entity API passes data to drupal_export_json(), if there are any syntax errors in the resulting JSON that really amounts to a bug in that core Drupal function.
If this is still a problem, I need to see specific steps to reproduce the issue. If it can't be reproduced, then we have no assurance that any change to Rules actually 'fixed' the problem.
Comment #7
TR CreditAttribution: TR commentedNo further information provided.