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 code in _potx_find_context
does not support PHP's []
array syntax.
For example it won't process the following code correctly.
$b = new TranslationWrapper('TranslationWrapper string with context', [], ['context' => 'With context']);
Comment | File | Size | Author |
---|---|---|---|
#20 | interdiff.txt | 2.92 KB | Gábor Hojtsy |
#20 | 2598910-20.patch | 12.87 KB | Gábor Hojtsy |
#18 | 2598910-17.patch | 12.06 KB | Gábor Hojtsy |
#15 | 2598910-15.patch | 5.31 KB | Gábor Hojtsy |
#11 | 2598910.11.patch | 3.98 KB | alexpott |
Comments
Comment #2
alexpottHere's a failing test.
Comment #4
alexpott#2 had the wrong patch.
Comment #6
alexpottHere's an approach that works and does not break anything.
Comment #8
alexpottalexpott-- failed at patch creation
Comment #10
alexpottThis is awesome...
So we can't test this because Drupal 7 test infra will fail cause lint checking
Comment #11
alexpottOkay linting Drupal 8 code is not a good idea - let's rename it.
Comment #12
Gábor HojtsyYay, thanks! While the patch also parses
array(.... ]
and[....)
, those should hopefully not appear in Drupal code. :) There are other things that break more badly with bad code.So this is my only concern:
This second use of this function is not actually meant to find end of array, it was meant to figure out the end of the arg argument which may include functions invoked, etc. For example:
t('Boo @value', array('@value' => boo_load_multiple([1])[0]->id()) (a contrived example to contain all of long arrays, short arrays and methods :)
In this case the method invocations and arrays both go down to the nesting and we are interested when we come back out at the end of the arguments short or long array part :)
Comment #13
Gábor HojtsyAlso causes issues with #2601370: [META] Parsing notices with Drupal 8 RC2, adding as parent.
Comment #14
Gábor HojtsyComment #15
Gábor HojtsyMore test coverage with unique strings for different combinations of tokens and inlining the end of nesting check where it does not necessarily mean end of array. The test includes function calls, nested arrays, etc. to demonstrate that now :)
Comment #17
Gábor HojtsyI did not apply @alexpott's patch proper. Now with the rename of module to module.txt.
Comment #18
Gábor HojtsyComment #20
Gábor HojtsyTest was failing because it asserted a source string we did not have in the test anymore :) Adding one more test for a complicated options array and some docs.
Comment #22
Gábor HojtsyAll right, got this one in. Will see if this resolves the outstanding ones from #2601370: [META] Parsing notices with Drupal 8 RC2 :)