Hi.

I've been getting mysql_real_escape_string() expects parameter 1 to be string, array given in `includes/database.mysql.inc':321 in my logs when anonymous users visit http://crca.org.au/recent

I'm running Drupal 6.14 with Boost 6.x-1.17 under Nginx. Php version is 5.2.10-1ubuntu1~fpm~jaunty~ppa6.1 with Suhosin Patch 0.9.7.

I installed the trace module, which gave me the following backtrace:

Dec 5 03:16:13 crca drupal: #0675eb7f T+22.213265 [WARNING] E_WARNING: mysql_real_escape_string() expects parameter 1 to be string, array given in `includes/database.mysql.inc':321
Dec 5 03:16:13 crca drupal: return mysql_real_escape_string($text, $active_db);
Dec 5 03:16:13 crca drupal: mysql_real_escape_string(array('page_1', 'page_1'), resource(mysql link)) in `includes/database.mysql.inc':321
Dec 5 03:16:13 crca drupal: db_escape_string(array('page_1', 'page_1')) in `includes/database.inc':225
Dec 5 03:16:13 crca drupal: _db_query_callback(array('%s', '%s'))
Dec 5 03:16:13 crca drupal: preg_replace_callback('/(%d|%s|%%|%f|%b|%n)/', '_db_query_callback', 'SELECT * FROM boost_cache_settings WHERE page_callback = \'%s\' AND page_type = \'%s\' AND base_dir = \'%s\' AND page_id = \'%s\'') in `includes/database.mysql.inc':240
Dec 5 03:16:13 crca drupal: db_query_range('SELECT * FROM {boost_cache_settings} WHERE page_callback = \'%s\' AND page_type = \'%s\' AND base_dir = \'%s\' AND page_id = \'%s\'', 'view', 'RecentPastoralNotesAndBlogs', 'cache/normal/www.crca.org.au', array('page_1', 'page_1'), 0, 1) in `sites/all/modules/boost/boost.module':2579
Dec 5 03:16:13 crca drupal: boost_get_settings_db(array('path' => 'recent', 'load_functions' => '', 'to_arg_functions' => '', 'access_callback' => 'views_access', 'access_arguments' => 'a:2:{i:0;b:1;i:1;b:1;}', 'page_callback' => 'view', 'page_arguments' => array(), 'fit' => '1', 'number_parts' => '1', 'tab_parent' => '', 'tab_root' => 'recent', 'title' => '', 'title_callback' => 't', 'title_arguments' => '', 'type' => '4', 'block_callback' => '', 'description' => '', 'position' => '', 'weight' => '0', 'file' => '', 'href' => 'recent', 'options' => array(), 'access' => TRUE, 'localized_options' => array(), 'map' => array('recent'), 'page_type' => 'RecentPastoralNotesAndBlogs', 'page_id' => array('page_1', 'page_1'))) in `sites/all/modules/boost/boost.module':2149
Dec 5 03:16:13 crca drupal: boost_cache_set('recent', '\n\n

\n\n\n Recent Pastoral Notes/Blog Items | Christian Reformed Churches of Australia\n \n
\n\n
\n
\n

array('page_1', 'page_1') on that second last line. I'd happily trace the cause back further, but am not a PHP expert at all. I expect you're going to say this isn't a bug in Boost. If that's the case, can you give me a clue as to tools I could use to simplify the task of further tracing of the cause? Custom paging modules are installed but disabled. Thanks, Nigel
CommentFileSizeAuthor
#5 boost-651798.patch825 bytesmikeytown2

Comments

mikeytown2’s picture

Nice find with the trace module, I'll remember to use that next time I have an ugly error.

The recent page on your site, it's a view correct? page_id is set inside _boost_get_menu_router(), via this

  // Handle views
  if ($router_item['page_callback'] == 'views_page') {
    $router_item['page_callback'] = 'view';
    $router_item['page_type'] = array_shift($router_item['page_arguments']);
    $router_item['page_id'] = array_shift($router_item['page_arguments']);
    return $router_item;
  }

if $router_item['page_arguments'] contains an array in an array then this would cause the error your seeing. Whats special about this view that makes it different from most others? Set the verbose setting to 7 and let me know the output of 'Debug: _boost_ob_handler()' when you hit this page.

nigelcunningham’s picture

Yes, it is a view.

It' set up with unformatted style, node row style, no pager. I can provide screenshots of the config if that will help. Views version is 6.x-2.8.

I get:

Dec 5 05:14:47 crca drupal: http://www.crca.org.au|1259990087|boost|118.209.94.40|http://www.crca.org.au/|http://www.crca.org.au/admin/settings/performance/boost|0||Debug: _boost_ob_handler() HTTP Info: 200 - text/html Path: cache/normal/www.crca.org.au/_.html Content Container: page_manager_page_execute Content Type: front_v2 ID: 4 Cache This: TRUE.

Regards,

Nigel

mikeytown2’s picture

ID is 4; it should say something like page_1. The output you gave me is for your front page Path: cache/normal/www.crca.org.au/_.html; appears to be a panel. Can I get the view? I'm fairly certain the error is in _boost_get_menu_router().

nigelcunningham’s picture

Oh, sorry. Here's the right one:

Dec 5 05:49:14 crca drupal: http://www.crca.org.au|1259992154|boost|118.209.94.40|http://www.crca.org.au/recent||0||Debug: _boost_ob_handler() HTTP Info: 200 - text/html Path: cache/normal/www.crca.org.au/recent_.html Content Container: view Content Type: RecentPastoralNotesAndBlogs ID: Array Cache This: TRUE.

mikeytown2’s picture

Status: Active » Needs review
StatusFileSize
new825 bytes

Why it would be having this error doesn't make any sense though... this is the function that renders the view

/**
 * Page callback entry point; requires a view and a display id, then
 * passes control to the display handler.
 */
function views_page() {
  $args = func_get_args();
  $name = array_shift($args);
  $display_id = array_shift($args);

  // Load the view
  if ($view = views_get_view($name)) {
    return $view->execute_display($display_id, $args);
  }

  // Fallback; if we get here no view was found or handler was not valid.
  return drupal_not_found();
}

Heres the code in Boost for grabbing this; so 'page_id' is the same as $display_id

  // Handle views
  if ($router_item['page_callback'] == 'views_page') {
    $router_item['page_callback'] = 'view';
    $router_item['page_type'] = array_shift($router_item['page_arguments']);
    $router_item['page_id'] = array_shift($router_item['page_arguments']);

In short, $router_item = menu_get_item(); is returning that in an array for no good reason. I think this issue is related #647946: mysqli_real_escape_string() expects parameter 2 to be string, array given in /database.mysqli.inc on line 323. I need to handle this even though it should "never happen".

Try this patch

nigelcunningham’s picture

Status: Needs review » Reviewed & tested by the community

Works for me; thanks for such a quick response!

mikeytown2’s picture

Status: Reviewed & tested by the community » Fixed

committed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.