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:

  1. The admin theme is not being respected.
  2. 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:

CommentFileSizeAuthor
#3 purl-2599098-3.patch2.07 KBkristiaanvandeneynde
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kristiaanvandeneynde created an issue. See original summary.

kristiaanvandeneynde’s picture

Issue summary: View changes
kristiaanvandeneynde’s picture

Title: PURL providers activated too late. » PURL activated too late.
Status: Active » Needs review
FileSize
2.07 KB
kristiaanvandeneynde’s picture

Hmm, 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.

m.abdulqader’s picture

I think this patch should solve you problem.

https://www.drupal.org/files/1473502-purl-init-2_0.patch

They used it in openscholar.

Regards

kristiaanvandeneynde’s picture

That 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.