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 call to drupal_get_path() in hook_requirements ultimately will do a DB query on the system table. However during install profiles, the database is not yet available and the call to drupal_get_path() will cause the entire install profile to fail.
This patch circumvents the use of drupal_get_path() and uses dirname(__FILE__) instead; the same approach used by CCK to get around this problem.
Comment | File | Size | Author |
---|---|---|---|
#34 | 325831-jquery-ui-bug.jpg | 82.29 KB | coltrane |
#30 | jquery_ui install screenshot.jpg | 858.09 KB | jonathan1055 |
#28 | _325831.jquery_ui.readme_link.d6.patch | 1.02 KB | jonathan1055 |
#16 | jquery_ui_325831.patch | 1.57 KB | drewish |
#10 | 325831-jquery_ui-install-profile.patch | 1.37 KB | hanoii |
Comments
Comment #1
quicksketchThere was a second call to drupal_get_path() at the top of jquery_ui.module, this patch applies the same approach there also.
Comment #2
KingMoore CreditAttribution: KingMoore commentedPatch looks good.
Comment #3
ZMan9854 CreditAttribution: ZMan9854 commentedHi there - I was creating an installation profile for a configuration that includes jquery_ui.module, and I ran into the problem that required this patch. After I patched the module from the latest dev snapshot (Nov 4) and got the profile working, I see now that the javascript file paths are incorrect. I get for example (from HTML head):
when it was previously:
Forgive me if it's just my misconfiguration : ) Thanks!
Comment #4
sun@Zman9854: Thanks for testing and reporting this. Looks like a reasonable effect of the proposed change to me.
Comment #5
James Andres CreditAttribution: James Andres commentedSlightly modified version of the above patch. Works well for me.
The only change is doing a check on the MAINTENANCE_MODE constant before choosing whether to use dirname or drupal_get_path.
Hope it helps,
James
Comment #6
ksenzeeThis version gets rid of a php notice. I think it's good to go.
Comment #7
DamienMcKenna(please ignore, wrong issue)
Comment #8
sunThanks for reporting, reviewing, and testing! Committed to all branches.
A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.
Comment #10
hanoiiI am afraid this is still an active issue.
When jquery is not there, the link to the README also uses drupal_get_path() (and url()) which both functions executes db queries on tables that are not there.
This went undetected probably because the previous patches were tested with a module with jquery.ui installed.
I am attaching a patch that tries to solve this using something similar to the above solutions, although with a twist as now it has to be a link. The change is within the t() description as is the following:
for
I am honestly not very proud about this patch, specially wondering if this will work on windows, but I couldn't find any other way around it. My real suggestion would be to remove that link altogether and just leave README.txt as plain text (no link).
Comment #11
jp.stacey CreditAttribution: jp.stacey commentedI can confirm the patch in #10 works: we were still having problems here too. As the patch shows the relevant problem comes from the url() call to create the link to the README.txt in the "Requirements problems" warning message if you don't have jquery.ui installed:
This patch solves that error for me.
Comment #12
sunThanks for reporting, reviewing, and testing! Committed.
A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.
Comment #14
jonathan1055 CreditAttribution: jonathan1055 commentedHi,
Sorry to re-open this, but I thought it better to do it here, instead of starting a new issue, as the suggested solution in the patch in #10 does not work in all cases. It might be fine within an install profile, but when simply adding the module to an existing installed site, the readme link can be incorrectly formed.
The problem is that the derived path using dirname(str_replace(getcwd(), '', __FILE__)) contains a / at the start which means the href location is built from the host but excludes the path to the drupal root. This may not be apparent on some sites, but on mine the path to the drupal root
is http://localhost:8888/mysite whereas the code as it stands in the latest dev version, creates an href of http://localhost:8888/sites/all/files/modules/jquery_ui/README.txt, ie the path 'mysite' is missing.
If the leading slash is removed this does not help because the href location then becomes relative and we get
http://localhost:8888/mysite/admin/build/sites/all/modules/jquery_ui/REA...
So, when not in installation mode, I think the correct way to generate links to specific files is to start the link with $GLOBALS['base_url'] which will give http://localhost:8888/mysite. This is how links to file attachments are created in file_create_url() in /includes/file.inc. The problem with using the url() function, even when the db is available, is that it is designed for urls and adds ?q= if clean urls are not enabled, which does not work either, because the path is not found in the menu router table.
We could test for MAINTENANCE_MODE == 'install' just as is done in the patch in #6 and leave the result unchanged for during installation (if what is currently coded works, which I have not tested but the thread above implies is OK) but change it to use $GLOBALS['base_url'] so that it works correctly when the db is installed.
If you think that is the way to do it let me know and I'll make a patch. Or if I have got it all wrong, let me know that too.
Jonathan
Comment #15
drewish CreditAttribution: drewish commentedStill experiencing this with 6.x-1.3 which was released on June 20--after the April 2 commit.
I'm trying to use the hostmaster installation profile:
Comment #16
drewish CreditAttribution: drewish commentedOkay I think we can get around this simply by passing the 'alias' => TRUE option url() to indicate that it shouldn't look for a path alias.
Comment #17
drewish CreditAttribution: drewish commentedModifying the subject to match the remaining issue.
Comment #18
jonathan1055 CreditAttribution: jonathan1055 commented@15 Drewish, I think you are mistaken with your versions. 1.3 was released on 21 June 2009 according to the project page and the .info (you may have saw June and thought this was 2010). It is only the dev version which contains the commit of 2nd April 2010, and the url() call has been removed because line 34 in .install is now:
My question in #14 remains open, though.
Jonathan
Comment #19
drewish CreditAttribution: drewish commentedYup, I was mistaken. Pretend I asked for a new stable release ;)
Comment #20
sunerm, so the remaining issue is fixed already? Or what's left here?
Comment #21
hanoiiI think it's fixed, #18 is right just looked at the code. Maybe it's time for a new stable release?
Comment #22
jonathan1055 CreditAttribution: jonathan1055 commentedI've just checked the latest dev, and hook_requirements() in jqueryui.install has not changed since the problem I reported on 19th June. So the error in #14 is not resolved. What do you think of my suggestion I made then:
I am happy to code this and make a patch if you think it is the correct way to do it.
Comment #23
hanoiiIt's not my call to make, but I think that if your suggestion of using $_GLOBAL['base_ref'] or rather base_path() which is the drupal equivalent to that works for both installation profiles/normal installation of the module that should be what you should provide a patch for rather than testing for something which is not really need it.
Comment #24
jonathan1055 CreditAttribution: jonathan1055 commented@23, Hanoii, yes of course you are right that it is better to find one fix which works in both scenarios. I don't know much about installation profiles, I have tried to read the drupal documentation but I've not found out yet whether $GLOBALS['base_url'] is defined at that stage. Could anyone tell me?
Comment #25
James Andres CreditAttribution: James Andres commentedjonathan1055, it should be.
$GLOBALS['base_url']
is defined in bootstrap.inc very early, specifically in conf_init(). The install system is mostly a normal Drupal bootstrap, just like any other page load.Comment #26
sunI'm tempted to remove that link to README.txt entirely. This just seems to be a major waste of developer time, which could be better spent with far more important improvements.
Comment #27
hanoii@sun, second that :)
Comment #28
jonathan1055 CreditAttribution: jonathan1055 commented@25 Thanks James for the info. The solution is really simple now! Just need to add $GLOBALS['base_url'] infront of the dirname(str_replace(getcwd(), '', __FILE__)) to make it an absolute ref containing the correct full path. This should work for all cases, so we do not have to test for installation mode.
Attached is a patch against the current dev release (11th July)
Comment #29
sunNo, that doesn't work for Drupal installed in a sub-directory...
Comment #30
jonathan1055 CreditAttribution: jonathan1055 commentedI've tested it on a drupal installation in a sub-directory on my localhost and it seems to work fine. The attached screenshot shows the module page in a drupal site installed at drupal6_in_subdir/main. Also added my standard block of global variables at the right hand side. $GLOBALS['base_url'] is http://localhost:8888/drupal_6_in_subdir/main. The hover text in the status bar shows the correct link.
I must be mis-understanding what you mean, as it seems OK to me.
Jonathan
Comment #31
coltrane+1 to just removing the url() to the README file, though I'll probably test the patch in #28 too.
Comment #32
quicksketchLet's just get rid of the link, this whole thing is silly.
Comment #33
sunThanks for the confirmation. Done, in all branches.
Comment #34
coltraneThe patch does not work in #28 when the site is in a subdirectory for me. See the attached screenshot. It does work if it's the root site (example.com).
Comment #35
coltraneSorry, crossposted.
Comment #36
quicksketchThanks sun!