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.
Currently, PURL is active all around the Drupal bootstrap, while it should only intervene in one place: drupal_path_initialize(). This is perfectly possible through hook_inbound_url_alter(), which PURL already implements.
Problems this causes:
- The admin theme is not being respected.
- Provider callbacks are run too late, not allowing the to change the site frontpage for instance.
Solution: Remove purl_init() and purl_custom_theme() and move the small piece of logic that triggers provider callbacks to hook_inbound_alter(), making sure it's only run once.
The patch below also fixes:
Comment | File | Size | Author |
---|---|---|---|
#3 | purl-2599098-3.patch | 2.07 KB | kristiaanvandeneynde |
Comments
Comment #2
kristiaanvandeneyndeComment #3
kristiaanvandeneyndeComment #4
kristiaanvandeneyndeHmm, I just noticed a drawback.
Some provides such as space_type_purl do some logic on $_GET['q'], but $_GET['q'] hasn't been altered yet because the provider callbacks now get called in the very first run of purl_get_normal_path() during purl_url_inbound_alter().
The problem is $_GET['q'] is only set to the normalized path after all inbound alters have been fired. This didn't use to be a problem because the provider callbacks were being called too late (in purl_init()), after $_GET['q'] had been set.
A solution could be to temporarily spoof $_GET['q'] and reset it to its original value after we fire the provider callbacks.
Comment #5
m.abdulqader CreditAttribution: m.abdulqader commentedI think this patch should solve you problem.
https://www.drupal.org/files/1473502-purl-init-2_0.patch
They used it in openscholar.
Regards
Comment #6
kristiaanvandeneyndeThat was an approach I considered, but if the path is only normalized in hook_init(), it's already too late for hook_custom_theme() and it's definitely too late for provider callbacks to change the front page.