- Issue created by @borisson_
- First commit to issue fork.
- Status changed to Needs review
9 months ago 8:31am 28 March 2024 - Status changed to Needs work
9 months ago 12:56pm 28 March 2024 - ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
๐ I don't think this is quite right yet.
- Status changed to Needs review
9 months ago 9:20am 29 March 2024 - Status changed to Needs work
9 months ago 12:24pm 29 March 2024 - Status changed to Needs review
9 months ago 1:56pm 29 March 2024 - Status changed to RTBC
9 months ago 2:53pm 29 March 2024 - ๐ง๐ชBelgium borisson_ Mechelen, ๐ง๐ช
This looks good to me, i don't think we should decrease the size even further.
- Status changed to Needs review
9 months ago 3:14pm 29 March 2024 - ๐ฌ๐งUnited Kingdom catch
What would happen if you had an existing field prefix that's invalid according to the new validation?
- ๐บ๐ธUnited States smustgrave
Is this something that can be fixed though after the field is created?
- ๐ฎ๐ณIndia narendraR Jaipur, India
I think that is already handled in
core/modules/field/src/Entity/FieldStorageConfig::__construct
if (!preg_match('/^[_a-z]+[_a-z0-9]*$/', $values['field_name'])) {
throw new FieldException("Attempt to create a field storage {$values['field_name']} with invalid characters. Only lowercase alphanumeric characters and underscores are allowed, and only lowercase letters and underscore are allowed as the first character");
} - Status changed to Needs work
9 months ago 10:16am 2 April 2024 - ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
- ๐ฎ๐ณIndia narendraR Jaipur, India
Adding
_
in the end of field prefix failedcore/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest::testFieldPrefix
. Either that test needs to be adjusted as per new validation rule or _ in the end of field prefix is not necessary. For now, I am removing the _ from field prefix end. - Status changed to Needs review
9 months ago 11:02am 2 April 2024 - Status changed to Needs work
9 months ago 1:10pm 2 April 2024 - ๐ฎ๐ณIndia narendraR Jaipur, India
- ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
Ah, I see โ I had only seen the two underscore-related commits (eafb29c0 and 5b82dd9a), not the one that fixed the regex (f7ea3188) โ sorry about that! ๐
Indeed, I don't think a trailing
_
is required for the prefix โ it could also be justfoo
as a prefix for example.I think this looks ready now, except for one nit (left a suggestion for it) and one question/bit of ambiguity.
- Status changed to Needs review
9 months ago 4:14pm 2 April 2024 - Status changed to RTBC
9 months ago 8:43am 3 April 2024 - ๐ฌ๐งUnited Kingdom catch
With #11 I actually meant what happens if the field prefix is over 30 characters already (although glad my vague question found a real bug).
- Status changed to Needs review
9 months ago 9:57am 3 April 2024 - Status changed to Needs work
9 months ago 1:14pm 4 April 2024 - ๐บ๐ธUnited States phenaproxima Massachusetts
I'm guessing we need an update path to handle that case. :(
- Status changed to Needs review
9 months ago 8:52am 5 April 2024 - Status changed to Needs work
9 months ago 2:55pm 5 April 2024 - ๐ฌ๐งUnited Kingdom catch
Sorry I'm not sure about the update path either - this is silently updating someone's config and field names aren't changeable once they make a new field, which they might do without realising.
I don't really believe anyone has a 40 (or even 31) character field prefix, but if their field prefix was
iloveantidisestablishmentarianismverymuch
would we really want to shorten that to<code>iloveantidisestablishmentarianismverymu
.If all that happens when the field prefix is too long, is they get a validation error if they try to save that form again, could we add a hook_requirements() warning, then they can fix it to a shorter string of their choosing? Or something like that seems OK as long as config import/export is unaffected.
- ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
#27: a 40-character long prefix is impossible already thanks to
\Drupal\field\Entity\FieldStorageConfig::preSaveNew()
doing:// Field name cannot be longer than FieldStorageConfig::NAME_MAX_LENGTH // characters. We use mb_strlen() because the DB layer assumes that column // widths are given in characters rather than bytes. if (mb_strlen($this->getName()) > static::NAME_MAX_LENGTH) { throw new FieldException('Attempt to create a field storage with an name longer than ' . static::NAME_MAX_LENGTH . ' characters: ' . $this->getName()); }
I agree that should be better documented though.
- Status changed to Needs review
8 months ago 10:49am 17 April 2024 - ๐ฎ๐ณIndia narendraR Jaipur, India
Not sure what next should be done in this issue, hence marking it for another review.
- Status changed to RTBC
8 months ago 9:12am 18 April 2024 - Status changed to Needs work
8 months ago 1:23pm 18 April 2024 - ๐ฌ๐งUnited Kingdom alexpott ๐ช๐บ๐
Discussed with @catch - I don't think we should have an update path here. Because as wim points out on the less youโd already have problems if it was over 31 charactersโฆ and practically you do with the new limit of 30โฆ every field name would have to only be 2 lettersโฆ so I just so think the upgrade path is worth it.
Also see #27
- Status changed to RTBC
8 months ago 1:51pm 18 April 2024 - ๐บ๐ธUnited States phenaproxima Massachusetts
Okay, I'm going to guess this is therefore RTBC once tests pass!
- ๐ฌ๐งUnited Kingdom alexpott ๐ช๐บ๐
Committed and pushed 6c6c22c36a to 11.x and fb746dae75 to 10.3.x. Thanks!
-
alexpott โ
committed fb746dae on 10.3.x
Issue #3417363 by narendraR, Wim Leers, catch, phenaproxima, alexpott:...
-
alexpott โ
committed fb746dae on 10.3.x
- Status changed to Fixed
8 months ago 2:03pm 18 April 2024 -
alexpott โ
committed e63b0c22 on 11.x
Issue #3417363 by narendraR, Wim Leers, catch, phenaproxima, alexpott:...
-
alexpott โ
committed e63b0c22 on 11.x
Automatically closed - issue fixed for 2 weeks with no activity.