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.
Add process plugin to implement substr.
This plugin is needed for #2225781: Migrate D6 i18n taxonomy vocabularies so setting to 8.1-x.
Comment | File | Size | Author |
---|---|---|---|
#15 | interdiff-2752591-13-15.txt | 3.58 KB | quietone |
#15 | 2752591-15.patch | 4.96 KB | quietone |
#13 | interdiff-2752591-8-13.txt | 4.02 KB | quietone |
#13 | 2752591-13.patch | 5.65 KB | quietone |
#10 | 2752591-8.patch | 5.2 KB | mallezie |
Comments
Comment #2
quietone CreditAttribution: quietone as a volunteer commentedComment #3
quietone CreditAttribution: quietone as a volunteer commentedAnd let's test it.
Comment #4
mallezieThis looks good to me.
I did some minor code style changes.
Can confirm plugin works, and would be nice addition.
Tests look good as well.
Since i only did some code style changes, i'll probably can RTBC it, if the bot is happy.
Comment #5
penyaskitoThis looks great!
Should we remove this one, as it will be never reached?
Also:
Could we add also a test for testing when "no start"/"no length"/"no start and no length" are given?
Note:
I'm not sure we want this blank line here... there are not any usages to compare to in core. But IMHO they should be next to each other.
Docs on phpunit puts them without a blank line too: https://phpunit.de/manual/current/en/appendixes.annotations.html#appendi...
Comment #6
penyaskitoTagging for the sprint.
Comment #7
mallezieI'll go further on this one.
Comment #8
mallezieThink i added the tests, not sure anymore is needed, let's wait what the bot says.
Removed the unreached assert.
Didn't remove the extra newlines (i've added them since code sniffer complained about them).
I see your reasoning, but perhaps make it a code style change.
Now only thing i can find in our code style is on https://www.drupal.org/node/1354
Comment #9
mallezieComment #10
mallezieJust a small test against the 8.2 branch
Comment #11
kevinquillen CreditAttribution: kevinquillen at Velir commentedPatch works (8.2.x), and upon changing the process plugin to substr here to prevent deduping roles (but still truncating to 32 characters), it also helps resolve #2716133: Roles are duplicated instead of updated existing roles.
Comment #12
mikeryanThe plugin itself looks functionally good, thanks. Some tweaks:
Needs just a bit more, like "This plugin returns a substring of the current value."
First "key" should be "value".
Ditto. And, should indicate that omitting the key returns the string from the start point (not the entire string if start > 0).
I'm not sure there's a point in creating a plugin in setUp() when most test methods create their own.
Do not call setUp in a test method.
Do not call setUp in a test method.
Also, it'd be good to have a test with both a start > 0 and a length provided.
Comment #13
quietone CreditAttribution: quietone as a volunteer commentedFixed all issues from #12 and removed the blanks lines as per #5.
Comment #14
dawehnerDid you considered to use a
@dataProvider
here? This could improve the readability of this test quite a bit.Comment #15
quietone CreditAttribution: quietone as a volunteer commented@dawehner, thx. I have changed the test to use @dataProvider.
Comment #16
quietone CreditAttribution: quietone as a volunteer commentedAlthough, the docs for Unicode::substr state that it follows the same behavior as PHP's own substr() function. But substr() return an empty string when length is NULL and Unicode:substr doesn't. Is there a reason for that?
Comment #17
dawehnerThis function is coming directly from
drupal_substr
in D7 etc. The initial conversion patch: https://www.drupal.org/files/drupal_1938670_00.patch had this behaviour already as well.I would guess its in order to distinct between no characters (0) and NULL (no cutting).
Comment #18
quietone CreditAttribution: quietone as a volunteer commented@dawehner, thank you.
Comment #19
mikeryanBlocks #2716133: Roles are duplicated instead of updated existing roles.
Comment #20
dawehnerFor future patches: https://thephp.cc/news/2016/02/questioning-phpunit-best-practices might be interesting to read
Comment #21
dawehnerI actually wanted to RTBC it though.
Comment #22
alexpottCommitted and pushed 05a3cb70fea9ec33581ab8e5c6b7cd60b455503d to 8.2.x and a72245a to 8.1.x. Thanks!
Fixed indentation on commit.