0

I tried to update Wordpress to version 4.7 and received a fatal error. I'm using windows and XAMPP for localhost development.

Update WordPress
Downloading update from
https://downloads.wordpress.org/release/wordpress-4.7-new-bundled.zip…

Unpacking the update…    

Fatal error: Maximum execution time of 30 seconds exceeded in 
<path to project>\wp-admin\includes\class-wp-filesystem-direct.php on line 81

Inside class-wp-file-system-direct.php (line 81 is if-statement):

public function put_contents( $file, $contents, $mode = false ) {
    $fp = @fopen( $file, 'wb' );
    if ( ! $fp )
        return false;

    mbstring_binary_safe_encoding();

    $data_length = strlen( $contents );

    $bytes_written = fwrite( $fp, $contents );

    reset_mbstring_encoding();

    fclose( $fp );

    if ( $data_length !== $bytes_written )  // LINE 81
        return false;

    $this->chmod( $file, $mode );

    return true;
}

I removed read-only permissions from the includes folder and the file itself and explicitly allowed write permission on the file. I ran the auto update for Wordpress again, and now I'm getting.

Update WordPress
Another update is currently in progress.

Not sure what to try next.

Solved

Manually updating Wordpress solved the problem.

  • 3
    This isn't a bug in the code, it's just your server running out of time. Requests are given a limit of how much time, and if they run over it they're cut short. If this didn't happen then you could launch attacks on a server by having a script that takes hours to finish. Have you tried downloading WordPress and uploading a copy over the top of your site? If your host/server is super slow then it might run into this issue. – Tom J Nowell Dec 10 '16 at 0:02
  • Post your fix as an answer; not a comment, nor initial post update. It should equally be marked as such so as to clear your question from the unanswered list. – nyedidikeke Dec 10 '16 at 8:50
1

Manually updating Wordpress fixes this issue.

Upgrading WordPress Core Manually (How To) WordFence Reference

  • First create a full backup of your website. This is very important in case you make a mistake.
  • Download the newest WordPress ZIP file from wordpress.org. Unzip the file into a directory on your local machine or in a separate directory on your website.
  • Deactivate all of the plugins on your WordPress site.
  • Go to your website root directory and delete your ‘wp-includes’ and ‘wp-admin’ directories. You can do this via sFTP or via SSH.
  • Upload (or copy over) the new wp-includes and wp-admin directories from the new version of WordPress you unzipped to your website root directory to replace the directories you just deleted.
  • Don’t delete your wp-content directory or any of the files in that directory. Copy over the files from the wp-content directory in the new version of WordPress to your existing wp-content directory. You will overwrite any existing files with the same name. All of your other files in wp-content will remain in place.
  • Copy all files from the root (‘/’) directory of the new version of WordPress that you unzipped into your website root directory (or the root directory of your WordPress installation). You will overwrite any existing files and new files will also be copied across. Your wp-config.php file will not be affected because WordPress is never distributed with a wp-config.php file.
  • Examine the wp-config-sample.php which is distributed with WordPress to see if any new settings have been added that you may want to use or modify.
  • If you are upgrading manually after a failed auto-update, remove the .maintenance file from your WordPress root directory. This will remove the ‘failed update’ message from your site.
  • Visit your main WordPress admin page at /wp-admin/ where you may be asked to sign-in again. You may also have to upgrade your database and will be prompted if this is needed. If you can’t sign-in, try clearing your cookies. Re-enable your plugins which you disabled earlier.
  • Clear your browser cache to ensure you can see all changes. If you are using a front-end cache like ‘varnish’ you should also clear that to ensure that your customers can see the newest changes on your site.
  • Your upgrade is now complete and you should be running the newest version of WordPress.
1

Please

locate the file [XAMPP Installation Directory]\php\php.ini (e.g. C:\xampp\php\php.ini)

  1. open php.ini in Notepad or any Text editor

  2. locate the line containing max_execution_time and

  3. increase the value from 30 to some larger number (e.g. set: max_execution_time = 90)

  4. then restart Apache web server from the XAMPP control panel

If there will still be the same error after that, try to increase the value for the max_execution_time further more.

0

You can see here the proper way to handle with the max execution time issues.

  • It is better to write an answer here instead of providing the link which could go broke someday. – Picard Aug 4 '17 at 9:13
  • The day a wordpress.stackexchange.com link is broken... is the same day that this post ceases to exist. So i don't see the point... – jreis Aug 4 '17 at 11:24

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.