Download & Extend

warning: mysqli_real_escape_string() expects parameter 2 to be string, object given

Project:Advanced Help Injection and Export
Version:6.x-1.0-alpha5
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

When I enable both Help injection and Help injection help I get this on front page:
warning: mysqli_real_escape_string() expects parameter 2 to be string, object given in X:\home\www.example.com\www\includes\database.mysqli.inc on line 323
warning: mysqli_real_escape_string() expects parameter 2 to be string, object given in X:\home\www.example.com\www\includes\database.mysqli.inc on line 323

Comments

#1

I have the same error messages. They come from line 654 in the file helpinject.module in function helpinject_help_link:

<?php
if (isset($element['#type']) && !in_array($element['#type'], array('button', 'image_button', 'submit', 'markup', 'token', 'hidden', 'form', 'value', 'weight'))) {
?>

In my problem case $element is a string "node" and $form_id is the node object. In this case I would expect that isset($element['#type']) will return FALSE because $element is not an array and therefore the array key '#type' doesn't exist. I don't know why, but PHP returns TRUE for isset($element['#type']) instead (and "n" for $element['#type']) and so the IF condition is evaluated to TRUE and in the next line the function helpinject_get_from_key is called with the node object as parameter $form_id which leads to the error message later. It really seems to be an error in the isset function in PHP, I use PHP 5.1.6 under Red Hat Enterprise Linux 5.

To prevent these errors I added is_array($element) to the IF clause, the modified line 654 in the file helpinject.module is now:

<?php
if (is_array($element) && isset($element['#type']) && !in_array($element['#type'], array('button', 'image_button', 'submit', 'markup', 'token', 'hidden', 'form', 'value', 'weight'))) {
?>

I attach a patch file for fixing the error

#2

Nice analysis brahms. Is the patch still coming?

#3

Sorry Robert, here is the patch file.

AttachmentSize
helpinject-6.x-1.0-alpha5-458796-1.patch 824 bytes

#4

Status:active» fixed

Committed, thanks.

#5

Status:fixed» closed (fixed)

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