Wedge

Public area => Bug reports => The Pub => Archived fixes => Topic started by: Adam Dresch on March 3rd, 2014, 05:30 PM

Title: Fatal error: Unsupported operand types (Load.php on line 1971)
Post by: Adam Dresch on March 3rd, 2014, 05:30 PM
Hello there!

Just testing our Wedge and on a fresh installation, I get:

Fatal error: Unsupported operand types in /home/theguard/public_html/wedge/gz/app/Load.php on line 1971

As can be seen here - http://theguardians.us/wedge/

Line 1971 is -

$language_directories += glob(LANGUAGES_DIR . '/*', GLOB_ONLYDIR);

Section of code being:

   // Default language directories to try.
   $language_directories = array(
      'root' => LANGUAGES_DIR,
   );
   $language_directories += glob(LANGUAGES_DIR . '/*', GLOB_ONLYDIR);
Title: Re: Fatal error: Unsupported operand types (Load.php on line 1971)
Post by: Nao on March 3rd, 2014, 06:25 PM
Hmm...
GLOB_ONLYDIR is available on PHP < 5, so it shouldn't be a problem.
I'm not sure why this would be happening. What's your server setup?
Title: Re: Fatal error: Unsupported operand types (Load.php on line 1971)
Post by: Adam Dresch on March 3rd, 2014, 06:33 PM
Hi Nao

I'm wondering if it's because I have Litespeed? would that affect it?

PHP Version 5.3.28
LiteSpeed V6.6
with XCache v3.1.0, Copyright (c) 2005-2013, by mOo
with the ionCube PHP Loader v4.4.1, Copyright (c) 2002-2013, by ionCube Ltd.
with XCache Cacher v3.1.0, Copyright (c) 2005-2013, by mOo
MySQL 5.5.36
Title: Re: Fatal error: Unsupported operand types (Load.php on line 1971)
Post by: Nao on March 3rd, 2014, 06:38 PM
Hmm, I don't think so... You're not the only one to use it. It doesn't seem like a bad system.
Title: Re: Fatal error: Unsupported operand types (Load.php on line 1971)
Post by: Adam Dresch on March 3rd, 2014, 06:39 PM
I tried turning off mod_security, but no change.
Can't think of what else is special about it, it's a standard VPS on OpenVZ, running Cpanel/WHM
Title: Re: Fatal error: Unsupported operand types (Load.php on line 1971)
Post by: Adam Dresch on March 3rd, 2014, 06:59 PM
Getting rid of litespeed fixed it hehe.
Title: Re: Fatal error: Unsupported operand types (Load.php on line 1971)
Post by: Nao on March 3rd, 2014, 07:09 PM
Oh my...
Still, that's no solution. Other people are using LiteSpeed, and I need to make sure that this line of code will be accepted, or rewrite it in an acceptable way. (Its only purpose is to add to an array a list of language sub-folders that should be searched for language items. There are approximately 8742 different ways of doing that, but this one was by far the shortest and coolest. I tend to commit my code only when it's short and cool enough. Cool because I'm vain, and short because it makes for more maintainable code if it's not too cryptic.)
Posted: March 3rd, 2014, 07:02 PM

Stupid me!! That's what happens when you're trying to work on several things at the same time.

I just realized that the error wasn't due to glob() (I focused too much on GLOB_ONLYDIR), but on the "+=" item.
Thing is, glob() MAY return false instead of an array, if an error occurred.
I don't know why your error wasn't logged, though...! Who cares that the operand is unsupported. What I want to know is why your code failed in the first place.

Can you re-enable LiteSpeed, and replace the line of code with this?

Code: [Select]
$language_directories += (array) glob(LANGUAGES_DIR . '/*', GLOB_ONLYDIR);

This will force typecasting the result to an array, and avoid this error. Then, maybe it'll finally record the error...
Title: Re: Fatal error: Unsupported operand types (Load.php on line 1971)
Post by: txcas on March 3rd, 2014, 08:31 PM
Quote from Adam Dresch on March 3rd, 2014, 06:59 PM
Getting rid of litespeed fixed it hehe.
Weird, my site is running on LiteSpeed.
Title: Re: Fatal error: Unsupported operand types (Load.php on line 1971)
Post by: Nao on March 3rd, 2014, 10:41 PM
It may not be related. I mean, the problem may lie in a folder problem within /languages. Waiting for feedback..!
Title: Re: Fatal error: Unsupported operand types (Load.php on line 1971)
Post by: CvH on March 27th, 2014, 04:59 PM
I got the same problem. Using git-3f1acd5e1a (27.03.14) - 1.st time install.
htdocs/gz/app/Load.php on line 2091

Ubuntu-Server 14.04
PHP Version 5.5.9, Server API FPM/FastCG
Apache/2.4.7

some ideas ?
Title: Re: Fatal error: Unsupported operand types (Load.php on line 1971)
Post by: Nao on March 27th, 2014, 05:12 PM
Well, my post above had a piece of code that you could use instead of that line... I specifically asked for feedback, but no one answered. This isn't going to get fixed by itself..!
Title: Re: Fatal error: Unsupported operand types (Load.php on line 1971)
Post by: Nao on March 27th, 2014, 05:15 PM
Also, from now on, I'll reserve my right to give free support to anyone who doesn't provide a link to their website (either the Wedge version, or a previous version not running Wedge.)

Just saying. I'm not getting paid here, and apart from the forum regulars, people come, ask for support, get it, and then rarely even bother to say thanks to anyone who helped...
Title: Re: Fatal error: Unsupported operand types (Load.php on line 1971)
Post by: CvH on March 27th, 2014, 05:34 PM
Code: [Select]
// $language_directories += glob(LANGUAGES_DIR . '/*', GLOB_ONLYDIR);
$language_directories += (array) glob(LANGUAGES_DIR . '/*', GLOB_ONLYDIR);

fixed it for me ! thanks for quick help

(it is a local test install of wedge, so no url or something because it only shows a blank white page ;) )
Title: Re: Fatal error: Unsupported operand types (Load.php on line 1971)
Post by: CvH on March 27th, 2014, 05:42 PM
After 2-3 clicks at the forum (looks like it should) i got the same error again (maybe a php cache problem ?) :hmm:
Title: Re: Fatal error: Unsupported operand types (Load.php on line 1971)
Post by: Nao on March 27th, 2014, 06:26 PM
Can you reproduce the error all the time..?

Try to purge the cache (main menu's admin tab).
Title: Re: Fatal error: Unsupported operand types (Load.php on line 1971)
Post by: CvH on March 27th, 2014, 09:26 PM
after changing this line, i press refresh at browser and the normal site appear, then i click to forum thread -> Load.php error, refresh or something won´t help, always htdocs/gz/app/Load.php on line 2091 (also incognito mode at browser)
i won´t get to the normal site again

but with git #0ad741a2a8 it seems to work (even with navigating through the site)

thanks for fix !