Closed (fixed)
Project:
Flag
Version:
8.x-4.x-dev
Component:
Flag core
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Aug 2015 at 13:59 UTC
Updated:
2 Nov 2016 at 04:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
webflo commentedComment #3
joachim commented> Use the same database constraints as in {flagging}.
That seems like a good idea.
> (e.g. config entities).
We don't currently allow flagging of config entities though. Are there any other kinds of entities with non-numeric IDs? (If not, it's {flagging} that's wrong, not the counts table, maybe?)
Also, we're not currently supporting head-to-head upgrades, so there shouldn't be a hook_update_N().
Comment #4
webflo commentedI use an older version of flag and flagging config entities works fine :/
Schema for {flagging} is correct because its generated by
SqlContentEntityStorageandSqlContentEntityStorageSchema. Also the docblock on EntityInterface::id allows strings.Comment #5
webflo commentedComment #6
webflo commentedComment #7
gloob commentedHi,
As an additional information and half of what this patch adressed is that the current absence of "not null" => TRUE flag in the members of the primary key (flag_id, entity_type) create an error in the creation definition of table 'flag_counts' using mysql 5.7.9 (mysql Ver 14.14 Distrib 5.7.9, for osx10.11 (x86_64) using EditLine wrapper)
As defined in the example of Schema API it seems we should define the fields part of the primary key as not null although is not fully clear or I didn't find it. This happens on some mysql versions and it's not reproducible in others (probably mysql convert it automatically? Schema API behave in other way?).
Anyhow this patch makes sense to address this bug. I will provide a new patch without the hook_update_n().
Comment #8
gloob commentedAdding new patch setting main fields as not_true and supporting non-numeric IDs.
Comment #9
mbovan commentedThis patch fixes Flag installation using drush, which is currently not possible.
Changing to RTBC.
Comment #10
berdirentity_type ID's are limited to 32 characters, everything else will throw an exception. If we are changing it, then lets limit to that.
For config entity ID's, the max length is 166 but there is no global limit, so fine with keeping that at 255.
Note that changing this might decrease query/index performance if you do joins against that table.
Not sure if we should split up the not null change into a separate issue, since that is an obvious, simple bugfix, while the other is a task/change that's not quite so simple.
Comment #11
eiriksmCould be split up, but since the suggested change was so small, here is just an updated patch.
Interdiff is practically changing 255 to 32.
Comment #12
joachim commented> For config entity ID's, the max length is 166 but there is no global limit, so fine with keeping that at 255.
You can't flag config entities.
I'm no longer clear what this issue is trying to fix.
> Not sure if we should split up the not null change into a separate issue, since that is an obvious, simple bugfix, while the other is a task/change that's not quite so simple.
Someone's done that already: #2657504: Error "All part of primary key must be not null" when installing flag module
Comment #13
berdir> You can't flag config entities.
Content entities can have string ID's too (e.g. UUID). Field API supports that now, entity references do too, comment.module however doesn't as it also has a separate table, similar to flagging.
Comment #14
socketwench commentedReimplemented the patch with the longer entity_id length.
Comment #15
berdirThis makes it consistent with Flagging, which I guess fine.
That said, note that the max length for entity_type is 32 (\Drupal\Core\Entity\EntityTypeInterface::ID_MAX_LENGTH) and the max length of a config entity is 166 as mentioned before, although other entity types could possibly have longer ID's, so 255 is probably fine there.
To save storage, you could consider to instead limit entity_type to 32 characters in both places.
Comment #16
socketwench commentedHow would you set the length of the Flagging entity_type field? BaseFieldDefinition::setConstraints()?
Comment #17
berdirstring field type has a max_length setting, that automatically adds a validation constraint and uses it for the schema.
Comment #18
jhedstromWhat's left to be done here?
Comment #19
joachim commentedLet's set this to the 32 constant as in #15.
What was this for?
Comment #20
jhedstromI think this is what #15 was suggesting to do. It uses the max length of 166 (config entity ids) for
entity_idand the max length of 32 forentity_type.I've also updated the IS.
Comment #21
socketwench commentedI think this is ready to go.
Comment #23
socketwench commented