Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For PHP 7.1 compat use get_wp_details() instead of "version.php" include. #13

Merged
merged 2 commits into from
May 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion features/core-check-update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ Feature: Check for more recent versions
1
"""

@less-than-php-7
Scenario: No minor updates for an unlocalized WordPress release
Given a WP install

Expand Down
1 change: 1 addition & 0 deletions features/core-download.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Feature: Download WordPress

Scenario: Verify release hash when downloading new version
Given an empty directory
And an empty cache

When I run `wp core download --version=4.4.1`
Then STDOUT should contain:
Expand Down
50 changes: 36 additions & 14 deletions features/core-update.feature
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
Feature: Update WordPress core

@less-than-php-7
Scenario: Update from a ZIP file
Given a WP install

When I run `wp core download --version=3.8 --force`
When I run `wp core download --version=3.9 --force`
Then STDOUT should not be empty

When I run `wp eval 'echo $GLOBALS["wp_version"];'`
Then STDOUT should be:
"""
3.8
3.9
"""

When I run `wget http://wordpress.org/wordpress-3.9.zip --quiet`
And I run `wp core update wordpress-3.9.zip`
When I run `wget http://wordpress.org/wordpress-4.0.zip --quiet`
And I run `wp core update wordpress-4.0.zip`
Then STDOUT should be:
"""
Starting update...
Expand All @@ -27,9 +26,11 @@ Feature: Update WordPress core
When I run `wp eval 'echo $GLOBALS["wp_version"];'`
Then STDOUT should be:
"""
3.9
4.0
"""

# PHP 7.1 needs WP 3.9 (due to wp_check_php_mysql_versions(), see trac changeset [27257]),
# and travis doesn't install mysql extension by default for PHP 7.0.
@less-than-php-7
Scenario: Update to the latest minor release
Given a WP install
Expand All @@ -55,12 +56,35 @@ Feature: Update WordPress core
3.7.21
"""

@less-than-php-7
Scenario: Update to the latest minor release (PHP 7.1 compatible with WP >= 3.9)
Given a WP install

When I run `wp core download --version=3.9.9 --force`
Then STDOUT should not be empty

When I run `wp core update --minor`
Then STDOUT should contain:
"""
Updating to version 3.9.19
"""

When I run `wp core update --minor`
Then STDOUT should be:
"""
Success: WordPress is at the latest minor release.
"""

When I run `wp core version`
Then STDOUT should be:
"""
3.9.19
"""

Scenario: Core update from cache
Given a WP install
And an empty cache

When I run `wp core update --version=3.8.1 --force`
When I run `wp core update --version=3.9.1 --force`
Then STDOUT should not contain:
"""
Using cached file
Expand All @@ -70,13 +94,13 @@ Feature: Update WordPress core
Downloading
"""

When I run `wp core update --version=3.9 --force`
When I run `wp core update --version=4.0 --force`
Then STDOUT should not be empty

When I run `wp core update --version=3.8.1 --force`
When I run `wp core update --version=3.9.1 --force`
Then STDOUT should contain:
"""
Using cached file '{SUITE_CACHE_DIR}/core/wordpress-3.8.1-en_US.zip'...
Using cached file '{SUITE_CACHE_DIR}/core/wordpress-3.9.1-en_US.zip'...
"""
And STDOUT should not contain:
"""
Expand Down Expand Up @@ -161,7 +185,6 @@ Feature: Update WordPress core
wordpress-4.2.4-partial-1-en_US.zip
"""

@less-than-php-7
Scenario: Make sure files are cleaned up
Given a WP install
When I run `wp core update --version=4.4 --force`
Expand Down Expand Up @@ -195,7 +218,6 @@ Feature: Update WordPress core
When I run `wp post create --post_title='Test post' --porcelain`
Then STDOUT should be a number

@less-than-php-7 @require-wp-4.0
Scenario: Minor update on an unlocalized WordPress release
Given a WP install
And an empty cache
Expand All @@ -210,7 +232,7 @@ Feature: Update WordPress core
Then STDOUT should contain:
"""
Updating to version 4.0.18 (en_US)...
Descargando paquete de instalación desde https://downloads.wordpress.org/release/wordpress-4.0.16-partial-0.zip
Descargando paquete de instalación desde https://downloads.wordpress.org/release/wordpress-4.0.18-partial-0.zip
"""
And STDOUT should contain:
"""
Expand Down
2 changes: 1 addition & 1 deletion features/core.feature
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Feature: Manage WordPress installation
admin@example.com
"""

When I run `wp core install --url=localhost:8001 --title=Test --admin_user=wpcli --prompt=admin_email,admin_password < session`
When I run `wp core install --url=localhost:8001 --title=Test --admin_user=wpcli --prompt=admin_password,admin_email < session`
Then STDOUT should not be empty

When I run `wp eval 'echo home_url();'`
Expand Down
14 changes: 7 additions & 7 deletions src/Core_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ public function download( $args, $assoc_args ) {

$from_version = '';
if ( file_exists( $download_dir . 'wp-includes/version.php' ) ) {
global $wp_version;
require_once( $download_dir . 'wp-includes/version.php' );
$from_version = $wp_version;
$wp_details = self::get_wp_details( $download_dir );
$from_version = $wp_details['wp_version'];
}

WP_CLI::log( sprintf( 'Downloading WordPress %s (%s)...', $version, $locale ) );
Expand Down Expand Up @@ -774,8 +773,8 @@ public function version( $args = array(), $assoc_args = array() ) {
* @type string $wp_local_package The TinyMCE version.
* }
*/
private static function get_wp_details() {
$versions_path = ABSPATH . 'wp-includes/version.php';
private static function get_wp_details( $abspath = ABSPATH ) {
$versions_path = $abspath . 'wp-includes/version.php';

if ( ! is_readable( $versions_path ) ) {
WP_CLI::error(
Expand Down Expand Up @@ -1022,9 +1021,10 @@ public function update( $args, $assoc_args ) {
}
} else {

$to_version = '';
if ( file_exists( ABSPATH . 'wp-includes/version.php' ) ) {
include( ABSPATH . 'wp-includes/version.php' );
$to_version = $wp_version;
$wp_details = self::get_wp_details();
$to_version = $wp_details['wp_version'];
}

$locale = \WP_CLI\Utils\get_flag_value( $assoc_args, 'locale', get_locale() );
Expand Down