Hi agentrickard,

I'm getting the strangest PHP errors, noticed some of these before but never could reproduce. This time I can but it's still random...
When I use my default core search functionality, on some words/terms/keywords I get the following PHP errors;

* warning: Illegal offset type in isset or empty in sites/all/modules/domain/domain.module on line 1157.
* warning: Illegal offset type in sites/all/modules/domain/domain.module on line 1172.
* warning: Illegal offset type in sites/all/modules/domain/domain.module on line 1173.
* warning: in_array() [function.in-array]: Wrong datatype for second argument in sites/all/modules/domain/domain_source/domain_source.module on line 208.
* warning: current() [function.current]: Passed variable is not an array or object in sites/all/modules/domain/domain_source/domain_source.module on line 209.

Now this only happens when I search with certain words, in my case searching on 'uiterwaard' (without quotes) I always get this error.
Now if I search on another word (like a telephone number) from nodes that also have the word 'uiterwaard' thus the result from the search are the exact same nodes I'm not getting this error?? So it's not the content-type causing the error I think.

What could be the cause of this??

Cheers

Comments

agentrickard’s picture

This is on HEAD?

agentrickard’s picture

Status: Active » Postponed (maintainer needs more info)

You aren't on rc9 and you aren't on HEAD, so I need to know what functions are throwing these errors.

bartezz’s picture

Status: Postponed (maintainer needs more info) » Active

Another thing, this happens only when searching as user #1, they're also logged by watchdog.
When searching as anonymous I don't have this error.... not only NOT showing but also not logged by watchdog.

Cheers

bartezz’s picture

Version: 6.x-2.x-dev » 6.x-2.0-rc9

I am on rc9 with those patches we discussed in the other issue applied.

Cheers

agentrickard’s picture

Not helpful. I need to know what functions those line numbers correspond to.

bartezz’s picture

From watchdog:

Illegal offset type in isset or empty in /domain.module op regel 1157.
Illegal offset type in /domain/domain.module op regel 1172.
Illegal offset type in /domain/domain.module op regel 1173.
in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument in domain/domain_source/domain_source.module op regel 208.
current() [<a href='function.current'>function.current</a>]: Passed variable is not an array or object in domain/domain_source/domain_source.module op regel 209

Will post the functions asap

Cheers

bartezz’s picture

domain.module
function domain_get_node_domains($nid) {
  static $lookup = array();
  if (isset($lookup[$nid])) {   //Illegal offset type in isset or empty in /domain.module op regel 1157.
    return $lookup[$nid];
  }
  $domains = array('domain_id' => array(), 'domain_site' => FALSE);
  $result = db_query("SELECT gid, realm FROM {domain_access} WHERE nid = %d AND (realm = '%s' OR realm = '%s')", $nid, 'domain_id', 'domain_site');
  while ($data = db_fetch_object($result)) {
    // Transform the 0 to -1, since {domain_access} is unsigned.
    ($data->gid == 0) ? $gid = -1 : $gid = $data->gid;
    if ($data->realm == 'domain_id') {
      $domains['domain_id'][$gid] = $gid;
    }
    else if ($data->realm == 'domain_site') {
       $domains['domain_site'] = TRUE;
    }
  }
  $lookup[$nid] = $domains;  //Illegal offset type in /domain/domain.module op regel 1172.
  return $lookup[$nid];   //Illegal offset type in /domain/domain.module op regel 1173.
}
//domain_source.module
function domain_source_lookup($nid, $domains = array()) {
  global $_domain;
  $source = db_result(db_query("SELECT domain_id FROM {domain_source} WHERE nid = %d", $nid));
  if (empty($source)) {
    $source = variable_get('domain_default_source', 0);
  }
  // DOMAIN_SOURCE_USE_ACTIVE is the status for 'Use active domain.'
  else if ($source == DOMAIN_SOURCE_USE_ACTIVE){
    $source = $_domain['domain_id'];
  }
  if (empty($domains)) {
    $lookup = domain_get_node_domains($nid);
    $domains = $lookup['domain_id'];
  }
  if (!in_array($source, $domains)) {    //in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument in domain/domain_source/domain_source.module op regel 208.
    $source = current($domains);    //current() [<a href='function.current'>function.current</a>]: Passed variable is not an array or object in domain/domain_source/domain_source.module op regel 209
  }
  $domain_id = ($source == -1) ? 0 : $source;
  return domain_lookup($domain_id);
}
agentrickard’s picture

I suspect $nid is coming in empty. Why would that be?

There is another new patch coming, #615258: Clean up source domain handling, which changes this lookup behavior.

bartezz’s picture

Not sure... is there anything you want me to test here?

Cheers

bartezz’s picture

Status: Active » Closed (fixed)

Found the problem;

One of the nodes in the search results was set to "publish to:" [none checked] and "source domain:" [use active domain].
Now I don't know how this could have happened cause when I try to replicate these settings I can't submit the node and get a warning "publish to is a required field".
So somehwre along the line this got messed up??? But where? Can't find it in watchdog!

Closing for now, will open IF I find more info!

Cheers

agentrickard’s picture

Status: Closed (fixed) » Active

You could watchdog($nid) in domain_get_node_domains().

I seem to recall that I had an instance where the function was passing $node instead of $node->nid, and I think I fixed that yesterday.

So if the watchdog shows an Object instead of a number, then that's the problem.

agentrickard’s picture

Status: Active » Closed (fixed)

Probably while we were debugging the validation step on changes to Domain Source handling.

bartezz’s picture

Ah yes, that could be it!
Well I'll try the patch in the other issue tomorrow and leave this for now.

Cheers and thanx!