Install profiles not working with CCK

csevb10 - March 31, 2008 - 23:24
Project:Drupal
Version:7.x-dev
Component:base system
Category:bug report
Priority:critical
Assigned:Unassigned
Status:needs work
Description

drupal_get_filename returns a different set of results (or rather returns results or doesn't return results) depending on the case that it falls into.
Before the db is active, if a call to drupal_get_path exists, elements falling into the else clause return results _iff_ it is a module and only in situations more apt for Drupal 4 than Drupal 6:
sites/{sitename}/modules/{modulename}.module
sites/{sitename}/modules/{modulename}/{modulename}.module
modules/{modulename}.module
modules/{modulename}/{modulename}.module

Since most modules now go into sites/all/modules rather than sites/{sitename} or /modules, (and since modules are placed in folders inside of the modules directory instead of placed in the modules directory parent) it seems to make sense to modify this logic.

The primary fault (and the way to reproduce this error) is when using a profile to install modules that have a call to drupal_get_path in the install files. CCK in particular has a call to drupal_get_path at the beginning of most of the .install files and therefore cannot install correctly via a profile.

Since both modules and themes support .info files at this point, I chose to search for {filename}.info so that it would correctly find both modules & themes (mirroring what you would find in the system table that would be hit if the db were active). This modifies the return of the else case in many situations, but I believe it is more accurate not less accurate.

Thoughts?

AttachmentSize
bootstap.inc-get_filename-patch.txt1.02 KB

#1

flobruit - April 2, 2008 - 23:39
Version:6.x-dev» 7.x-dev
Status:active» needs review

The patch looks good, and removes some code duplication in drupal_get_filename() by calling drupal_system_listing() instead of doing the check for the possible locations directly. I haven't tested this fix in a situation where drupal_get_filename() is called before the database is set up, but in all other cases the patched function behaves just like the original.

I didn't find any existing tests for this function, having some would be very helpful in this case.

Moving to 7.x, and we can backport this to 6.x later.

#2

Steven Jones - April 4, 2008 - 07:25
Status:needs review» needs work

By using drupal_system_listing which is in common.inc, you've made this function dependant on that include, and therefore if we don't have a database active, unusable until DRUPAL_BOOTSTRAP_FULL.

I'm going to set as code needs work because either you need to run a function_exists to make sure you can call drupal_system_listing or you need to provide a further fallback in drupal_get_filename as well, if we're before DRUPAL_BOOTSTRAP_FULL.

#3

csevb10 - April 4, 2008 - 16:15

I thought the same thing, but I can't find a situation where this function is called without common.inc being included. During the install process, common.inc is included, and once things are up and running, you're doing a full bootstrap, so common.inc is included. If you can give me an example of a case that I should protect against, that'd be supremely helpful. I, of course, can check for the function, but if the case never fails then it's sort of unwarranted overhead.

Also, the current system fails completely when it has to drop to this case for drupal_get_path, and this at least provides some functionality for that case that wasn't covered before. I want to cover the full scope of cases, but if we look at this as an incremental step, it seems like movement in the correct direction. That being said, if there are use-cases where this function gets called without common.inc being included, I would love to cover those cases.

#4

flobruit - April 4, 2008 - 16:36
Title:drupal_get_filename doesn't work correctly until the db is installed» Install profiles not working with CCK
Priority:normal» critical

Changing title to reflect the real problem. From the original issue:

The primary fault (and the way to reproduce this error) is when using a profile to install modules that have a call to drupal_get_path in the install files. CCK in particular has a call to drupal_get_path at the beginning of most of the .install files and therefore cannot install correctly via a profile.

If install profiles cannot use CCK, that's a big limitation on their use cases, so I'm also bumping this to critical.

#5

Senpai - April 4, 2008 - 18:08
Title:Install profiles not working with CCK» drupal_get_filename doesn't work correctly until the db is installed
Priority:critical» normal

Tested on a 7.x-dev, fully updated, and no existing database. I have fresh head checkouts of Views, CCK, and Admin_menu in my sites/all/contrib/ directory because they're required by the install profile I'm testing with.

Without the patch, I went to use an install profile, and got this error, proving that the installation bug in http://drupal.org/node/210752 hasn't been fixed yet.

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY fit DESC LIMIT 0, 1' at line 1 query: SELECT * FROM menu_router WHERE path IN () ORDER BY fit DESC LIMIT 0, 1 in /www/drupalhead/includes/menu.inc on line 315.

I can't proceed with this test until I get that thing sorted out, and when I do, I'll be sure to post some more details on the afore mentioned thread 210752.

#6

Senpai - April 4, 2008 - 18:25
Priority:normal» critical

I accidentally changed the status. Setting back to critical.

#7

Senpai - April 4, 2008 - 20:53
Title:drupal_get_filename doesn't work correctly until the db is installed» Install profiles not working with CCK

#8

Steven Jones - April 6, 2008 - 08:09

@csevb10 Okay, well we're fixing a serious bug here, and are worrying about some serious edge cases. Can you reroll a patch so that drupal_get_filename will first check for the database, then if that fails, do a function_exists for drupal_system_listing, and use that but, but if that fails, then it falls back to the old way, but add some more paths too.

That should cover most of the edge cases no? And still provide the updated functionality. The function is already built using failover, so it's more of an extension to the current functionality anyway.

#9

Steven Jones - April 7, 2008 - 06:22
Status:needs work» needs review

Something like this.

AttachmentSize
drupal-HEAD-241086.patch 1.68 KB

#10

csevb10 - April 8, 2008 - 16:48

That's a fair point. 'tis core code and all. :-P
Here's a slightly tighter version, I think, a little less code duplication.

AttachmentSize
bootstap.inc-get_filename-patch.txt 1.32 KB

#11

lilou - October 11, 2008 - 22:54

Patch still applies.

#12

Anonymous (not verified) - November 10, 2008 - 20:25
Status:needs review» needs work

The last submitted patch failed testing.

#13

Alkaaran - June 29, 2009 - 13:09

Using 6.12, this problem is not fixed yet, waiting for a patch please.

#14

Senpai - July 5, 2009 - 22:24
Status:needs work» reviewed & tested by the community

Chasing HEAD. Patch looks good.

This patch could use a test or two, but for what?
A) Check to see if the $files[$type][$name] array is populated with recognizable strings?
B) See if function_exists('drupal_system_listing') is coming back TRUE so we don't accidentally add things that break core later? (since there's no calls that fail right now)
C) ...

AttachmentSize
241086_bootstrap_inc_get_filename.patch 1.35 KB

#15

Senpai - July 5, 2009 - 22:25
Status:reviewed & tested by the community» needs review

Lets see if the TestBot likes it...

#16

System Message - July 5, 2009 - 22:35
Status:needs review» needs work

The last submitted patch failed testing.

#17

Senpai - July 6, 2009 - 02:32
Status:needs work» needs review

Odd, HEAD installs perfectly for me with this patch applied. Don't know what the problem is.

#18

System Message - July 31, 2009 - 09:43
Status:needs review» needs work

The last submitted patch failed testing.

#19

Senpai - July 31, 2009 - 21:29

Ahh, the install.php is failing due to a Warning: preg_match() [/www/manual_php/function.preg-match.html]: Delimiter must not be alphanumeric or backslash in /www/drupalhead/includes/file.inc on line 1652 error.

 
 

Drupal is a registered trademark of Dries Buytaert.