This is a patch to the settings_domain_prefix.inc and the domain.module so that it will allow hook_domaincron to change the the global $dbprefix variable so that it will allow domain prefixing changes on cron.

Enjoy!

Comments

agentrickard’s picture

What, if anything did you change in the domain prefix include file? The patch rewrote the entire file, but I can't see why.

grndlvl’s picture

Ya i do not know why the diff did the whole file really strange considering I only changed

-function _domain_prefix_load() 
+function _domain_prefix_load($domain = NULL) 

and added this conditional in


    if (is_null($domain)) {
      // Cribbed from bootstrap.inc -- removes port protocols from the host value.
      $_subdomain = strtolower(implode('.', array_reverse(explode(':', rtrim($_SERVER['HTTP_HOST'], '.')))));
      // Lookup the active domain against our allowed hosts record.
      $domain = db_fetch_array(db_query("SELECT domain_id FROM {domain} WHERE subdomain = '%s'", $_subdomain));      
    }

If you would like I do a up and try to do the diff again.

agentrickard’s picture

I wonder if we need to do the same for Domain Conf?

grndlvl’s picture

Status: Needs review » Postponed

Do not commit this yet, there may be a problem. I need to retest a few things.

Thanks

grndlvl’s picture

Status: Postponed » Needs review

This patch does work perfectly for me and I am currently using it on http://wheretraveler.com/ just one issue that I found is that if the function that is being called within hook_domaincron has static variables inside it then the new queries for the table prefixing will not be taken into account.
For example:

***Note** One of the tables I have domain prefixed is term_hierarchy so that each domain can have its own separate parent child relationships with taxonomy.

I was calling a function within hook_domaincron that called taxonomy_get_tree() and it has static variables $children, $parents, $terms. This was a problem because where ever cron was being ran it would pull that domains parent child relation ship out of that specific domains table. So in order to remedy this I added an additional parameter to taxonomy_get_tree() that allows me to tell the function to not use the static variables when I run this from a specific function.

The Call

  $taxonomy_parents = taxonomy_get_tree($vid, 0, -1, 1, TRUE);

The fix

function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL, $flush = FALSE) {
  if (!$flush) {
    static $children, $parents, $terms;
  }
...

For more information on static variable fixes. See Here!

I will also roll this patch for the taxonomy module I will post the link here as soon as I do.
The patch for taxonomy_get_tree

grndlvl’s picture

Version: 5.x-1.4 » 6.x-1.0-rc2
StatusFileSize
new2.28 KB

Here is a patch for 6.x, should work not tested I do not have a six install to test at the time.

agentrickard’s picture

Status: Needs review » Fixed

There was a typo in the D6 patch, but this has ben committed to both branches.

Nice catch.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.