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.
See hook_link_alter() documentation
If you alter the Url object inside $variable['url'] nothing change because it's not used in the code after the alteration.
Comment | File | Size | Author |
---|---|---|---|
#16 | code_after-2675648-16.patch | 2.82 KB | Haza |
#12 | 2675648-12.patch | 2.8 KB | Bès |
#11 | make-test-fail-2675648-11.patch | 2.23 KB | Bès |
#7 | 2675648-7.patch | 2.71 KB | dawehner |
#5 | test-hook_link_alter-url-fix.2675648-5.patch | 2.8 KB | Bès |
Comments
Comment #2
Bès CreditAttribution: Bès at Happyculture commentedHere is a first patch that add a failing test demonstrating that hook_link_alter is not working.
Comment #3
Bès CreditAttribution: Bès at Happyculture commentedSet to Needs review to have the test bot show the failing test.
Comment #4
Bès CreditAttribution: Bès at Happyculture commentedHere is a patch that fix the test and make the altered data used by the code.
Comment #5
Bès CreditAttribution: Bès at Happyculture commentedGood version of the patch with the fix and the test in the same file.
Comment #7
dawehnerThis is indeed a problem. What about fixing it like this, which would be IMHO a bit easier to read at the end of the day?
Comment #8
chx CreditAttribution: chx at Smartsheet commentedTwo suggestions
$this->getMock('\Drupal\Core\Routing\UrlGenerator', array(), array(), '', FALSE, TRUE, TRUE); use the mock builder please
$options['url'] = (new Url('test_route_1'))->setUrlGenerator($this->urlGenerator);
the fewer references we use the better ; although of course the closure needs &$options but further referencing is unnecessary.
Comment #10
Fabianx CreditAttribution: Fabianx at Tag1 Consulting commentedRTBC - except for stylistic fixes needed.
Comment #11
Bès CreditAttribution: Bès at Happyculture commentedHere is an update of the tests with the fixes suggested by chx that shows the failing tests when the code is not fixed
Comment #12
Bès CreditAttribution: Bès at Happyculture commentedand the patch with the same test plus the fix.
Comment #14
Fabianx CreditAttribution: Fabianx at Tag1 Consulting commentedRTBC
Comment #15
catchNeeds a re-roll for 8.2.x
Comment #16
HazaJust re-rolling against 8.2.x
Comment #17
Fabianx CreditAttribution: Fabianx at Tag1 Consulting commentedBack to RTBC
Comment #19
catchCommitted/pushed to 8.2.x, thanks!
The 8.1.x patch no longer applies either, so this will need a re-roll for that too.
Comment #20
Bès CreditAttribution: Bès at Happyculture commentedPatch on #12 apply without warning on the 8.1.x branch for me. I don't know what to do.
Comment #22
catchNo you're right, not sure what went wrong my end.
Committed/pushed to 8.1.x, thanks!