Fatal Error :-S

Zahor - October 27, 2008 - 01:33
Project:Subdomain
Version:6.x-1.4
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:postponed (maintainer needs more info)
Description

I get a Fatal Error: Call to undefined function subdomain_url_rewrite_inbound() ...in settings.php.
Don't understand this error since the module is installed and the function is there.

I'm confused. The subdomain_url_rewrite_outbound() works fine.

#1

setvik - November 3, 2008 - 12:20
Status:active» postponed (maintainer needs more info)

Check the spelling on both functions: are they both spelled correctly?

Can you paste the relevant section of your settings.php file in a comment below?

#2

Zahor - November 4, 2008 - 03:51

Modified to stop fatal errors (with function_exists):

function custom_url_rewrite_outbound(&$path, &$options, $original_path) {

    // Used by the Subdomain module to generate URLs with subdomains
    if (module_exists('subdomain')) {
      subdomain_url_rewrite_outbound($path, $options);
    }
  }

  function custom_url_rewrite_inbound(&$result, $path, $path_language) {

    // Used by the Subdomain module to correctly interpret URLs with subdomains
    if (module_exists('subdomain')) {
if(function_exists(subdomain_url_rewrite_inbound)) {
      subdomain_url_rewrite_inbound($result, $path, $path_language);
  }
    }
  } 

#3

brandontrew - May 19, 2009 - 18:51

This code worked at last!!!!

#4

held69 - June 3, 2009 - 10:38

Yep works!!

#5

doublejosh - July 22, 2009 - 20:02

ummm..... doesn't seem right to just remove that from the subdomain settings.php additions.

I added the check just to get the module limping along and found the outbound rewrites to work, but the inbounds do not point to the node, which would make sense when commenting out that function reference in the settings.php file.

Helps?

#6

jp.stacey - August 4, 2009 - 15:23

I've done a bit of digging, and it seems it depends on what other modules you've got enabled.

Here's how you can dig yourself:

<?php
 
function custom_url_rewrite_inbound(&$result, $path, $path_language) {
 
// Used by the Subdomain module to correctly interpret URLs with subdomains
 
if (module_exists('subdomain')) {
    if(!
function_exists('subdomain_url_rewrite_inbound')) {
     
debug_print_backtrace(); exit();
    }
   
subdomain_url_rewrite_inbound($result, $path, $path_language);
  }
}
?>

View the source in that page. You should see a backward look at what function called what function, called what function etc. Look at what module tried to call the function that little bit too early. In my case it was og_user_roles, and here's my sample output:

#0 custom_url_rewrite_inbound(admin/build/path/subdomain, admin/build/path/subdomain, ) called at [/var/www/drupal/drupal-6/includes/path.inc:136]
#1 drupal_get_normal_path(admin/build/path/subdomain) called at [/var/www/drupal/drupal-6/includes/path.inc:18]
#2 drupal_init_path() called at [/var/www/drupal/drupal-6/includes/bootstrap.inc:1067]
#3 _drupal_bootstrap(7) called at [/var/www/drupal/drupal-6/includes/bootstrap.inc:983]
#4 drupal_bootstrap(8) called at [/var/www/drupal/drupal-6/sites/default/modules/groups/og_user_roles/og_user_roles.module:2157]
#5 og_user_roles_all_roles(... trimmed ...) called at [/var/www/drupal/drupal-6/sites/default/modules/groups/og_user_roles/og_user_roles.module:1288]
#6 og_user_roles_boot()
#7 call_user_func_array(og_user_roles_boot, Array ()) called at [/var/www/drupal/drupal-6/includes/module.inc:450]
#8 module_invoke(og_user_roles, boot) called at [/var/www/drupal/drupal-6/includes/bootstrap.inc:585]
#9 bootstrap_invoke_all(boot) called at [/var/www/drupal/drupal-6/includes/bootstrap.inc:1044]
#10 _drupal_bootstrap(5) called at [/var/www/drupal/drupal-6/includes/bootstrap.inc:983]
#11 drupal_bootstrap(8) called at [/var/www/drupal/drupal-6/index.php:16]

You can see the custom_url_rewrite_inbound hit, followed by some Drupal internals, followed by a hook_boot implementation for og_user_roles.

The problem happens in Drupal's bootstrap phase. In this phase, Drupal only brings in the modules it really needs: these are identified by having a hook_boot implementation.

Now, there does exist a subdomain_boot. However, it's only brought in by Drupal when that module is being bootstrapped, and by default modules get summoned in alphabetical order. Hence og_user_roles tries to rewrite a URL and keels over.

Solution: open a MySQL prompt and type UPDATE system SET weight = -200 WHERE name = 'subdomain'; You can set the weight to any negative number, as long as it weights the module above whatever's calling it. To see what the offending module is weighted at, type SELECT WEIGHT FROM system WHERE name = 'og_user_roles';, replacing that with whatever module came out of the debug_print_backtrace.

If this works, then this isn't on its own a bugfix for the module: it also needs to go into the module's .install file, as it's necessary for the hook_boot trick to work properly!

 
 

Drupal is a registered trademark of Dries Buytaert.