Get a warning when using Multisite

14 views
Skip to first unread message

Florian Fiegel

unread,
Nov 28, 2008, 12:36:06 PM11/28/08
to habari-users
Hi out there,

I am not sure if it is a bug, but when using Multisite I get this
warning every time:

Warning: array_map() [function.array-map]: Argument #2 should be an
array in /var/www/.../index.php on line 91

I actually use 0.6-alpha. If there is a need to more specs, just tell
me.

It is caused by anything I did? Or is it really a bug?
Couldn't find anything in the wiki or on Trac, so I am unsure.

Regards
Florian

Colin

unread,
Nov 30, 2008, 3:45:11 AM11/30/08
to habari...@googlegroups.com
Hi there

Sounds like you may not have sufficient access permissions on your /path/to/habari/user/sites directory or it's sub-directories.

Ensure this directory is accessible by your web server user.

HTH
Colin
--
Colin Seymour
Blog: http://www.colinseymour.co.uk
Tech Stuff: http://www.lildude.co.uk

Florian Fiegel

unread,
Nov 30, 2008, 5:05:05 AM11/30/08
to habari-users
Hi,

so, I now set 777 to the folders and the warning resides on the top of
the page.

The site is displayed and works, so there is no bigger problem. Just
this annoying warning on every page.

If you want to check out: http://blog.florian-fiegel.net

regards
Florian

Colin

unread,
Nov 30, 2008, 5:25:12 AM11/30/08
to habari...@googlegroups.com
Hmmm, so that's not it (best put those permissions back).

What version of Habari are you using?

Fiegel Florian

unread,
Nov 30, 2008, 6:09:03 AM11/30/08
to habari...@googlegroups.com
Actually i'm using the last 0.6-alpha (head), updated before asking here. I thougt it maybe was a bug and already fixed.

--~--~---------~--~----~------------~-------~--~----~
 This message is part of the topic "Get a warning when using Multisite"
in the Google Group "habari-users" for which you requested email updates.
To stop receiving email updates for this topic, please visit the topic
at http://groups.google.com/group/habari-users/t/514c398985964c07
-~----------~----~----~----~------~----~------~--~---


Colin

unread,
Nov 30, 2008, 6:36:35 AM11/30/08
to habari...@googlegroups.com
Thanks.

It sounds like your system may be having problems with glob() not returning an array, even an empty one.

I suspect the line number in the error may be slightly wrong as line 91 is a comment.  There are two array_map function calls in index.php and I suspect you're tripping up on the 2nd.

Add "Utils::debug($glob);" just above the $fnames line so the if() clause looks like this:

---
                // Verify if this Habari instance is a multisite.
                if ( ($site_user_dir = Site::get_dir('user')) != HABARI_PATH . '/user' ) {
                        // We are dealing with a site defined in /user/sites/x.y.z
                        // Add the available files in that directory in the $files array.
                        $glob = glob( $site_user_dir . '/classes/*.php' );
                        Utils::debug($glob);     //    <<<<<------------------- HERE
                        $fnames = array_map(create_function('$a', 'return strtolower(basename($a));'), $glob);
                        if ( $glob !== false && ! empty( $glob ) && ! empty( $fnames ) ) {
                                $files = array_merge($files, array_combine($fnames, $glob));
                        }
                }
---

... and refresh your page.  What is displayed now?

It's also worth checking your error logs. Is anything else printed in them around this warning?

 

Fiegel Florian

unread,
Nov 30, 2008, 6:53:54 AM11/30/08
to habari...@googlegroups.com
When I add the Utils I get:

Call Stack
>
index.php (113): spl_autoload_call(stringError);
[Internal PHP] (): __autoload(stringError);
index.php (91): Utils::debug(boolean);

boolean

The logs are clean, even with the optional error backtrace logging enabled.


Colin

unread,
Nov 30, 2008, 7:18:40 AM11/30/08
to habari...@googlegroups.com
Looks like your system has either had a problem with the glob() hence it returning FALSE, or it's one of the few systems that fall into this comment that appears on the php.net/glob page:

Note: On some systems it is impossible to distinguish between empty match and an error.

Change your Util::debug() line to read: Utils::debug( $site_user_dir); and refresh.  This is likely to return something like:

/var/www/web234/html/florianfiegel/home/user/sites/blog.florian-fiegel.net/

Check all the directories in the path returned from /home onward and ensure your webserver user has access to each directory in the path. 

It is does, then I think your system may be one of those that returns FALSE instead of an empty array.

You may find changing the $fnames line to read (add the "(array)" part before $glob):

         $fnames = array_map(create_function('$a', 'return strtolower(basename($a));'), (array)$glob);

... will stop the errors and allow things to work correctly.

If so, let me know and I'll log a bug for this behaviour.

Colin

unread,
Nov 30, 2008, 7:28:45 AM11/30/08
to habari...@googlegroups.com
I've looked into this and I see where the problem is. This is definitely going to be a bug and it's going to be due to your system returning FALSE instead of an empty array.

Further up on the file where the first array_map() takes place, we can see this behaviour is accounted for:

---
                // For each directory, save the available files in the $files array.
                foreach ($dirs as $dir) {
                        $glob = glob( $dir . '/classes/*.php' );
                        if ( $glob === false || empty( $glob ) ) continue;    <<---- HERE

                        $fnames = array_map(create_function('$a', 'return strtolower(basename($a));'), $glob);
                        $files = array_merge($files, array_combine($fnames, $glob));
                }
---

But the same check is not done further down at the next array_map().

I'll log a ticket and let you know the number.

Fiegel Florian

unread,
Nov 30, 2008, 7:31:10 AM11/30/08
to habari...@googlegroups.com
Did what you wrote and it works. Thx!

Fiegel Florian

unread,
Nov 30, 2008, 7:37:08 AM11/30/08
to habari...@googlegroups.com
ok, so it wasn't my mistake … just wondered about …


Colin

unread,
Nov 30, 2008, 7:41:15 AM11/30/08
to habari...@googlegroups.com
Nope, not your mistake.

I've logged ticket #781 - https://trac.habariproject.org/habari/ticket/781 - for the issue.

It's a trivial fix, so I don't think it'll be long before it's fixed.

Cheers,
Colin

Matthias Bauer

unread,
Nov 30, 2008, 10:56:15 AM11/30/08
to habari...@googlegroups.com
Fiegel Florian wrote:
> Actually i'm using the last 0.6-alpha (head), updated before asking
> here. I thougt it maybe was a bug and already fixed.

Replace the calls to glob() in site.php with calls to Utils::glob().
That should fix that.

-Matt

Matthias Bauer

unread,
Nov 30, 2008, 10:59:49 AM11/30/08
to habari...@googlegroups.com
Colin wrote:
> Nope, not your mistake.
>
> I've logged ticket #781 -
> https://trac.habariproject.org/habari/ticket/781 - for the issue.
>
> It's a trivial fix, so I don't think it'll be long before it's fixed.

Should be fixed in r2910, can you please test and confirm?

-Matt

Colin

unread,
Nov 30, 2008, 12:01:48 PM11/30/08
to habari...@googlegroups.com
Confirmed it resolves the issue in my testing env.

Thanks for the quick turnaround Matt.
Reply all
Reply to author
Forward
0 new messages