The PHP notice indicated on the Recent log messages whenever admin/content/file is accessed is as below,

Notice: Undefined property: stdClass::$total_count in file_entity_admin_files() (line 400 of /var/aegir/platforms/myplatform/sites/all/modules/contrib/file_entity/file_entity.admin.inc).

Releavant code snippet,

   $options[$file->fid] = array(
      'title' => array(
        'data' => array(
          '#type' => 'link',
          '#title' => $file->filename,
          '#href' => 'file/' . $file->fid,
        ),
      ),
      'type' => $file_type ? check_plain($file_type->label) : FILE_TYPE_NONE,
      'size' => format_size($file->filesize),
      'author' => theme('username', array('account' => $account)),
      'timestamp' => format_date($file->timestamp, 'short'),
      'usage' => format_plural((int) $result[$file->fid]->total_count, '1 place', '@count places'),
    );
[105] => stdClass Object
(
[fid] => 105
[uid] => 18
[total_count] => 1
)

[106] => stdClass Object
(
[fid] => 106
[uid] => 18
[total_count] => 1
)

[134] => stdClass Object
(
[fid] => 134
[uid] => 18
)

[135] => stdClass Object
(
[fid] => 135
[uid] => 18
)

total_count attribute in $result[$file->fid]->total_count is assumed to have set always but it is not the case. Adding an isset() check fixed the issue for me.

Comments

Sivaji created an issue. See original summary.

joseph.olstad’s picture

Please write a patch as follows:

add this line one line above $options.....blah

so:

$count_usage = isset($result[$file->fid]))? $result[$file->fid]->total_count : 0;
$options[......blah

Then replace this line:

      'usage' => format_plural((int) $result[$file->fid]->total_count, '1 place', '@count places'),

with this:

      'usage' => format_plural((int) $count_usage, '1 place', '@count places'),
joseph.olstad’s picture

Status: Active » Needs review

please write a patch as directed

lasseitorp’s picture

I believe it shoud be:

$count_usage = isset($result[$file->fid]->total_count) ? $result[$file->fid]->total_count : 0;

Otherwise it works like a charm!

KD

  • joseph.olstad authored 7be631c on 7.x-2.x
    Issue #2908522 by joseph.olstad: PHP notice in function...
joseph.olstad’s picture

Status: Needs review » Fixed

  • joseph.olstad authored 7be631c on 7.x-3.x
    Issue #2908522 by joseph.olstad: PHP notice in function...

Status: Fixed » Closed (fixed)

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