[wp-trac] [WordPress Trac] #47301: Core_Upgrader class not extending or working properly
WordPress Trac
noreply at wordpress.org
Fri May 17 13:21:48 UTC 2019
#47301: Core_Upgrader class not extending or working properly
-----------------------------------------------+---------------------------
Reporter: techeshta | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: Upgrade/Install | Version:
Severity: normal | Resolution:
Keywords: has-screenshots reporter-feedback | Focuses:
-----------------------------------------------+---------------------------
Comment (by techeshta):
Hi @SergeyBiryukov,
Thanks for your comment on the issue.
> What's the difference between this manual functionality and default
WordPress updates?
There is a one-click update instead of going to the WordPress Updates
page.
> Could you share an example piece of code to reproduce the problem?
Yes, of course. Why not!
Here it is,
{{{
function ff_wordpress_instant_update() {
ini_set('max_execution_time', 10000);
global $wp_version;
$res = array();
ob_start();
include_once ( ABSPATH . '/wp-admin/includes/admin.php' );
require_once ( ABSPATH . '/wp-admin/includes/class-wp-
upgrader.php' );
include_once ( ABSPATH . '/wp-admin/includes/update.php' );
$core_updates = get_core_updates();
$cur_phpversion = phpversion();
$wp_phpversion = $core_updates[0]->php_version;
if($cur_phpversion < $wp_phpversion) {
$res['phpvermsg'] = "WordPress update requires PHP version
".$wp_phpversion." or higher. You are currently running PHP version
".$cur_phpversion." Please contact your host to upgrade your PHP version.
You may also be able to do it via cPanel, under Software ==> PHP
Selector.";
$res['isres'] = false;
echo json_encode($res);
exit;
}
if (count($core_updates) > 0) {
foreach ($core_updates as $core_update) {
global $latest_version;
if ('latest' === $core_update->response) {
$information['upgrade'] = 'SUCCESS';
} else {
if ('upgrade' === $core_update->response
&& $core_update->locale === get_locale() && version_compare($wp_version,
$core_update->current, '<=')) {
// Upgrade!
$upgrade = false;
if (class_exists('Core_Upgrader'))
{
$core = new
Core_Upgrader();
$upgrade =
$core->upgrade($core_update);
}
break;
}
}
}
}
}
}}}
{{{
}}}
Let me know if you want any other things from my end.
Thanks
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47301#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list