Object of class stdClass could not be converted to string em /etc/drupal6/all/modules/drupal.org/nodewords/nodewords.module na linha 77.

This is caused by the following line on nodewords.module:

  $bool = (
    isset($form['type']) &&
    isset($form['type']['#value']) &&
    $form_id == $form['type']['#value'] . '_node_form' &&
    isset($form['#node']) &&
    variable_get('nodewords_edit_metatags_' . $form['type']['#value'], TRUE)
  );

The PHP warning is generated if you have any form in your installation which store something in a 'type' item's value that are not a scalar. E.g.:

    $form['type'] = array(
           '#value' => $my_object
   );

The attached patch fixes the error message by testing if the variable is scalar before concatenation.

CommentFileSizeAuthor
#1 nodewords-fix-warning.patch523 bytesflaviovs

Comments

flaviovs’s picture

StatusFileSize
new523 bytes

Oops... here goes the patch.

avpaderno’s picture

Hello flaviovs, and thanks for your report.

The fix for this issue is a little different, and involves just a re-ordering of the code. In fact, a similar check is done from Drupal core modules, but they don't check if the value is a scalar. They simple access $form['type']['#value'] once they verified $form['#node'] is defined; in that case, they are sure the form is the correct one.

function path_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
    // ...
  }
}

I am going to change that code.

avpaderno’s picture

Status: Active » Fixed

The code has been changed, and committed in CVS (#324602).

flaviovs’s picture

@kiamlaluno, thanks for pointing it out. In fact, I was not very confortable with that solution -- yes, some code reordering might well fix the problem, but I just wanted to keep the patch as simple as possible. Your solution is much more elegante.

Status: Fixed » Closed (fixed)

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