• Resolved JackSim

    (@jacksim)


    The French translation contains an unescaped % character in a string that causes a Fatal error (at least with PHP 8.2) on the Images configuration page.

    Steps to reproduce

    Install and activate WP-Optimize on a vanilla site with the Site Language set to French.
    Browse to WP-Optimize > Images
    A Fatal error will be thrown:

    [12-Jul-2023 12:28:43 UTC] PHP Fatal error:  Uncaught ArgumentCountError: 5 arguments are required, 4 given in /path/wp-content/plugins/wp-optimize/includes/class-updraft-smush-manager-commands.php:175
    Stack trace:
    #0 /path/wp-content/plugins/wp-optimize/includes/class-updraft-smush-manager-commands.php(175): sprintf('Depuis la derni...', '6', '0 bytes', '0.00%')
    #1 /path/wp-content/plugins/wp-optimize/includes/class-updraft-smush-manager.php(190): Updraft_Smush_Manager_Commands->get_ui_update(Array)
    #2 /path/wp-includes/class-wp-hook.php(308): Updraft_Smush_Manager->updraft_smush_ajax('')
    #3 /path/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array)
    #4 /path/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
    #5 /path/wp-admin/admin-ajax.php(188): do_action('wp_ajax_updraft...')
    #6 {main}
      thrown in /path/wp-content/plugins/wp-optimize/includes/class-updraft-smush-manager-commands.php on line 175

    Expected behaviour: a list of Uncompressed images.

    Actual behaviour: a fatal error (not visible in the admin page), and no images in the list.

    Cause and fix

    A string in the French translation contains an unescaped % character. As in the other languages, it should be replaced with the word for “percent”, “pourcent”. I suggested the change on the aforementioned link.

    The extra, unescaped % character makes the sprintf() function throw an error because it is expecting one more argument.

    • This topic was modified 1 year, 8 months ago by JackSim.

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator Yui

    (@fierevere)

    永子

    pinging #fr_FR translation editors

    Fixed, thanks for letting us know

    Plugin Support vupdraft

    (@vupdraft)

    @jacksim – is this fixed for you now?

    Thread Starter JackSim

    (@jacksim)

    Nope. I updated the translation, but I still have the same error:

    [12-Jul-2023 14:02:11 UTC] PHP Fatal error:  Uncaught ArgumentCountError: 5 arguments are required, 4 given in /path/wp-content/plugins/wp-optimize/includes/class-updraft-smush-manager-commands.php:175

    I noticed that the change in the translation wasn’t enough to fix the error: a space was removed from the string, but the % character is still not escaped correctly with a double %%.

    The unsufficient change: https://www.dropbox.com/s/lmlo2634jfk5j9c/wpo-fr-bug.png?dl=0

    The best approach would be the one I suggested: do like all of the other translators did (and the original English version does), use the word for “percent”, “pour cent” in French, instead of the problematic % character. Then the problem will be solved.

    Thread Starter JackSim

    (@jacksim)

    By the way, the same bug is present in another string:

    #: includes/class-updraft-smush-task.php:293
    msgid "The file was compressed from %s to %s saving %s percent using WP-Optimize"
    msgstr "Le fichier a été compressé de %s à %s en réduisant de %s?% avec WP-Optimize"

    The last % should be escaped with a double %%, or replaced with the words “pour cent” like in English.

    In this one tough, it is done properly:

    #: includes/class-updraft-smush-manager.php:157
    msgid "The file was compressed from %s to %s, saving %s percent, using WP-Optimize"
    msgstr "Le fichier a été compressé de %s à %s, en économisant %s?%% à l’aide de WP-Optimize"
    Plugin Support vupdraft

    (@vupdraft)

    Hi,

    Apologies, can you take me through step by step how to recreate your issue.

    I have a site with the Language set to French and I have installed the WPO plugin

    When I navigate to the uncompressed images tab, I get this:

    https://snipboard.io/PLzVSd.jpg

    When I compress an image I do not get any errors:

    https://snipboard.io/4i7GJO.jpg

    Thread Starter JackSim

    (@jacksim)

    Then my problem may be specific to my testing environment (PHP 8.2.4 on MAMP PRO 6.8.1 on macOS 12.6.7). But I doubt it since I saw the same behaviour on my live environment (shared hosting on PHP 8.2.x).

    I simply took a new WP installation in French without anything else, installed and enabled WP-Optimize and saw the fatal error on the Images configuration page.

    To be honest I gave up on WP-Optimize because it was causing too much trouble for me. In addition to the fatal error, the cache preloading wasn’t preloading anything except for the sitemaps. I even experienced a 500 error on my live server while preloading (in addition to a JS error message).

    • This reply was modified 1 year, 8 months ago by JackSim.
    Plugin Support Kowsar Hossain

    (@kowsar89)

    @jacksim This issue should be resolved by updating WP-Optimize to the latest version (v3.2.17). If the Fatal error continues to persist, please let us know. Thank you.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘French translation mistake causes Fatal error’ is closed to new replies.