Skip to:
Content

BuddyPress.org

#8821 closed defect (bug) (fixed)

Preventing ArgumentCountError when using sprintf/printf functions

Reported by: imath's profile imath Owned by: slaffik's profile slaFFik
Milestone: 11.1.0 Priority: normal
Severity: normal Version:
Component: I18N Keywords: dev-feedback has-patch
Cc:

Description

Some Polyglots locale team might not have updated their translated string or have used wrong placeholder causing fatals into the plugin:

See https://buddypress.org/support/topic/uncaught-argumentcounterror-bp-blogs-activity-php233/
See https://buddypress.org/support/topic/php-fatal-error-uncaught-valueerror/

I believe a function to check for these placeholders would be nice to have.

Change History (4)

This ticket was mentioned in Slack in #buddypress by imath. View the logs.


14 months ago

This ticket was mentioned in PR #66 on buddypress/buddypress by @imath.


14 months ago
#2

  • Keywords has-patch added

In 11.0 we have removed 1 placeholder to 2 strings used to display the activity action for published posts. Issues were raised about the fact some polyglots team did not update corresponding translations leaving the removed placeholder. As these two strings are used inside sprintf() function it resulted fatal errors for the corresponding locales. We hope improving the comment will avoid such mistakes. It is a temporary fix, the right one would be to create a sanitization function wrapping sprintf() to make sure expected placeholders are found into the translated string. Although this kind of function should be made available by WordPress imho, a quick check into some tickets reported upstream made us realize this would not happen. We will handle it for our usage.

Trac ticket: https://buddypress.trac.wordpress.org/ticket/8821

#3 @imath
14 months ago

In 13419:

Edit translator comments of problematic strings

In 11.0 we have removed 1 placeholder to 2 strings used to display the
activity action for published posts. Issues were raised about the fact
some polyglots teams did not update corresponding translations leaving the
removed placeholder in their translated strings. As these two strings are
used inside sprintf() function it resulted in fatal errors for the
corresponding locales.

We hope simply improving the comment will avoid such mistakes raising
translators attention. The result of this commit should avoid the string
to be translated as long as the polyglots team haven't updated their
translations.

It is a temporary fix, the right one should be to create a "sanitization"
function wrapping sprintf() to make sure expected placeholders are found
into the translated strings.

Although we think this kind of function should be made available by
WordPress, in [https://core.trac.wordpress.org/ticket/55776#comment:3 this
ticket] the issue was diagnosed as invalid. It's probably ok when you have
a lot of polyglots contributors like WordPress has, it's a different
situation for plugins
: we will work on preventing these potential fatals
in the next major release (12.0).

Props 1benk1, webmasterfreya

See #8821 (trunk)
Closes https://github.com/buddypress/buddypress/pull/66

#4 @imath
14 months ago

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

In 13420:

Edit translator comments of problematic strings

In 11.0 we have removed 1 placeholder to 2 strings used to display the
activity action for published posts. Issues were raised about the fact
some polyglots teams did not update corresponding translations leaving the
removed placeholder in their translated strings. As these two strings are
used inside sprintf() function it resulted in fatal errors for the
corresponding locales.

We hope simply improving the comment will avoid such mistakes raising
translators attention. The result of this commit should avoid the string
to be translated as long as the polyglots team haven't updated their
translations.

It is a temporary fix, the right one should be to create a "sanitization"
function wrapping sprintf() to make sure expected placeholders are found
into the translated strings.

Although we think this kind of function should be made available by
WordPress, in [https://core.trac.wordpress.org/ticket/55776#comment:3 this
ticket] the issue was diagnosed as invalid. It's probably ok when you have
a lot of polyglots contributors like WordPress has, it's a different
situation for plugins
: we will work on preventing these potential fatals
in the next major release (12.0).

Props 1benk1, webmasterfreya

Fixes #8821 (branch 11.0)

Note: See TracTickets for help on using tickets.