From 6bd793805549a91d26584fb8b1e3686cf82d51dd Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Wed, 11 Aug 2021 09:23:55 -0300 Subject: [PATCH 1/2] PHP Compatibility GH Action --- .github/workflows/php-compatibility.yml | 54 +++++++++++++++++++++++++ composer.json | 3 +- composer.lock | 16 ++++---- 3 files changed, 64 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/php-compatibility.yml diff --git a/.github/workflows/php-compatibility.yml b/.github/workflows/php-compatibility.yml new file mode 100644 index 0000000000..6d1e5325ad --- /dev/null +++ b/.github/workflows/php-compatibility.yml @@ -0,0 +1,54 @@ +name: PHP Compatibility + +env: + COMPOSER_VERSION: "1" + COMPOSER_CACHE: "${{ github.workspace }}/.composer-cache" + +on: + schedule: + - cron: '0 0 * * *' + push: + branches: + - develop + - master + pull_request: + branches: + - develop + +jobs: + php_compatibility: + name: PHP ${{ matrix.php }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ] + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set standard 10up cache directories + run: | + composer config -g cache-dir "${{ env.COMPOSER_CACHE }}" + + - name: Prepare composer cache + uses: actions/cache@v2 + with: + path: ${{ env.COMPOSER_CACHE }} + key: composer-${{ env.COMPOSER_VERSION }}-${{ hashFiles('**/composer.lock') }} + restore-keys: | + composer-${{ env.COMPOSER_VERSION }}- + + - name: Set PHP version + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + coverage: none + tools: prestissimo, composer:v1 + + - name: Install dependencies + run: composer install + + - name: Check PHP Compatibility + run: ./vendor/bin/phpcs -p elasticpress.php includes --standard=PHPCompatibilityWP --extensions=php --runtime-set testVersion ${{ matrix.php }} diff --git a/composer.json b/composer.json index ed6f1d8b2b..5116edd7ed 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,8 @@ "10up/phpcs-composer": "dev-master", "wpackagist-plugin/woocommerce":"*", "phpunit/phpunit": "^7", - "10up/wpacceptance": "dev-master" + "10up/wpacceptance": "dev-master", + "phpcompatibility/phpcompatibility-wp": "*" }, "scripts": { "lint": "phpcs elasticpress.php includes", diff --git a/composer.lock b/composer.lock index 7bd0958fb0..7c930c8cfd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c15b07485d849c42f5ff53353862b2ff", + "content-hash": "075efe059b27e67fbd4d34a65c4ecc52", "packages": [], "packages-dev": [ { @@ -2527,16 +2527,16 @@ }, { "name": "phpcompatibility/phpcompatibility-wp", - "version": "2.1.0", + "version": "2.1.2", "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", - "reference": "41bef18ba688af638b7310666db28e1ea9158b2f" + "reference": "a792ab623069f0ce971b2417edef8d9632e32f75" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/41bef18ba688af638b7310666db28e1ea9158b2f", - "reference": "41bef18ba688af638b7310666db28e1ea9158b2f", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/a792ab623069f0ce971b2417edef8d9632e32f75", + "reference": "a792ab623069f0ce971b2417edef8d9632e32f75", "shasum": "" }, "require": { @@ -2544,10 +2544,10 @@ "phpcompatibility/phpcompatibility-paragonie": "^1.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5" + "dealerdirect/phpcodesniffer-composer-installer": "^0.7" }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." }, "type": "phpcodesniffer-standard", @@ -2573,7 +2573,7 @@ "standards", "wordpress" ], - "time": "2019-08-28T14:22:28+00:00" + "time": "2021-07-21T11:09:57+00:00" }, { "name": "phpdocumentor/reflection-common", From 2b055c58a885ecc28b32e5b13ee7ff492ee50672 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Wed, 11 Aug 2021 09:35:36 -0300 Subject: [PATCH 2/2] PHP 5.6: Remove null coalescing operator --- includes/classes/Indexable/Comment/QueryIntegration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/classes/Indexable/Comment/QueryIntegration.php b/includes/classes/Indexable/Comment/QueryIntegration.php index e1b2f56d0a..bf1cd01dcb 100644 --- a/includes/classes/Indexable/Comment/QueryIntegration.php +++ b/includes/classes/Indexable/Comment/QueryIntegration.php @@ -195,7 +195,7 @@ public function maybe_filter_query( $results, WP_Comment_Query $query ) { * @return array */ protected function format_hits_as_comments( $comments, $new_comments, $query_vars ) { - $hierarchical = $query_vars['hierarchical'] ?? false; + $hierarchical = isset( $query_vars['hierarchical'] ) ? $query_vars['hierarchical'] : false; foreach ( $comments as $comment_array ) { $comment = new \WP_Comment( (object) $comment_array );