After migrating a site to a server with php 5.3, I'm getting the following warning:

Notice: Trying to get property of non-object in filefield_field_sanitize() (line 294 of /var/aegir/platforms/live/systemseed-6.x-1.20.3/profiles/systemseed/modules/contrib/filefield/filefield_field.inc).

CommentFileSizeAuthor
#3 1164892-filefield-sanitize.patch585 bytesmrfelton
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mrfelton’s picture

Should probably also note that this is with pressflow.

mrfelton’s picture

This seems to be a conflict with the Realname module. Disabling that module resolves the issue. Looking at backtrace shows that realname's implementation of content_profile_load_profile() cals

content_format($field_name, $content);

.

This looks like a valid way to call content_format() whose signature looks like so:

content_format($field, $item, $formatter_name = 'default', $node = NULL)

So, content_format then calls filefield_file_sanitze with a NULL node object (the following is from content_format):

    if (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE) {
      // Single value formatter.

      // hook_field('sanitize') expects an array of items, so we build one.
      $items = array($item);
      $function = $field['module'] .'_field';
      if (function_exists($function)) {
        $function('sanitize', $node, $field, $items, FALSE, FALSE);
      }

      $element['#item'] = $items[0];
    }

$node is null because it wan't passed to content_format(). Should filefield_field_sanitize() be able to deal with a NULL node object, since content_format may pass one to it? Or, is content_format at fault here?

mrfelton’s picture

Status: Active » Needs review
FileSize
585 bytes

Here is a patch that gets rid of the warning by first checking if the node object is valid before trying to use it to set the nid property. I don't know if this would have any side effects, but it seems to be working for me.

pydubreucq’s picture

Hi,
I had this error too after migrate to Pressflow and this patch works for me ;)
Bye

mikeytown2’s picture

Status: Needs review » Reviewed & tested by the community

patch #3 works for me as well.

quicksketch’s picture

Title: PHP 5.3 warning Trying to get property of non-object in filefield_field_sanitize() line 294 of filefield_field.inc » Trying to get property of non-object in filefield_field_sanitize() line 294 of filefield_field.inc
Priority: Normal » Minor
Status: Reviewed & tested by the community » Fixed

Thanks guys. Although it accommodating for other naughty modules it works for me.

Status: Fixed » Closed (fixed)

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