Skip to content

Commit

Permalink
General: require PHP 5.3+ to be able to run Jetpack. (#12395)
Browse files Browse the repository at this point in the history
* General: require PHP 5.3+ to be able to run Jetpack.

If a site runs WP 5.1 (where the PHP requirements are still PHP 5.2) and updates Jetpack:
1. We pause Jetpack (stop loading it).
2. We display an admin notice inviting folks to update PHP.
3. If WP_DEBUG is on, we log an error.

* Add comment to remind us to remove code once WP 5.2 is the min v.

* Removing PHP 5.2 testing since Jetpack does not support it anymore
  • Loading branch information
jeherve authored May 17, 2019
1 parent c53cf49 commit 2e9efb2
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
6 changes: 0 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ env:
# so it doesn't need to be re-defined below.
matrix:
include:
# The versions listed below run within Precise distro with PHP 5.2 due to Travis limitation
# Hard-coding the versions since WP 5.2 has a PHP 5.6 minimum support.
# When removing this, remove corresponding setup functions in setup-travis.sh.
- php: "5.2"
env: WP_MODE=single WP_BRANCH=5.1
dist: precise
- if: branch !~ /(^branch-.*-built)/
language: node_js
env: WP_TRAVISCI="yarn lint"
Expand Down
40 changes: 40 additions & 0 deletions jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

define( 'JETPACK__MINIMUM_WP_VERSION', '5.1' );
define( 'JETPACK__MINIMUM_PHP_VERSION', '5.3' );

define( 'JETPACK__VERSION', '7.4-alpha' );
define( 'JETPACK_MASTER_USER', true );
Expand Down Expand Up @@ -93,6 +94,45 @@ function jetpack_admin_unsupported_wp_notice() { ?>
return;
}

/**
* Outputs an admin notice for folks running an outdated version of PHP.
* @todo: Remove once WP 5.2 is the minimum version.
*
* @since 7.4.0
*/
function jetpack_admin_unsupported_php_notice() { ?>
<div class="notice notice-error is-dismissible">
<p><?php esc_html_e( 'Jetpack requires a more recent version of PHP and has been paused. Please update PHP to continue enjoying Jetpack.', 'jetpack' ); ?></p>
<p class="button-container">
<?php
printf(
'<a class="button button-primary" href="%1$s" target="_blank" rel="noopener noreferrer">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
esc_url( wp_get_update_php_url() ),
__( 'Learn more about updating PHP' ),
/* translators: accessibility text */
__( '(opens in a new tab)' )
);
?>
</p>
</div>
<?php
}

if ( version_compare( phpversion(), JETPACK__MINIMUM_PHP_VERSION, '<' ) ) {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log(
sprintf(
/* translators: Placeholders are numbers, versions of PHP in use on the site, and required by Jetpack. */
esc_html__( 'Your version of PHP (%1$s) is lower than the version required by Jetpack (%2$s). Please update PHP to continue enjoying Jetpack.', 'jetpack' ),
esc_html( phpversion() ),
JETPACK__MINIMUM_PHP_VERSION
)
);
}
add_action( 'admin_notices', 'jetpack_admin_unsupported_php_notice' );
return;
}

add_filter( 'jetpack_require_lib_dir', 'jetpack_require_lib_dir' );
add_filter( 'jetpack_should_use_minified_assets', 'jetpack_should_use_minified_assets', 9 );

Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Contributors: automattic, adamkheckler, aduth, akirk, allendav, alternatekev, an
Tags: Jetpack, WordPress.com, backup, security, related posts, CDN, speed, anti-spam, social sharing, SEO, video, stats
Stable tag: 7.3.1
Requires at least: 5.0
Requires PHP: 5.3
Tested up to: 5.2

The ideal plugin for stats, related posts, search engine optimization, social sharing, protection, backups, security, and more.
Expand Down
6 changes: 0 additions & 6 deletions tests/setup-travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ latest)
previous)
git clone --depth=1 --branch $(php ./tests/get-wp-version.php --previous) git://develop.git.wordpress.org/ /tmp/wordpress-previous
;;
5.0)
git clone --depth=1 --branch 5.0 git://develop.git.wordpress.org/ /tmp/wordpress-5.0
;;
5.1)
git clone --depth=1 --branch 5.1 git://develop.git.wordpress.org/ /tmp/wordpress-5.1
;;
esac

clone_exit_code=$?
Expand Down

0 comments on commit 2e9efb2

Please sign in to comment.