• Resolved Tedder T

    (@teddert)


    At some point, the ability to translate in the Loco Translate plugin stopped working.

    When editing any translation, a message appears: Error: Uploaded file is not readable.

    Through debug.log we found out that your plugin is trying to create a temporary file, outside the site directory – which is restricted through open_basedir.

    How to solve the problem? Disabling open_basedir helps, but it’s not the right solution.

    Thanks a lot.

    P.S. Versions Loco Translate: 2.6.4, WordPress: 6.2.2, PHP: 7.4.29 (fpm-fcgi), Server: nginx/1.20.2

    • This topic was modified 1 year, 5 months ago by Tedder T.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Tim W

    (@timwhitlock)

    It’s normal to add required temporary directories to the open_basedir path. This doesn’t mean disabling it.

    Thread Starter Tedder T

    (@teddert)

    What parameter PHP does your plugin look at that can be forced into wp-config.php to specify the temporary directory?

    The code below doesn’t help…

    define( 'WP_TEMP_DIR', dirname(__FILE__) . '/tmp/' );
    • This reply was modified 1 year, 5 months ago by Tedder T.
    Plugin Author Tim W

    (@timwhitlock)

    PHP handles file uploads before WordPress has started. Hence, my plugin accesses uploaded files from PHP’s internal $_FILES collection. I believe this observes upload_tmp_dir.

    So check your PHP config for this path and add it to your open_basedir path.

    Alternatively choose a temporary directory already under your open_basedir path and set upload_tmp_dir to that value.

    Thread Starter Tedder T

    (@teddert)

    Why isn’t the WP_TEMP_DIR standard for WordPress used? So without editing the server settings for each site personally – you can not use the plugin?

    Thank you for your support

    Plugin Author Tim W

    (@timwhitlock)

    Why isn’t the WP_TEMP_DIR standard for WordPress used?

    Why? Because I wasn’t aware of it, and I didn’t realise this was an issue.

    I will look into using move_uploaded_file so that WP_TEMP_DIR can be observed in the next release, but if you want a quick resolution I suggest doing as mentioned.

    Thread Starter Tedder T

    (@teddert)

    Thank you very much. Yeah, I didn’t run into this problem either until I switched to a VPS server…
    Now many of the settings for each site must be prescribed independently.
    Thanks again for your patient answers!

    Thread Starter Tedder T

    (@teddert)

    I temporarily prescribed the settings upload_tmp_dir in the configuration file of the site – everything is working again.


    Now I will wait for the plugin update which will use the parameter WP_TEMP_DIR

    Many thanks to the developer!

    Plugin Author Tim W

    (@timwhitlock)

    I’ve looked deeper into this and refreshed my memory on the topic.

    I’ve added some code (in the dev branch) that moves the uploaded file to WP_TEMP_DIR if it can’t be read from its original location. However, I am unable to reproduce any scenario where this can happen. In my tests, if I set a upload_tmp_dir value outside of open_basedir, PHP automatically falls back to sys_temp_dir. Changing the value of WP_TEMP_DIR can’t affect this behaviour.

    Plugin Author Tim W

    (@timwhitlock)

    Since posting I’ve managed to reproduce the error where uploads can succeed based on upload_tmp_dir, but then fail later on due open_basedir restrictions.

    My fix is to move the uploaded file as discussed previously, and this does observe WP_TEMP_DIR because it uses WordPress’s own get_temp_dir function.

    This fix is in the development version and will go live soon. Now I’ve been able to test this, I am marking as resolved.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Loco Translate & open_basedir’ is closed to new replies.