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.
The gid column is declared as an integer in all database schemas within og.install
with one exception: In function og_field_schema
, line 363, the gid column is declared as a float. On runtime this can lead to the following error when trying to create more than one group, at least when drupal is used in conjunction with an sqlite database:
Notice: Undefined index: 1.0 in og_label() (line 2222 of /tmp/drupal-7.8/sites/all/modules/og/og.module).
Exception: Group membership for entity user with ID 1 for group ID 1.0 () already exists. in og_membership_create() (line 1028 of /tmp/drupal-7.8/sites/all/modules/og/og.module).
Comment | File | Size | Author |
---|---|---|---|
#11 | group-audience-gid-float-1277842-11.patch | 1.23 KB | BassistJimmyJam |
#7 | OG-Fix-the-group-audience-float-schema-issue-1277842.patch | 6.64 KB | citlacom |
#1 | 0001-Fixes-1277842.patch | 628 bytes | znerol |
Comments
Comment #1
znerol CreditAttribution: znerol commentedAttached the trivial patch. I have no idea though of how to write an update-function which alters all the field data and revision tables...
Comment #2
amitaibuWe have a big problem with this -- #937442: Field type modules cannot maintain their field schema (field type schema change C(R)UD is needed). However, very soon OG will not use the data from the group-audience field. In fact there's already a work in progress (almost finished actually) to only use the OG membersihp entity.
Can you please try with this branch (don't forget to backup and execute update.php):
git clone --branch deprecate-audience http://git.drupal.org/project/og.git
Comment #3
znerol CreditAttribution: znerol commentedI can confirm that the deprecate-audience branch does not have this specific problem when run with sqlite.
Comment #4
barraponto CreditAttribution: barraponto commentedThis should be highlighted in the module page, to have people patching the module before using it with sqlite. It is a known issue we are postponing after all.
Or maybe fixing this and providing a "regression patch" for anyone already using sqlite with OG — very unlikely, since it prevents adding two groups ...
Comment #5
barraponto CreditAttribution: barraponto commentedThere is a patch and it works for new installs.
What we're reviewing is whether it makes sense to fix it for sqlite.
Comment #6
amitaibuWe can fix it via an upgrade path, which should be added on top of the patch in #1
Comment #7
citlacom CreditAttribution: citlacom commentedI had this same issue but affecting with fatal error in MSSQL DB engine in Windows environment for an installation that already have a lot of content types using group_audience fields and with many existing nodes so I prepared a patch that look for all that fields and convert it to the correct int type.
This issue is directly related with #1659078: MSSQL server error: Conversion failed when converting the nvarchar value '1.0' to data type int when access user profile and #1228300: Subgroup cannot be created with MSSQL
Comment #9
weboide CreditAttribution: weboide commentedWith version 7.x-1.5, I faced this same issue this morning and was thinking that my code was wrong for hours...
Is there a reason why we wouldn't be able to do a patch similar to what citlacom suggested?
Comment #10
amitaibu> Is there a reason why we wouldn't be able to do a patch similar to what citlacom suggested?
There's no problem, but tests should at least pass before I review it :)
Comment #11
BassistJimmyJam CreditAttribution: BassistJimmyJam commentedI just encountered a floating point precision issue in MySQL due to this (specific gid is 1007508). See below:
I've attached an updated patch.
Comment #13
BassistJimmyJam CreditAttribution: BassistJimmyJam commented#11: group-audience-gid-float-1277842-11.patch queued for re-testing.
Comment #14
BassistJimmyJam CreditAttribution: BassistJimmyJam commentedI realize that OG 2.x has been released and this may not be an issue there, but this is a pretty serious issue for sites still using 1.x that have gids which happen to correspond to floating-point issues in MySQL. Can we get some movement on this?