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.
It seems that every patch that has been uploaded for 7.x-1.x-dev over the last couple months has failed its automatic tests, always at the same test in OgGroupAudienceField, with the same error messages. For example:
- From #1543696: PHP Fatal error: Unsupported operand types in modules/all/og/includes/og.info.inc on line 29: test results
- From #1567492: Allow alphabetical sorting on the group audience field: test results
- From #1516108: Removing the Node Author of a group node triggers PDOException: test results
- From #1146636: membership fields error on subscribe: test results
- From #1510290: Hide "Add People" from showing up if no permissions.: test results
I've elevated the priority of this bug, because until it's fixed it's impossible to post any patches to fix any other problems found in the 1.x branch.
Comment | File | Size | Author |
---|---|---|---|
#2 | og_qa_test_failure-1748782-2.patch | 1.94 KB | Nephele |
#1 | og_qa_test_failure-1748782-1.patch | 1.31 KB | Nephele |
Comments
Comment #1
Nephele CreditAttribution: Nephele commentedAfter some digging I've discovered some facts about the failed tests:
http://drupal7_clean.local/node/add/article?gids_entity_test=1
causes gid=1 to be added to OG_AUDIENCE_FIELD twice. This is presumably a new bug in core or somewhere else outside of og.Although the source of the problem is outside of og, making og's form validation more robust by filtering duplicate gids is a fix that's within the scope of og. The attached patch makes that change and has fixed the QA tests on my test machine.
Also, for what it's worth, it seems unlikely that this is the same problem as #1559766: EntityMalformedException when deleting users, in og_get_user_roles(), even though the error messages are the same.
Comment #2
Nephele CreditAttribution: Nephele commentedMy apologies for the triple post. However, I continued to dig to the bottom of what suddenly triggered this problem, and in the process of banging my head against the table I've found some more og issues.
The first point is that it seems that upgrading core from drupal 7.14 to drupal 7.15 is somewhat of a red herring. Yes, it triggered some minor changes in the tests, but those minor changes shouldn't have derailed og. Specifically, it seems that in drupal 7.15 the testing module is using more clean urls. So the key url being tested changed from
http://drupal7_clean.local/index.php?q=node/add/article&gids_entity_test=1
tohttp://drupal7_clean.local/node/add/article?gids_entity_test=1
. Trivial, but enough to cause the subsequent processing changes.The short story of what then happens in og is that gid gets set to both "1" (string value) and 1 (integer value) in the audience field's default values (within the function og_field_widget_form()). Those duplicates propagate all the way through to the final calls to og_membership_create().
My first patch cleaned up the duplicates at the validation step. I've now added a bit more cleaning during the setup phase, as well.
Although I've done the basic fixes, I didn't try to tackle some other more nebulous questions that arose while investigating this issue.
$default_values[$gid] = $gid
(line 238 of og.field.inc) with the intent of preventing up duplicate gids. However, it doesn't work given that $default_values starts as an unkeyed array -- in which case, the code could cause existing values to be overwritten without explanation. Therefore I changed the line even though it's not really responsible for the issues I was investigating.I can't judge the importance of these questions/issues -- especially given that all of the relevant code has been removed from og-7.x-2.x, so this only affects a dead-end branch of the module. Nevertheless, I wanted to make the information available to those of you who are more knowledgeable about og.
Comment #3
amitaibuThanks, mostly looks good just one question:
Why do you remove those lines?
Comment #4
Nephele CreditAttribution: Nephele commentedIn the specific case triggered by the QA tests, #hidden_selected_gids is empty, so the entire validation was being skipped. However, $form_state['values'][OG_AUDIENCE_FIELD] contained duplicate values, so it needs to be validated (regardless of whether or not #hidden_selected_gids contains data) -- and the duplicates trigger the exception in og_membership_create that's causing the test failure. In other words, removing those lines allowed the existing validation to fix the problem.
Comment #5
amitaibuCommitted, thanks.
Comment #6
Nephele CreditAttribution: Nephele commentedThanks for committing it so quickly!
I've re-queued the patches that incorrectly failed because of this bug (at least the ones that I'm aware of), so I'm afraid I've probably just added more patches onto your to-review list ;)