Problems with mymood plugin

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
DarKRaveR
Regular
Posts: 20
Joined: Wed Mar 29, 2006 7:35 am
Location: FFM, Germany

Problems with mymood plugin

Post by DarKRaveR »

Hi all,

I installed the mymood plugin - so far so good. When I try to write a new blog entry, I am getting an Error Message:
Warning: pg_query(): Query failed: ERROR: invalid input syntax for integer: "" in .../serendipity/include/db/postgres.inc.php on line 207
Error in SELECT value FROM serendipity_entryproperties WHERE entryid = '' AND property = 'mymood'
ERROR: invalid input syntax for integer: ""
The first obvious thing is: entryid is empty, defined as integer and unfortunately the value is enclosed in quotes, which postgres will not accept on numeric values (well at least integer) ...

When I checked the 'traceback', the following thing came to my attention:

Code: Select all

 array (
    'file' => '/var/www/vhosts/block.verfeiert.org/serendipity/include/admin/entries.inc.php',
    'line' => 476,
    'function' => 'serendipity_printentryform',
    'args' => 
    array (
      0 => '?',
      1 => 
      array (
        'serendipity[action]' => 'admin',
        'serendipity[adminModule]' => 'entries',
        'serendipity[adminAction]' => 'save',
      ),
      2 => 
      array (
      ),
    ),
  ),
It seems the third parameter passed to 'serendipity_printentryform' is an empty array. I am wondering what the third parameter is used for and if it should really be an empty array ...

Update:

I added two checks if an entry id is passed to the backend_display hook. I wonder though, why backend_display is executed when I want to write a new entry? shouldn't there be different hooks for editing an existing entry and creating a new one?

when does backend_entryform get called exactly? whenever the form for entering title, text is displayed ?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Problems with mymood plugin

Post by garvinhicking »

Hi!

I patched the mymood plugin to check if the eventdata is set. You are right that this is not set, when an entry is created. Plugins need to check on this.

Backend_display is used always on the display of an entryform, no matter if you create or edit an entry. Checkin on $eventData will make the plugin emit specific things. Usually a plugin emits the same output on this hook, only with some values assigned if $eventData is set, so this makes sense to not use/create a second hook.

Best 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/
DarKRaveR
Regular
Posts: 20
Joined: Wed Mar 29, 2006 7:35 am
Location: FFM, Germany

Post by DarKRaveR »

Okay, thnx fpr the info, I patched the mymood version I had installed anyway ....

I'm slowly getting a better understanding and overview of the whole system :wink: .
DarKRaveR
Regular
Posts: 20
Joined: Wed Mar 29, 2006 7:35 am
Location: FFM, Germany

Additional Error:

Post by DarKRaveR »

Hi Garvin:

in the event_hook switch statement is another bug:

Code: Select all

                case 'entry_display':
                    $elements = count($eventData);
                    for ($i = 0; $i < $elements; $i++) {

                            $location = ($this->get_config('location', 'body'));

                            switch ($location) {
                                case 'body':
                                case 'title':
                                case 'author':
                                    $location = $location;
                                    break;

                                case 'footer':
                                    $location = 'add_footer';
                                    $delim = '|';
                                    break;
                            }

                            # do nothing if we don't have any moods
                            $moods = $this->f_display_moods($eventData[$i]['id']);
                            if (!empty($moods)) {
                                if ($this->get_config('place_before')==false) {
                                    $eventData[$i][$location] .= $delim . $moods;
                                } else {
                                    $eventData[$i][$location] = $delim . $moods . $eventData[$i][$location];
                                }
                            }
                        }
                    break;

The for loop gets executed, even if no eventdata is passed (well if the count is zero) so, what happens is, that if you open an empty category it emits an SQL error, due to the empty id) when the actuall mood is checked for ...

Changed the following line as a fast hack:

Code: Select all

$moods = $this->f_display_moods($eventData[$i]['id']);
into

Code: Select all

if (isset($eventData[$i]['id'])) $moods = $this->f_display_moods($eventData[$i]['id']);
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Additional Error:

Post by garvinhicking »

Thanks a lot! I patched that as well.

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/
Post Reply