[buddypress-trac] [BuddyPress Trac] #9221: [BP Legacy Template pack] A printf function is written incorrectly related to "mentions" count in src/bp-templates/bp-legacy/buddypress/activity/index.php

buddypress-trac noreply at wordpress.org
Tue Jul 30 01:05:16 UTC 2024


#9221: [BP Legacy Template pack] A printf function is written incorrectly related
to "mentions" count in src/bp-templates/bp-
legacy/buddypress/activity/index.php
-------------------------+-------------------------------------------------
 Reporter:  emaralive    |      Owner:  (none)
     Type:  defect       |     Status:  new
  (bug)                  |
 Priority:  normal       |  Milestone:  14.1.0
Component:  Templates    |    Version:  14.0.0
 Severity:  normal       |   Keywords:  has-screenshots needs-patch dev-
                         |  feedback
-------------------------+-------------------------------------------------
 This bug was flagged on Slack by @venutius (see
 [https://wordpress.slack.com/archives/C02RQBYUG/p1722207561829889
 conversation]) which was originally reported by @mike80222 as a Support
 forum post (see [https://buddypress.org/support/topic/bp-templates-bp-
 legacy-buddypress-activity-index-php-line-164/ topic]).

 Although the offending **{{{printf()}}}** function is contained within a
 template file for the !BuddyPress Legacy Template, the reported bug can be
 duplicated by other methods.

 The aforementioned function is located on line 164 of
 [https://github.com/buddypress/buddypress/blob/master/src/bp-templates/bp-
 legacy/buddypress/activity/index.php#L164 src/bp-templates/bp-
 legacy/buddypress/activity/index.php] (master branch) which is represented
 by the following code snippet

 {{{#!php
 <?php
 printf( esc_html( _nx( '%s new', '%s new',
 bp_get_total_mention_count_for_user( bp_loggedin_user_id() ), 'Number of
 new activity mentions', 'buddypress' ), esc_html(
 bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) ) );

 }}}
 PHP 7.4.33 casts the following error:
 {{{
 Warning: printf(): Too few arguments in...
 }}}
 PHP 8.0.30 casts the following error:
 {{{
 Fatal error: Uncaught ArgumentCountError: 2 arguments are required, 1
 given in...
 }}}

 Tracing things back, it looks like the **{{{esc_html()}}}** function was
 initially introduced in 12.0.0-beta1 and is a quandary as to why this
 wasn't caught from a syntactical standpoint. Perhaps the question is: How
 would one detect such an error? I ask because when utilizing a site with:

 WP: 6.6.1
 BP: 14.0.0
 Theme: Twentyeleven
 Template pack: Legacy
 PHP: 7.4.33 & 8.0.30

 I'm not picking up any error log entries, things appear to be normal
 (well, as normal can be) and I get an actual "**mentions**" count. The
 attached screenshot is indicative of such, i.e., "**mentions**" count.

 Neither here nor there, I'm not sure why the **{{{_nx()}}}** is needed,
 the word "**new**"" is both singular and plural because "**news**", if it
 were used, would be a synonym for "**information**" and not the plural for
 "**new**". And, in reality, there is nothing really to contextualize since
 there should only be a count (numeric indicator) without the word
 "**new**".

 @espellcaste I stated what I stated, so, here is the ticket, so that you
 can/may perform your magic.

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/9221>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list