We have moved to Github. Please open tickets there.

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#3433 closed Defect (fixed)

elgg_count_comments() has incorrect use of plugin hook

Reported by: beck24 Owned by:
Priority: normal Milestone: Elgg 1.7.9
Component: Core Version: 1.7
Severity: minor Keywords: plugin hook
Cc: brett@… Difficulty: easy

Description

Using the plugin hook comments:count, but presumably all plugin hooks.

When the function called by a plugin hook returns a value of (int)0 or (string)'0', the value is discarded and the original value is used. There doesn't appear to be any way to return 0 as a legitimate value. I've gotten around it by returning "<span>0</span>" so that it renders correctly on the page, but that's not ideal as another hook may want to perform other mathematical functions with the value.

Change History (3)

comment:1 Changed 2 years ago by cash

  • Difficulty set to easy
  • Milestone changed from Needs Review to Elgg 1.7.9
  • Summary changed from plugin hook fails when 0 is returned to elgg_count_comments() has incorrect use of plugin hook

Thanks so much! We definitely appreciate it when people report these annoying little bugs.

It was some lazy code in elgg_count_comments() causing the problem. The fix will be included in Elgg 1.7.9

comment:2 Changed 2 years ago by cash

  • Resolution set to fixed
  • Status changed from new to closed

(In [svn:9062]) Fixes #3433 correctly checking return value of plugin hook in elgg_count_comments() now

comment:3 Changed 2 years ago by brettp

(In [svn:9139]) Refs #3510, #3433. Ported [svn:9062] to trunk. Fix for comment hook returning 0 comments.

Note: See TracTickets for help on using tickets.