According to https://www.drupal.org/node/3367037 → this is supposed to work and it is not Ajax.
Is this bug replicated on a newly-installed and unmodified Drupal site?
See the Issue tags field description for the reason I removed tags.
- First commit to issue fork.
- Status changed to Postponed: needs info
9 months ago 4:31am 17 March 2024 - 🇫🇷France nod_ Lille
Can you type in the JS console:
console.log(drupalSettings.machineName)
and post the result here please? - Status changed to Active
9 months ago 5:12pm 17 March 2024 - 🇸🇪Sweden UserOne.se
#2, #4
Yes, I created a new DB, new instance of Drupal 10 as a new project with "Workflow" as the only added module. All installations were performed as instructed on https://www.drupal.org/docs/getting-started/installing-drupal/get-the-code → i.e.- composer create-project drupal/recommended-project newD10
- Installation and configuration in browser "as usual"
- composer require drupal/workflow
- Enabling only workflow module and no submodules
- Under Admin -> Configuration -> Workflow I choose (i.e. click on button) "+ Add workflow"
- Textbox with labe "Label*" I type "Flö"
- Text to the right of the textbox says "Machine name: fl [Edit] (see attached image "fl1.png"
- Javascript console - see attached image "fl2.png"
Please note:
Since I reinstalled and rechecked... this might not be D10 issue,
it could be Workflow related since correct behavior is discovered
in other situation in D10 not related to Workflow.
In such case this might need to be moved to Workflow issue queue - could you do it or should I? - 🇫🇷France nod_ Lille
It happens on date format inputs too, thank you for the detailed steps.
Downgrading to normal since there is a workaround (editing the machine name field directly) and the feature is for admin/developers, not regular site users. This is not related to ajax so moving to the base system.
- 🇸🇪Sweden UserOne.se
Oops, date formats? Did not see that one comming.
You are welcome (regarding detailed reporting).
Good job on spotting date format problem, excluding Ajax, downgrading and moving. - Assigned to jmaxant
- Merge request !8316#3428652 - fix js error in Date Formats machine name generation when using accented characters in label → (Open) created by jmaxant
- 🇫🇷France jmaxant
Hi,
I just pushed a commit in mr !8316 fixing this error.First time contributing to the core, so please let me know if I didn't apply proper workflow, naming or anything else.
- Issue was unassigned.
- Status changed to Needs review
7 months ago 1:04pm 6 June 2024 - Status changed to Needs work
7 months ago 1:35pm 6 June 2024 - 🇺🇸United States smustgrave
Ran test-only feature
1) Drupal\Tests\system\FunctionalJavascript\System\DateFormatTest::testDateFormatXss Behat\Mink\Exception\ResponseTextException: The text "Machine name: label_with_special_characters" was not found anywhere in the text of the current page. /builds/issue/drupal-3428652/vendor/behat/mink/src/WebAssert.php:907 /builds/issue/drupal-3428652/vendor/behat/mink/src/WebAssert.php:293 /builds/issue/drupal-3428652/core/tests/Drupal/Tests/WebAssert.php:975 /builds/issue/drupal-3428652/core/modules/system/tests/src/FunctionalJavascript/System/DateFormatTest.php:77 FAILURES! Tests: 1, Assertions: 6, Failures: 1.
Which shows coverage.
Left 1 small comment on the MR though.
Good job for a first MR.
- 🇮🇳India prashant.c Dharamshala
Prashant.c → made their first commit to this issue’s fork.
- 🇮🇳India prashant.c Dharamshala
- Resolved this https://git.drupalcode.org/project/drupal/-/merge_requests/8316#note_323107 as the constant was not required because was not being used anywhere else
- Keeping the issue in NW as per https://www.drupal.org/project/drupal/issues/3428652#comment-15630065 🐛 Broken auto creation of machine name field Needs work
- Tested with content type fields machine names, special characters/non-ASCII characters are being replaced properly, tested with é, à, ö, ñ, etc.
Thanks!
- 🇫🇷France jmaxant
Weirdly enough, tests succeed on a ddev install with
ddev/ddev-selenium-standalone-chrome
for functionalJS tests.
I'll have a deeper look later this week, maybe there is some configuration discrepancies on my env vs drupal-ci. - Assigned to jmaxant
- Issue was unassigned.
- Status changed to Needs review
6 months ago 2:07pm 21 June 2024 - 🇫🇷France jmaxant
Ok, so, after much contemplation and reading the docs, it seems the Test-only changes job is supposed to fail ? I feel a little silly tbh, but hey, I learnt something new !
Changing the status to need review.
- Status changed to RTBC
6 months ago 5:00pm 23 June 2024 - 🇺🇸United States smustgrave
Feedback on the MR appears to be addressed.
Re-ran the test-only job after the pattern change and it still fails as expected, so coverage is still good.
- Status changed to Needs review
6 months ago 1:43pm 5 July 2024 - 🇫🇷France nod_ Lille
I think the problem is elsewhere. We're passing a regex to slugify for the allowedChars option where it expects a list of characters (so, not a regex). It's fine to do that because the replace pattern is used before sending the string to slugify.
Tried a different approach, let's see what testbot says.
- 🇫🇷France nod_ Lille
the tests in
machineNameTransliterationTest.js
are not correct, it doesn't test how things are used in Drupal from the PHP - Status changed to Needs work
6 months ago 8:17pm 5 July 2024 - 🇺🇸United States smustgrave
So sounds like the test needs to be corrected? Would almost say it should be separate from this issue and this one postponed but probably can roll the two together
- First commit to issue fork.
- 🇫🇷France nod_ Lille
Well I wanted to keep that test and fix the code instead. There is no reason to have 2 underscores in the transformed name.
- 🇬🇧United Kingdom alexpott 🇪🇺🌍
Oh I see... the problem is with date formats and workflow specifically because they have
'([^a-z0-9_]+)|(^custom$)',
and this is not going to work with what theallowedChars
option does forslugify
.My guess is that the workflow module has incorrectly copy pasted the date format code as I can't see why custom would not be allowed there. But regardless date format machine names are broken in the same way.
This is going to be fun to fix in a way that supports both
'replace_pattern' => '([^a-z0-9_]+)|(^custom$)',
and'replace_pattern' => '[^a-z0-9_]+',
- 🇬🇧United Kingdom alexpott 🇪🇺🌍
It's turns out that 🐛 Machine name generation is way too slow Fixed was built on an incorrect premise. That replace_pattern was always compatible with allowedChars - that's just not true. We need to do the replacing ourselves. So we transliterate and then do the replacement and do not use slugify.
- Status changed to Needs review
4 months ago 2:43pm 20 August 2024 - 🇬🇧United Kingdom alexpott 🇪🇺🌍
alexpott → changed the visibility of the branch fix/3428652d-date_format_machine_name_pattern_replacement to hidden.
- 🇬🇧United Kingdom alexpott 🇪🇺🌍
alexpott → changed the visibility of the branch 3428652-broken-auto-creation to hidden.
- 🇬🇧United Kingdom alexpott 🇪🇺🌍
alexpott → changed the visibility of the branch 11.x to hidden.
- 🇬🇧United Kingdom alexpott 🇪🇺🌍
@nod_ I agree with the latest fix. Think we should add test coverage of the bug exposed here.
- 🇬🇧United Kingdom alexpott 🇪🇺🌍
I checked that the transliteration per language is being tested and it is - in \Drupal\FunctionalJavascriptTests\MachineName\MachineNameTransliterationTest - so we have test coverage of the changes how we build the replace array. I slightly improved the test because it feels in scope.
I this issue is ready and will commit once rtbc.
- Status changed to RTBC
4 months ago 6:29pm 21 August 2024 Changes look good.
Tested locally on latest 11.x with standard profile install. No JS errors when adding these date formats:
Actually, one question/nit about this:
(function ($, Drupal, drupalSettings, transliterateLibrary) { ... const transliteratedSource = transliterateLibrary(source, { replace }); ... })(jQuery, Drupal, drupalSettings, transliterate);
Can the "transliterate" global object be passed into the the self-invoking function as "transliterate" instead of "transliterateLibrary"? It could be helpful to be able to grep for "transliterate(" for uses in JS code.
- 🇫🇷France nod_ Lille
We have a method on the Drupal object called transliterate too, if you search for it now you'll find all the Drupal calls, it's to make it explicit this is not the same thing.
We have a method on the Drupal object called transliterate too, if you search for it now you'll find all the Drupal calls, it's to make it explicit this is not the same thing.
Makes sense. Can stay at RTBC.
- Status changed to Fixed
4 months ago 8:31am 22 August 2024 - 🇬🇧United Kingdom alexpott 🇪🇺🌍
Committed and pushed 73ec28542e to 11.x and adc4219ee6 to 11.0.x and 2ca2d354d0 to 10.4.x and 747c866073 to 10.3.x. Thanks!
Backported this to 10.3.x as a bug fix with no API concerns.
-
alexpott →
committed 747c8660 on 10.3.x
Issue #3428652 by nod_, jmaxant, alexpott, prashant.c, godotislate,...
-
alexpott →
committed 747c8660 on 10.3.x
-
alexpott →
committed 2ca2d354 on 10.4.x
Issue #3428652 by nod_, jmaxant, alexpott, prashant.c, godotislate,...
-
alexpott →
committed 2ca2d354 on 10.4.x
-
alexpott →
committed adc4219e on 11.0.x
Issue #3428652 by nod_, jmaxant, alexpott, prashant.c, godotislate,...
-
alexpott →
committed adc4219e on 11.0.x
-
alexpott →
committed 73ec2854 on 11.x
Issue #3428652 by nod_, jmaxant, alexpott, prashant.c, godotislate,...
-
alexpott →
committed 73ec2854 on 11.x
Automatically closed - issue fixed for 2 weeks with no activity.