When you add url_alter to an installation profile the hook_requirements implementation fails:

( ! ) Fatal error: Call to undefined function db_result() in /path/to/site/includes/path.inc on line 55
Call Stack
#	Time	Memory	Function	Location
1	0.0050	383040	{main}( )	../install.php:0
2	0.0075	560144	install_main( )	../install.php:1174
3	0.1351	5501956	install_check_requirements( $profile = 'small_site', $verify = FALSE )	../install.php:109
4	0.1363	5504684	drupal_check_profile( $profile = 'small_site' )	../install.php:914
5	51.1490	9598328	module_invoke( 'url_alter', 'requirements', 'install' )	../install.inc:692
6	51.1490	9599092	call_user_func_array ( 'url_alter_requirements', array (2 => 'install') )	../module.inc:462
7	51.1491	9599220	url_alter_requirements( $phase = 'install' )	../module.inc:0
8	51.1499	9602768	url( $path = 'admin/settings/url-alter', $options = ??? )	../url_alter.install:44
9	51.1500	9606000	drupal_get_path_alias( $path = 'admin/settings/url-alter', $path_language = '' )	../common.inc:1715
10	51.1500	9606120	drupal_lookup_path( $action = 'alias', $path = 'admin/settings/url-alter', $path_language = '' )	../path.inc:111
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DamienMcKenna’s picture

Status: Active » Needs review
FileSize
2.27 KB

Here's a patch against the latest DRUPAL-6--1 that uses base_path() . 'admin/settings/url-alter' during the site installation because the url() function doesn't work yet.

DamienMcKenna’s picture

FileSize
4.01 KB

Here's another patch that works better with the code in the current DRUPAL-6--1 branch, specifically if the site is running an installation profile it does a simple estimate as to whether the custom_url_rewrite_inbound() and custom_url_rewrite_outbound() functions will work without loading the main module file itself.

jaydub’s picture

Status: Needs review » Reviewed & tested by the community

I tested this patch and it fixes the problem of the error on install via install profile. Probably could use another set of eyes but for now I'll mark as reviewed and tested.

jaydub’s picture

Status: Reviewed & tested by the community » Needs work
FileSize
4.01 KB

This part of the patch seems to be problematic:

- drupal_load('module', 'url_alter');
+ // Don't load try to load the module during installation.
+ if (!defined('MAINTENANCE_MODE') && constant('MAINTENANCE_MODE') != 'install') {
+ drupal_load('module', 'url_alter');
+ }
+

After install via install profile (success!) the code above spits out an error when hook_requirements() gets invoked.

error was:

Warning: constant() [<a href='function.constant'>function.constant</a>]: Couldn't find constant MAINTENANCE_MODE in url_alter_requirements() (line 35 of /opt/www/tng-fresh/sites/all/modules/contrib/url_alter/url_alter.install).

I presume that the problem is simply that the !defined('MAINTENANCE_MODE') should be defined('MAINTENANCE_MODE') as if the first is TRUE and then you invoke constant() you will get a PHP error.

Attached a patch of patch to flip the negation. Hopefully that results in intended behaviour.

Kars-T’s picture

Status: Needs work » Needs review
FileSize
3.99 KB

Hi

we had the same problem while running a dupal_make script and needed the patch. I believe jaydub is correct that the if shouldn't be !.
Otherwise this patch fixed a WSOD on install.

I did a few changes to the patch:

+++ url_alter.install	19 Apr 2010 16:27:40 -0000
@@ -31,19 +31,43 @@ function url_alter_requirements($phase) 
+  // Don't load try to load the module during installation.

Removed typo.

+++ url_alter.install	19 Apr 2010 16:27:40 -0000
@@ -31,19 +31,43 @@ function url_alter_requirements($phase) 
+  if (defined('MAINTENANCE_MODE') && constant('MAINTENANCE_MODE') != 'install') {

Changed to !== because the constant is a string and we should avoid uneccessary type checks.

+++ url_alter.install	19 Apr 2010 16:27:40 -0000
@@ -31,19 +31,43 @@ function url_alter_requirements($phase) 
+  ¶

Space after line end.

+++ url_alter.install	19 Apr 2010 16:27:40 -0000
@@ -31,19 +31,43 @@ function url_alter_requirements($phase) 
+    if (defined('MAINTENANCE_MODE') && constant('MAINTENANCE_MODE') == 'install') {

Changed == to === typed check.

+++ url_alter.install	19 Apr 2010 16:27:40 -0000
@@ -31,19 +31,43 @@ function url_alter_requirements($phase) 
+    // During normal usage

Comments should have a . at the end.

Powered by Dreditor.

DamienMcKenna’s picture

Status: Needs review » Reviewed & tested by the community

@jaydub, @Kars-T: Thanks for doing some cleanup on the patch, the last one in #5 works well. Is it kosher to mark it RTBC if I wrote the original patch?

Dave Reid’s picture

Can we just make it easier and skip the requirements check if MAINTENANCE_MODE = install?

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
2.95 KB

How's about this? Strictly speaking I see the value of checking to see if the functions exist elsewhere, i.e. the patch from #5 above.

jaydub’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #8 resolves for me both the issue with enabling via install profile as well as an issue with regular install at /admin/build/modules after using patch in #4 (problem with url_alter_is_disabled() not being defined yes but used in hook_requirements which is called into play on install).

erikwebb’s picture

FileSize
2.92 KB

Patch in #8 did not apply cleanly to 6.x-1.2. Re-rolled patch attached.

erikwebb’s picture

Status: Reviewed & tested by the community » Needs review
jhedstrom’s picture

Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community

Patch in #10 resolves the issue for me. Marking RTBC since it was a simple re-roll of #8. Also setting to major, as it really affects installation profiles.

Grayside’s picture

#10 worked for me.

gease’s picture

Yes,#10 solved the problem

hefox’s picture

Version: 6.x-1.2 » 6.x-1.x-dev

Patch needs to be applied to dev version or else causes fatal errors as url_alter_is_disabled doesn't exist in 1.2, but does in dev and patch uses it.

Grayside’s picture

@hefox covered it.

Anonymous’s picture

Here is an attempt to port patch in #10 to dev branch.

Anonymous’s picture

Oops. Missing }

Anonymous’s picture

Patch in #18 applies cleanly... but it doesn't seem to properly skip if running within an install profile. I'm posting a new patch that simply removes the requirements hook. This isn't a general purpose patch, it's for me personally in an install profile I control, so I don't need the requirements check.

Anonymous’s picture

Ok, what I ultimately settled on, was to disable the the requirements check if maintenance mode is set to install and if phase is set to install. This seems to make drush site-install happy.