{"id":62,"date":"2013-09-18T22:00:14","date_gmt":"2013-09-18T20:00:14","guid":{"rendered":"http:\/\/www.anginf.de\/?p=62"},"modified":"2014-07-10T17:14:17","modified_gmt":"2014-07-10T15:14:17","slug":"wordpress-update-use-local-file","status":"publish","type":"post","link":"https:\/\/www.anginf.de\/?p=62","title":{"rendered":"WordPress Update: Use local file"},"content":{"rendered":"<p>My WordPress installation couldn&#8217;t download the necessary update files fast enough. I could see that in <code>wp-content\/tmp<\/code> the .tmp-files were created and growing, but they all stopped early and WordPress tried downloading again and again. Of course, your WordPress-installation might use a different tempdir. If you&#8217;re unsure, just add the following line to your wp-config.php to make sure that the tempdir is exactly what you expect:<\/p>\n<pre lang=\"php\">\r\ndefine('WP_TEMP_DIR', ABSPATH . 'wp-content\/tmp');\r\n<\/pre>\n<p>Here&#8217;s what you have to do:<\/p>\n<ol>\n<li>Download the update manually and upload it to the server into the directory <code>wp-content\/tmp<\/code>.<\/li>\n<li>Modify the file <code>wp-admin\/includes\/file.php<\/code> by adding these five lines to the <code>function download_url<\/code>, right before the line with the call to <code>wp_safe_remote_get()<\/code>.\n<pre lang=\"php\">\r\n$parts = parse_url($url);\r\nif ( empty($dir) )\r\n    $dir = get_temp_dir();\r\nif (file_exists($dir . $parts['path']))\r\n    return $dir . $parts['path'];\r\n<\/pre>\n<\/li>\n<li>Run the &#8222;Automatic Update&#8220; from your dashboard.<\/li>\n<\/ol>\n<p>Please keep these things in mind:<\/p>\n<ul>\n<li>The file that you stored into the <code>wp-content\/tmp<\/code> will be deleted after the upgrade.<\/li>\n<li>The changes to file.php will disappear as the upgrade normally overwrites file.php<\/li>\n<\/ul>\n<p>How does this work?<\/p>\n<p>We extract the filename from the URL that WordPress is trying to download (<code>$parts['path']<\/code> is the filename). If the file resides in the tempdir, simply return with this filename rather than with a temporary filename.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My WordPress installation couldn&#8217;t download the necessary update files fast enough. I could see that in wp-content\/tmp the .tmp-files were created and growing, but they all stopped early and WordPress tried downloading again and again. Of course, your WordPress-installation might use a different tempdir. If you&#8217;re unsure, just add the following line to your wp-config.php &hellip; <a href=\"https:\/\/www.anginf.de\/?p=62\" class=\"more-link\"><span class=\"screen-reader-text\">WordPress Update: Use local file<\/span> weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-62","post","type-post","status-publish","format-standard","hentry","category-allgemein"],"_links":{"self":[{"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/posts\/62","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.anginf.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=62"}],"version-history":[{"count":5,"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/posts\/62\/revisions"}],"predecessor-version":[{"id":67,"href":"https:\/\/www.anginf.de\/index.php?rest_route=\/wp\/v2\/posts\/62\/revisions\/67"}],"wp:attachment":[{"href":"https:\/\/www.anginf.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anginf.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anginf.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}