TGMPA / TGM-Plugin-Activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins). It allows your users to install, update and even automatically activate plugins in singular or bulk fashion using native WordPress classes, functions and interfaces. You can reference bundled plugins, plugins from the WordPress Plugin Repository or even plugins hosted elsewhere on the internet.
http://tgmpluginactivation.com/
GNU General Public License v2.0
1.75k stars 431 forks source link

sprint #766

Closed simongcc closed 5 years ago

simongcc commented 5 years ago

The following error then occur during installation of some plugins in a theme:

Warning: sprintf(): Too few arguments in ......../wp-admin/includes/class-bulk-upgrader-ski

The plugin is then installed but not sure if anything is being interrupted due to the warning. I found that the warning appear due to the following suspected bug found:

$this->upgrader->strings['skin_update_successful'] = esc_html__( '%1$s installed successfully.', 'theme-name' ) . ' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>' . esc_html__( 'Show Details', 'theme-name' ) . '</span><span class="hidden">' . esc_html__( 'Hide Details', 'theme-name' ) . '</span>.</a>';

In the original code of TGM-Plugin-Activation class-tgm-plugin-activation.php on line 3674

$this->upgrader->strings['skin_update_successful'] .= ' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>' . esc_html__( 'Show Details', 'tgmpa' ) . '</span><span class="hidden">' . esc_html__( 'Hide Details', 'tgmpa' ) . '</span>.</a>';

There are 2 defined variable placeholder for being substituted and expected 2 arguments from them %1$s %2$s

However,

// in WP 4.9.8 class-bulk-upgrader-skin.php on line 150
... sprintf( $this->upgrader->strings['skin_update_successful'], $title ) ...
// Only $title is being put into it

In PHP 5.6.3 tested, this error does not appear, maybe surpassed or ignored. In PHP 7.19 tested, the error come out, maybe it test strictly.

Because I found in the theme, I have also reported to the theme author. The above findings is for your reference.

Thanks a lot for providing such a convenient tools.

jrfnl commented 5 years ago

Closing as duplicate of #669 which was fixed by PR #670. The fix will be in the next release of TGMPA.