Page 1 of 1

Problems with mymood plugin

Posted: Thu Mar 30, 2006 11:30 pm
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 ?

Re: Problems with mymood plugin

Posted: Fri Mar 31, 2006 12:12 pm
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

Posted: Fri Mar 31, 2006 4:40 pm
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: .

Additional Error:

Posted: Fri Mar 31, 2006 7:20 pm
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']);

Re: Additional Error:

Posted: Fri Mar 31, 2006 7:39 pm
by garvinhicking
Thanks a lot! I patched that as well.

Regards,
Garvin