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.
Hi,
I found an issue, when the url() function is called before the hook_init() the URL persistent functionality stop working. An example is the swftools module, which run this line: define('SWFTOOLS_DEFAULT_BG', url(drupal_get_path('module', 'swftools') . '/shared/swftools-default.jpg', array('absolute' => TRUE))); // A generic image for use in certain contexts.
that is executed when the module file is included.
I've created a patch against the PURL 6.x-1.0-beta4.
Thanks!
--
José Sánchez.
www.deviancefactory.com
Comment | File | Size | Author |
---|---|---|---|
#11 | url_rewrite_break-564512-11.patch | 1017 bytes | fuzzy76 |
Comments
Comment #1
vegardjo CreditAttribution: vegardjo commentedHia José,
my site build with OG and Spaces, and thus PURL, was also broken after installing SWFtools: all OG / space paths were removed from the links, so what should be
/mygroup/og/users/562/faces
became/og/users/562/faces
etc.Anyways, your patch fixed this for me, thanks!
Don't know if this qualifies as a community review so I'm not changing the tag.. :)
Comment #2
smk-ka CreditAttribution: smk-ka commentedSorry, but even if this patch seems like it fix things, it actually just tries to detect a prefix over and over again in a brute-force manner. This patch leads to a huge overhead since the PURL prefix detection is run on every invocation of url() or l() functions (and there can be LOTS of them on one page).
The real culprit in this case are modules that call Drupal's API functions from the global PHP namespace, which leads to code execution when the system has only halfway loaded – you can't even predict which modules files have already been included and which not, and hook_init() has not even run.
The only real solution to this problem is to banish modules that are calling Drupal API functions from the global namespace (yes, not even drupal_get_path() – use dirname(__FILE__) instead), since that's a no-go. SWFTools just needs to move the causal define() into hook_init() and everything is fine.
Comment #3
Stuart Greenfield CreditAttribution: Stuart Greenfield commentedGood spot. I've fixed this on branch DRUPAL-6--2, and it is also fixed in the development work on DRUPAL-6--3 pending the next commit.
Comment #4
vegardjo CreditAttribution: vegardjo commentedHia Stuart!
First, thanks a lot for SWFTools, it really makes a huge difference!
However, this bug above actually got me again today, and I had to install the Purl patch on a different site too, to be able to still use SWFTools. I'm afraid I don't have the skills to patch SWFtools myself, but any chance you could roll a patch for this issue (or explain how to manually fix it) so we can have SWFTools work properly with Spaces / PURL?
Best, Vegard
Comment #5
dergachev CreditAttribution: dergachev commentedTripped me up too.. had to finally install Komodo for the debugging fun!
We have the 2.5 version of SWFTOOLS.
Comment #6
lefnire CreditAttribution: lefnire commentedWorks for me now, I had to cvs checkout swftools -dev (2.5's back in April). Any chance of adding a release for the -dev branches? Or mayhap tagging this puppy as a new release?
Comment #7
vegardjo CreditAttribution: vegardjo commentedSeems the PURL patch (in addition to not being the right fix) also breaks Features beta 4. I did a CVS checkout of the 6.2 branch, found the fix, and manually updated my module. If someone else needs to fix this manually here's what you do:
in swftools.module, line 27, replace this line:
define('SWFTOOLS_DEFAULT_BG', url(drupal_get_path('module', 'swftools') . '/shared/swftools-default.jpg', array('absolute' => TRUE))); // A generic image for use in certain contexts
with this:
define('SWFTOOLS_DEFAULT_BG', 'shared/swftools-default.jpg'); // A generic image for use in certain contexts.
..or you could probably just run the dev version, but I chose not to in case it would introduce other problems!
Thanks again for SWFTools :)
Comment #8
that0n3guy CreditAttribution: that0n3guy commentedMan, I wish I would have seen this before I spent hours trying to figure out how I screwed up my open atrium install.
subscribing
Comment #9
Stuart Greenfield CreditAttribution: Stuart Greenfield commentedThis is fixed in 6.x-3.x.
Comment #10
pounardHello, I also experienced the bug and posted a quick and dirty patch at #960206: url() call outside any function context in swftools.module breaks some other modules init (duplicate bug). I'm posting this comment to have it appear on my dashboard and follow it.
Comment #11
fuzzy76 CreditAttribution: fuzzy76 commentedReroll against 2.5 because I maintain old stuff and swftools haven't had a stable release since 2009. :-/