array_unique returns NULL

I am dealing with legacy code written by another team and someone asked me why his images were not showing up...

Took me an hour to dig that one out.

Simply because the optional second parameter to array_unique() was only added in php 5.2.9 and we were using 5.2.4 ... Therefore it was generating an error that was hidden (because of error_reporting) and returning null.

I removed the second parameter and VOILA!

Too bad the sysadmin does not allow us to upgrade PHP. :)

Thanks for the post! I had

Thanks for the post! I had the same problem with one of the wordpress plugins. your post helped me to pinpoint the error using google! :)

Well... it is :) sort of

@Anonymous: It is not a question of consideration (I would if I could). The current systen is under FreeBSD and we are going to Ubuntu (OS and version is imposed by the Sysadmin group) so the dev server is currently on php 5.2.4 which will be what the new production server will be once we migrate the application on Ubuntu. At that point (soon) the dev will be exacly the same. Until that time, it will not be the same. In fact, it is good that the dev that we have now is how the new production will be. It allowed us to see this problem before we actually migrated the code :)

So one could say that we have the same environment after all since the new prod will be like our (new) dev. :)

--
Christian Roy

Maybe you should concider

Maybe you should concider using the same environement for development then the one you have in production.

It helps prevent these errors.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • You may post PHP code. You should include <?php ?> tags.
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options