I have a single subdomain configured and 'blog' selected under 'Use this domain for the following types of posts'. After creating a blog post, I'm receiving several errors reading 'warning: in_array(): Wrong datatype for second argument in ... multidomain/multidomain.module on line 466.'

These errors persist after deleting the blog node associated with the first instance of these errors. I suspect that other people would have observed this behavior since the latest release. Could there be something I am missing?

Comments

nedjo’s picture

I'll have a look at this as soon as I get a chance, likely tomorrow (Tuesday).

ezra-g’s picture

Thank you! I'm debugging now to see if I can find anything in the next hour.

ezra-g’s picture

Some preliminary investigation:
On line 466

 $page_match = in_array($node->type, array_keys($info['types']) && $info['types'][$node->type]);

I isolated line 466 into two separate statements.
The first part evaluated without error but evaluating (in_array($node->type,$info['types'][$node->type])) threw an error.

If an example $info array looks like this:

Array
(
    [url] => http://a.b.com
    [domain] => http://a.b.com
    [weight] => 0
    [variables] => Array
        (
            [theme_default] => theme1
        )

    [types] => Array
        (
            [blog] => blog
            [page] => 0
            [story] => 0
        )

    [visibility] => 
    [pages] => 
    [init] => 
    [op] => Submit
    [submit] => Submit
    [form_token] => 72abb4226cde03f6dc281d0ffd7986f0
    [form_id] => multidomain_domain_settings

Then $info['types'][$node->type] is a value, not a key.

I hope this is helpful.

kgriffin’s picture

I am getting the same error. After looking at the code and the example ezra-g provided, it seems you are looking for a key, value pair in the second level of a multi-dimensional array...I am not a php expert by any means, but I looked into in_array in the PHP manual online and found the following:

/**
 * Search for a key and value pair in the second level of a multi-dimensional array.
 *
 * @param array multi-dimensional array to search
 * @param string key name for which to search
 * @param mixed value for which to search
 * @param boolean preform strict comparison
 * @return boolean found
 * @access public
 */  
function findKeyValuePair($multiArray, $keyName, $value, $strict = false)
{
    /* Doing this test here makes for a bit of redundant code, but
     * improves the speed greatly, as it is not being preformed on every
     * iteration of the loop.
     */
    if (!$strict)
    {
        foreach ($multiArray as $multiArrayKey => $childArray)
        {
            if (array_key_exists($keyName, $childArray) &&
                $childArray[$keyName] == $value)
            {
                return true;
            }
        }
    }
    else
    {
        foreach ($multiArray as $multiArrayKey => $childArray)
        {
            if (array_key_exists($keyName, $childArray) &&
                $childArray[$keyName] === $value)
            {
                return true;
            }
        }
    }

    return false;
}

It seems in_array is limited. Hopefully this function might help. OR, I could be way off base. If I am, excuse the post.

nedjo’s picture

Assigned: Unassigned » nedjo
Status: Active » Fixed

I'd put a parenthesis in the wrong place in the previous commit, for issue http://drupal.org/node/141223. Should work now.

kgriffin’s picture

Yip. Warnings gone. Thanks. I wasn't completely off base, you just managed it differently...learning slowly but surely!

Anonymous’s picture

Status: Fixed » Closed (fixed)