Problem: All pluging & themes updates fail on folder does not exist or unavialble (WP. 5.3.2)

After research I found that in wp-admin/file.php in function: download_url

the call to wp_tempnam() returns non existing folder. Causing the update to fail.

More info:

  1. wp-config has define('WP_TEMP_DIR', dirname(__FILE__) . '/wp-content/temp/'); above call to wp-settings.php
  2. No definitions in database: wp_options for upload dir. - to use defaults.
  3. All needed folders exists with propper mode 0755
  4. Changing theme to default 2020 did not help (verify that no other code is involved)

All the above did not help. Only when I override the result of wp_tempnam() in file.php all works well.

Question: wp_tempnam() uses get_temp_dir() which returns the wrong part of the path. What am I missing? How can it be fixed?

  • Perhaps 777 would work.. but then, why don't you just use the default system path? – Sally CJ Mar 25 at 6:40
  • I try to use defaults... I did not provide any setting. – Mulli Mar 26 at 7:01
  • I'm saying, why do you need to define the WP_TEMP_DIR? If you don't define it, the default system path would be used. And by the "777", I mean setting the directory permission to 0777... – Sally CJ Mar 26 at 11:19
  • 1
    Well, I tried setting a custom WP_TEMP_DIR and things worked for me (i.e. wp_tempnam() returned a valid temporary file), except I didn't test with plugin/theme updates. So does using 0777 work? But if it's not your code, then how about not using the custom WP_TEMP_DIR value? Using the wp-content is also, IMO, not a good idea. The default (which is normally out of the 'public' site directory) should be fine in most cases. – Sally CJ Mar 27 at 16:41
  • 1
    @SallyCJ I replaced the plugin... – Mulli Mar 28 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.