Searching result in a call to watchdog that is longer than the 128 maximum characters.

I'm unsure how to fix this - either we shouldn't pass long-ish strings to watchdog() or watchdog should trim them before attempting an insert.

warning: pg_query() [function.pg-query]: Query failed: ERROR: value too long for type character varying(128) in /home/brenda/workspace/drupal/drupal6/includes/database.pgsql.inc on line 139.
user warning: ERROR: value too long for type character varying(128) query: INSERT INTO watchdog (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (1, 'search', '%keys (@type).', 'a:2:{s:5:"%keys";s:42:"this is a really really really long string";s:5:"@type";s:7:"Content";}', 5, 'results', 'http://gargi.wgtn.cat-it.co.nz/search/node/this%20is%20a%20really%20real...', 'http://dnc.gargi.wgtn.cat-it.co.nz/search/node/Real%20estate%20services%...', '192.168.2.42', 1247752598) in /home/brenda/workspace/drupal/drupal6/modules/dblog/dblog.module on line 144.

CommentFileSizeAuthor
#2 drupal-dblog-pgsql.patch448 bytesjamespharaoh

Comments

Shiny’s picture

The call is here:

<?php
function search_view($type = 'node') {
   .......
    $keys = search_get_keys();
    // Only perform search if there is non-whitespace search term:
    $results = '';
    if (trim($keys)) {
      // Log the search keys:
      watchdog('search', '%keys (@type).', array('%keys' => $keys, '@type' => module_invoke($type, 'search', 'name')), WATCHDOG_NOTICE, l(t('results'), 'search/'. $type .'/'. $keys));

      // Collect the search results:
      $results = search_data($keys, $type);

      if ($results) {
        $results = theme('box', t('Search results'), $results);
      }
      else {
        $results = theme('box', t('Your search yielded no results'), search_help('search#noresults', drupal_help_arg()));
      }
    }

  .....

  return drupal_get_form('search_form', NULL, empty($keys) ? '' : $keys, $type);
}
?>
jamespharaoh’s picture

StatusFileSize
new448 bytes

Yes, watchdog is trying to put too much data into the field. I would change this field to accept any size text but a simple solution is just to trim it as it goes in. The attached patch will do that.

dave reid’s picture

Status: Active » Closed (duplicate)