Image upload failed

Found a bug? Tell us!!
Post Reply
sammywg
Posts: 2
Joined: Sun Jun 03, 2012 3:43 pm

Image upload failed

Post by sammywg »

Hi there,

it's not the first entry in my blog I've wrote, but the first one after the last update to 1.7-alpha1. Runs on PHP 5.2.6. If I click to "Add media data" (or something like this, I use the german language version) the only result is this fatal error message:

Code: Select all

Fatal error: Uncaught exception 'ErrorException' with message 'Serendipity error: in_array(): Wrong datatype for second argument' in /home/www/servers/foo/pages/include/compat.inc.php:106 Stack trace: #0 [internal function]: errorToExceptionHandler('2', NULL) #1 /home/www/servers/foo/pages/plugins/serendipity_event_imageselectorplus/serendipity_event_imageselectorplus.php(293): in_array('backend_image_a...', Object(serendipity_property_bag), Array, NULL) #2 /home/www/servers/foo/pages/include/plugin_api.inc.php(1073): serendipity_event_imageselectorplus->event_hook('backend_image_a...', Array, NULL) #3 /home/www/servers/foo/pages/include/functions_smarty.inc.php(554): serendipity_plugin_api::hook_event(Array, Object(Smarty_Internal_Template)) #4 /home/www/servers/foo/pages/templates_c/terrafirma/40/e9/30/40e93062dcdae313196b39ed34e16a56aacc9bcc.file.media_upload.tpl.php(295): serendipity_smarty_hookPlugin(Object(S in /home/www/servers/foo/pages/include/compat.inc.php on line 106
Does exists a short fix for this problem? Looks as triggered by a template bug, but I'm not sure.

Thanks for help.

Sammy
blog.brockha.us
Regular
Posts: 695
Joined: Tue Jul 03, 2007 3:34 am
Location: Berlin, Germany
Contact:

Re: Image upload failed

Post by blog.brockha.us »

If this really is a template bug, there is no "short fix", as we don't know your template.

But it might help to put this line to your serendipity_config_local.inc.php:

$serendipity['production']=true;

This will let S9Y behave a little more nice on this types of problems. If your template worked before, the chances are high, that it will again with this small change. :)
- Grischa Brockhaus - http://blog.brockha.us
- Want to make me happy? http://wishes.brockha.us/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Image upload failed

Post by Timbalu »

These exception messages look quite confusing, but they tell you exactly where to look for...
I think it recommends this line ~293

Code: Select all

echo '<option value="'. $cat['categoryid'] .'"'. (in_array($cat['categoryid'], $selected) ? ' selected="selected"' : '') .'>'. str_repeat('&nbsp;', $cat['depth']) . $cat['category_name'] .'</option>' . "\n";
in the additional_plugin serendipity_event_imageselectorplus.php.

I can't see where $selected, the second argument, is defined...
This could be $serendipity['GET']['category']; for example.
So adding a line before the foreach loop could look like

Code: Select all

$selected = $serendipity['GET']['category'] ? $serendipity['GET']['category'] : '';
Can you please try this?

I even think just doing a simple replace of the first with

Code: Select all

echo '<option value="'. $cat['categoryid'] .'"'. (($cat['categoryid'] == $serendipity['GET']['category']) ? ' selected="selected"' : '') .'>'. str_repeat('&nbsp;', $cat['depth']) . $cat['category_name'] .'</option>' . "\n";
would suffice best.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Image upload failed

Post by garvinhicking »

Hi!

Good catch; that var doesn't exist. I'm afraid there could be a lot of other places where in_array() does no explicit type check or variable existing check. Do you know if the smarty/error exception handler can be finetuned to simply ignore such notices? IMHO for an untyped scripting language like PHP, errors like these should never make the whole process choke...

(I updated the plugin to remove that check)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Image upload failed

Post by Timbalu »

Hi Garvin

Well, hmm, no, I assume. We can disable NOTICE exceptions at all, but...
Remember this is a more strict setting, as using an Alpha version, where production = false.
Which is good in my eyes!
IMHO NULL is an error not a notice, btw...

Why didn't you change imageselectorplus to?:

Code: Select all

'. (($cat['categoryid'] == $serendipity['GET']['category']) ? ' selected="selected"' : '') .'
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
sammywg
Posts: 2
Joined: Sun Jun 03, 2012 3:43 pm

Re: Image upload failed

Post by sammywg »

Sometimes it is not the best idea to use the newest code - on the other hand is it not that unknown to find strange bugs.

First, yes, it is a bug in the alpha release, a downgrade to the last stable version fixed the problem completely. So I think you know which sections are edited from stable to head and are probably also affected.

Second: thanks for help to Garvin :) (and Kris for his hands on the machine).

Garvin: If you need more specific details on the local installation, please ask Kris for a tarball.

Regards,
Sammy
Post Reply