• When I run WP cli commands from command line I get:

    Warning: fread(): Length parameter must be greater than 0 in [REDACTED]/wp-content/plugins/dynamo/src/mo-reader.php on line 129

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Chouby

    (@chouby)

    Hello,

    Could you identify which translation file (.mo) is causing this error and share it?

    Thread Starter ehau

    (@ehau)

    Isn’t there easily a large amount of these mo-files?

    Any suggestions how to identify the problem. Maybe disable plug-ins one by one with wp cli? Or just check the logs?

    Plugin Author Chouby

    (@chouby)

    Yes, disabling the plugins one by one should help to identify it. It may come from the theme too.

    Thread Starter ehau

    (@ehau)

    Would it be possible to temporarily modify the code in /dynamo/src/mo-reader.php to output the name of the problematic file and perhaps some other debug info in the log warning?

    Would you have and example how this code could look like?

    • This reply was modified 2 years, 11 months ago by ehau.
    • This reply was modified 2 years, 11 months ago by ehau.
    Plugin Author Chouby

    (@chouby)

    Yes. That should be possible. However, the function where the error occurs doesn’t have access to the filename, so we must pass to it first.

    In src/mo.php at line 72, replace:
    if ( ! $reader->parse( $mem_handle ) ) {
    by
    if ( ! $reader->parse( $mem_handle, $filename ) ) {

    In src/mo-reader.php at line 42, replace:
    public function parse( $handle ) {
    by
    public function parse( $handle, $filename ) {

    In src/mo-reader.php just before the line 129, add:
    if ( $translations[ (int) $headers_idx ] <= 0 ) print_r( $filename );

    If print_r() doesn’t work, you may try with error_log().

    Plugin Author Chouby

    (@chouby)

    Hello @ehau

    Did you succeed to identify the translation file causing the issue? I am planning to release a new version with a new translation method supporting object cache, and it would be great if I could solve this bug in this same release.

    I have this same error.
    The filename is wp-content/languages/wpml/wordpress-ja.mo
    and the value is zero

    Not sure how to show you this file!
    The content of the file is this hex:

    DE 12 04 95 00 00 00 00 07 00 00 00 1C 00 00 00 54 00 00 00 00 00 00 00 8C 00 00 00 00 00 00 00 8C 00 00 00 18 00 00 00 8D 00 00 00 18 00 00 00 A6 00 00 00 11 00 00 00 BF 00 00 00 07 00 00 00 D1 00 00 00 10 00 00 00 D9 00 00 00 0B 00 00 00 EA 00 00 00 00 00 00 00 F6 00 00 00 10 00 00 00 F7 00 00 00 0B 00 00 00 08 01 00 00 07 00 00 00 14 01 00 00 07 00 00 00 1C 01 00 00 10 00 00 00 24 01 00 00 0B 00 00 00 35 01 00 00 00 55 52 4C 20 70 72 6F 64 75 63 74 5F 63 61 74 20 74 61 78 20 73 6C 75 67 00 55 52 4C 20 70 72 6F 64 75 63 74 5F 74 61 67 20 74 61 78 20 73 6C 75 67 00 55 52 4C 20 73 6C 75 67 3A 20 70 72 6F 64 75 63 74 00 70 72 6F 64 75 63 74 00 70 72 6F 64 75 63 74 2D 63 61 74 65 67 6F 72 79 00 70 72 6F 64 75 63 74 2D 74 61 67 00 00 70 72 6F 64 75 63 74 2D 63 61 74 65 67 6F 72 79 00 70 72 6F 64 75 63 74 2D 74 61 67 00 70 72 6F 64 75 63 74 00 70 72 6F 64 75 63 74 00 70 72 6F 64 75 63 74 2D 63 61 74 65 67 6F 72 79 00 70 72 6F 64 75 63 74 2D 74 61 67 00

    Plugin Author Chouby

    (@chouby)

    Hello,

    Yes, .mo files are binary so not readable for humans. A link to download the file would be great. That way, I would be able to use it in tests.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Warning: fread(): Length parameter must be greater than 0 mo-reader.php on line’ is closed to new replies.