undefined index warnings

stella - June 3, 2009 - 18:09
Project:Activity
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

I'm getting two php warnings when I use this module:

# notice: Undefined index: operation in /Applications/MAMP/htdocs/drupal6/sites/all/modules/activity/activity.module on line 1433.
# notice: Undefined variable: info in /Applications/MAMP/htdocs/drupal6/sites/all/modules/activity/views-view-row-activity.tpl.php on line 12.

The attached patch fixes these.

Cheers,
Stella

AttachmentSize
activity_undefined_msg.patch1.38 KB

#1

stella - June 3, 2009 - 18:18
AttachmentSize
activity_undefined_msg.patch 2.63 KB

#2

sirkitree - June 3, 2009 - 18:42
Status:needs review» fixed

thank you, committed.

#3

System Message - June 17, 2009 - 18:50
Status:fixed» closed

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

#4

bangpound - August 26, 2009 - 20:56
Status:closed» active

This patch introduced a big problem. If there's no 'mark' then the activity message is never displayed.

  * Theme function for individual activity message.
  */
function theme_activity($message, $item) {
-  $output = $item['mark'] .'<span class="activity activity-module-'. $item['module'] .' activity-type-'. $item['type'] .' activity-operation-'. $item['operation'] .'">'. $message .'</span>';
+  $output = '';
+  if (isset($item['mark'])) {
+    $output = $item['mark'] .'<span class="activity activity-module-'. $item['module'] .' activity-type-'. $item['type'] .' activity-operation-'. $item['operation'] .'">'. $message .'</span>';
+  }
   $output .= '<span class="activity-links">';

   // If user has permission to create an activity comment then show link to add comment

See what I mean?

#5

drewish - September 4, 2009 - 00:51
Status:active» needs review

yeah i think that something like this would be better:

  $output = '';
  if (isset($item['mark'])) {
    $output .= $item['mark'];
  }
  $output .= '<span class="activity activity-module-'. $item['module'] .' activity-type-'. $item['type'] .' activity-operation-'. $item['operation'] .'">'. $message .'</span>';

or
  $item += array('mark' => '');
  $output = $output = $item['mark'] .'<span class="activity activity-module-'. $item['module'] .' activity-type-'. $item['type'] .' activity-operation-'. $item['operation'] .'">'. $message .'</span>';

#6

bangpound - September 5, 2009 - 14:35

It's a theme function, so I think the most "basic" syntax and expression is preferred so themers can comprehend the goings on without a headache. For me, that means the first option. I don't understand the second one myself.

I'm at Drupalcon now, but I can roll a patch in a few days if nobody else does.

 
 

Drupal is a registered trademark of Dries Buytaert.