• Resolved supadigital

    (@supadigital)


    Hi

    I have been tasked with fixing a site that was incompatible with php.8.0 as the host has discontinued use of version 7.4 and below.

    I manually updated wordPress to version 6.1.1 which has the site kind of just up and running again, HOWEVER I get an error popping up on various pages in the backend, particularly on the general settings page where as a result I cannot save any changes, and on the wordpress Updates page in the backend where it doesn’t list plugins requiring upates, but rather displays the following error:

    /usr/www/users/*#####/wp-admin/update-core.php:1047 Stack trace: #0 {main} thrown in /usr/www/users/*######/wp-admin/update-core.php on line 1047

    * This is the host username

    The particular section of code in question (with exact line 1047 highlighted) is:

    $last_update_check = false;
    	$current           = get_site_transient( 'update_core' );
    
    	if ( $current && isset( $current->last_checked ) ) {
    		<strong>$last_update_check = $current->last_checked + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;</strong>
    	}

    Does anyone know how I could possibly resolve this?

    My logic is telling me that because I manually updated wordpress, there is no value for the last update date and time, and therefore an empty string or integer is causing the error… or something like that. I am not a coder, just guessing ??

    Assistance would be massively appreciated.

    Thanks

    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Hi,
    is there more to the error message? This only points out where the error happended, there should be a more specific error message. If you don’t find the error message activate the debug mode and then post the error message here. https://www.ads-software.com/support/article/debugging-in-wordpress/

    Thread Starter supadigital

    (@supadigital)

    @benniledl

    Thanks so much for responding. And apologies, I thought I’d copied the entire error.

    I have debug enabled and when I visit the WordPress Updates page, this is the full error I get:

    Fatal error: Uncaught TypeError: Unsupported operand types: string * int in /usr/www/users/######/wp-admin/update-core.php:1047 Stack trace: #0 {main} thrown in /usr/www/users/#####/wp-admin/update-core.php on line 1047
    There has been a critical error on this website. Please check your site admin email inbox for instructions.

    Any assistance massively appreciated. Thanks so much.

    PS: No errors on frontend.

    • This reply was modified 2 years, 3 months ago by supadigital.

    Hi, I would suggest that you copy some code into that file before the line that makes problems.
    This code that I send you takes those variables and saves them in a file so that we can see what variable is making a problem and maybe we get an idea about what we can do now:

    
    file_put_contents("test_debug.log", "current->last_checked : ".gettype('$current->last_checked')." ".$current->last_checked."\n get_option( gmt offset ): ".gettype(get_option('gmt_offset')*HOUR_IN_SECONDS)." ".get_option('gmt_offset') * HOUR_IN_SECONDS);
    
    
    Thread Starter supadigital

    (@supadigital)

    @benniledl
    Thanks again for your response and assistance thus far.

    I added the code and received the following slightly more lengthy error:

    Warning: Undefined variable $current in /usr/www/users/therucnvps/wp-admin/update-core.php on line 1043 Warning: Attempt to read property "last_checked" on null in /usr/www/users/therucnvps/wp-admin/update-core.php on line 1043 Fatal error: Uncaught TypeError: Unsupported operand types: string * int in /usr/www/users/therucnvps/wp-admin/update-core.php:1043 Stack trace: #0 {main} thrown in /usr/www/users/therucnvps/wp-admin/update-core.php on line 1043
    There has been a critical error on this website. Please check your site admin email inbox for instructions.

    Please let me know your thoughts. And again – thanks so much for your assistance thus far.

    Hi, I think you have added the code to at the wrong place, insert it before this:

    if ( $current && isset( $current->last_checked ) ) {
                    $last_update_check = $current->last_checked + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
    }

    Then in the wp-admin folder there should be a file named test_debug.log please post the content of it
    Note: the file should be there when you execute the update-core.php again (start the update)

    • This reply was modified 2 years, 3 months ago by Benedikt Ledl.
    Thread Starter supadigital

    (@supadigital)

    @benniledl

    Thanks so much for the clarification. I have added the code where you requested, and then error remains:

    Fatal error: Uncaught TypeError: Unsupported operand types: string * int in /usr/www/users/therucnvps/wp-admin/update-core.php:1046 Stack trace: #0 {main} thrown in /usr/www/users/therucnvps/wp-admin/update-core.php on line 1046

    There is no test_debug file in the wp-admin folder thereafter either.

    PLEASE NOTE: I am unable to trigger any updates as the updates are not listed on the updates page. Literally all I get when opening the UPDATES page in the backend is this:

    WordPress Updates
    Here you can find information about updates, set auto-updates and see what plugins or themes need updating.
    
    Fatal error: Uncaught TypeError: Unsupported operand types: string * int in /usr/www/users/therucnvps/wp-admin/update-core.php:1046 Stack trace: #0 {main} thrown in /usr/www/users/therucnvps/wp-admin/update-core.php on line 1046
    There has been a critical error on this website. Please check your site admin email inbox for instructions.
    
    Learn more about troubleshooting WordPress.

    That’s all that displays.

    I added your code at the following surrounding code just for clarification:

    $last_update_check = true;
    	$current           = get_site_transient( 'update_core' );
            file_put_contents("test_debug.log", "current->last_checked : ".gettype('$current->last_checked')." ".$current->last_checked."\n get_option( gmt offset ): ".gettype(get_option('gmt_offset')*HOUR_IN_SECONDS)." ".get_option('gmt_offset') * HOUR_IN_SECONDS);
    	if ( $current && isset( $current->last_checked ) ) {
    		$last_update_check = $current->last_checked + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
    	}
    
    	echo '<h2 class="wp-current-version">';
    	/* translators: Current version of WordPress. */
    	printf( __( 'Current version: %s' ), get_bloginfo( 'version' ) );
    	echo '</h2>';

    Apologies if I’m doing something incorrectly. I look forward to your thoughts once again. Thanks so much.

    Hi, thanks if you don’t get the file then delete my code again please. I am looking into the error, it has something to do with your timezone, have you set your timezone in the wp backend? If yes please try to change it to something different e.G. Berlin Germany

    Thread Starter supadigital

    (@supadigital)

    @benniledl
    Thanks so much.

    I also thought it had something to do with timezone at one stage, so I went to set the timezone on the general settings page, BUT, I also get an error on that page in the backend and the “Save settings” button is not available as a result, so I am unable to edit any settings on this page. The page displays as normal and the current timezone is set to UTC, but then the date format option just shows a single bullet/dot that I am able to select, but then displays a critical error message immediately thereafter without actually listing any of the date option:

    ‘Date Format

    There has been a critical error on this website. Please check your site admin email inbox for instructions.

    Learn more about troubleshooting WordPress.’

    Is it possible to somehow set the date format and timezone manually via the database or something? Or do you have any other ideas? Bearing in mind that this is all as a result of updating manually to latest version of wordpress from an older version that wasn’t compatible with php8.0 which is now a compulsory php version as the host has deprecated 7.4 and older.

    Thanks so much. Any further ideas would be greatly appreciated.

    Hi, in /wp-admin/options-general.php
    add this code before line 16, this will output all available timezones, open the page where you update the timezone in your browser, on the top of the page there will be the timezones, if there are none then your installation is missing them.

    $tzstring = get_option( 'timezone_string' );
    echo wp_timezone_choice( $tzstring, get_user_locale() );
    Thread Starter supadigital

    (@supadigital)

    @benniledl

    Thanks so much for the code and assistance once again.

    I have done as requested and there were no timezones or anything displayed at the top of the page or anywhere else.

    Does this mean that the manual update was incomplete possibly, or that there is an error in the database or something? Should I attempt to re-install the update package?

    Let me know next steps and I will do the necessary as well as sponsor you a beer once this is all sorted. haha. Thanks so much. I look forward to your next steps.

    Hi,
    no worries and no need for a beer but thanks ??
    Unfortunately I don’t know how the timezones work but I think reinstalling wordpress would be a good start:

    upload and overwrite these 2 folders from a functioning wordpress installation make sure it is the same version as yours
    /wp-admin/
    /wp-includes/
    
    and all .php files in the site root (make sure to not replace the wp-config.php and wp-content folder!!)
    Thread Starter supadigital

    (@supadigital)

    @benniledl

    Hi again

    Just a quick heads-up that I managed to sort this out. Basically, I tried the manual install by uploading to the client server over and over and it kept giving issues. So what I did was create a fresh install on my own server using the softaculous wordpress installer in CPANEL. Then I simply transferred the /content folder and the wp-config file to the new installation on my server. So all the other rubbish that was in the htaccess and root folder and stuff was no longer present and everything was a-okay from thereon in.

    Just wanted to take this opportunity to thank you so much for your assistance, it is very much appreciated. Keep up the good work and keep doing what you’re doing!

    Thanks man!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Error with update_core.php after updating manually’ is closed to new replies.