From ab46055e71f31ff1689193cd3ba969b09374c3ba Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Thu, 5 Dec 2024 16:08:45 +0800 Subject: [PATCH 1/3] Use PHPStan 2.0 --- composer.json | 6 +++--- includes/class-ckwc-integration.php | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index a9ed879..e0fb63a 100644 --- a/composer.json +++ b/composer.json @@ -17,9 +17,9 @@ "codeception/util-universalframework": "^1.0", "php-webdriver/webdriver": "^1.0", "wp-coding-standards/wpcs": "^3.0.0", - "phpstan/phpstan": "^1.7", - "szepeviktor/phpstan-wordpress": "^1.0", - "wp-cli/wp-cli-bundle": "2.9.0" + "phpstan/phpstan": "^1.0 || ^2.0", + "szepeviktor/phpstan-wordpress": "^1.0 || ^2.0", + "wp-cli/wp-cli-bundle": "2.11" }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/includes/class-ckwc-integration.php b/includes/class-ckwc-integration.php index f1628af..1b605fc 100644 --- a/includes/class-ckwc-integration.php +++ b/includes/class-ckwc-integration.php @@ -276,9 +276,6 @@ private function maybe_import_configuration() { global $wp_filesystem; // Bail if no configuration file was supplied. - if ( ! is_array( $_FILES ) ) { - return; - } if ( ! array_key_exists( 'woocommerce_ckwc_import', $_FILES ) ) { return; } From fdb143ab95ee3a05c648e6c8048e1a0bbf5a2ab1 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Thu, 5 Dec 2024 16:36:35 +0800 Subject: [PATCH 2/3] Include wp-config.php in symbols --- phpstan.neon.dist | 4 ++++ phpstan.neon.example | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 1452c1e..ead7df1 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -21,6 +21,10 @@ parameters: scanDirectories: - /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/wordpress/wp-content/plugins + # Location of constants for PHPStan to scan, building symbols. + scanFiles: + - /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/wordpress/wp-config.php + # Should not need to edit anything below here # Rule Level: https://phpstan.org/user-guide/rule-levels level: 5 diff --git a/phpstan.neon.example b/phpstan.neon.example index 1803717..ead7df1 100644 --- a/phpstan.neon.example +++ b/phpstan.neon.example @@ -1,4 +1,4 @@ -# PHPStan configuration for local static analysis. +# PHPStan configuration for GitHub Actions. # Include PHPStan for WordPress configuration. includes: @@ -19,7 +19,11 @@ parameters: # Location of WordPress Plugins for PHPStan to scan, building symbols. scanDirectories: - - /Users/tim/Local Sites/convertkit-github/app/public/wp-content/plugins + - /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/wordpress/wp-content/plugins + + # Location of constants for PHPStan to scan, building symbols. + scanFiles: + - /home/runner/work/convertkit-woocommerce/convertkit-woocommerce/wordpress/wp-config.php # Should not need to edit anything below here # Rule Level: https://phpstan.org/user-guide/rule-levels From b8ef13261aa4ed2b7eed75039e189a509c83a7ad Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Fri, 6 Dec 2024 18:47:14 +0800 Subject: [PATCH 3/3] Activate / deactivate _load_textdomain Plugin --- .github/workflows/test.yml | 6 ++++++ tests/_support/Helper/Acceptance/Plugin.php | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 047406c..dea5b02 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,6 +31,7 @@ jobs: DB_PASS: root DB_HOST: localhost INSTALL_PLUGINS: "custom-order-numbers-for-woocommerce woocommerce woocommerce-gateway-stripe" # Don't include this repository's Plugin here. + INSTALL_PLUGINS_URLS: "http://cktestplugins.wpengine.com/wp-content/uploads/2024/11/disable-doing-it-wrong-notices.zip" # URLs to specific third party Plugins STRIPE_TEST_PUBLISHABLE_KEY: ${{ secrets.STRIPE_TEST_PUBLISHABLE_KEY }} # Stripe Test API Publishable Key, stored in the repository's Settings > Secrets STRIPE_TEST_SECRET_KEY: ${{ secrets.STRIPE_TEST_SECRET_KEY }} # Stripe Test API Secret Key, stored in the repository's Settings > Secrets CONVERTKIT_API_KEY: ${{ secrets.CONVERTKIT_API_KEY }} # ConvertKit API Key, stored in the repository's Settings > Secrets @@ -126,6 +127,11 @@ jobs: working-directory: ${{ env.ROOT_DIR }} run: wp-cli plugin install ${{ env.INSTALL_PLUGINS }} --activate + # env.INSTALL_PLUGINS_URLS is a list of Plugin URLs, space separated, to install specific versions ot third party Plugins. + - name: Install Free Third Party WordPress Specific Version Plugins + working-directory: ${{ env.ROOT_DIR }} + run: wp-cli plugin install ${{ env.INSTALL_PLUGINS_URLS }} + # These should be stored as a separated list of URLs in the repository Settings > Secrets > Repository Secret > CONVERTKIT_PAID_PLUGIN_URLS. # We cannot include the URLs in this file, as they're not Plugins we are permitted to distribute. - name: Install Paid Third Party WordPress Plugins diff --git a/tests/_support/Helper/Acceptance/Plugin.php b/tests/_support/Helper/Acceptance/Plugin.php index a8fd1b8..b24baf1 100644 --- a/tests/_support/Helper/Acceptance/Plugin.php +++ b/tests/_support/Helper/Acceptance/Plugin.php @@ -47,6 +47,9 @@ public function deactivateConvertKitPlugin($I) */ public function activateWooCommerceAndConvertKitPlugins($I) { + // Activate Disable _load_textdomain notice. + $I->activateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); + // Activate ConvertKit Plugin. $I->activateConvertKitPlugin($I); @@ -78,6 +81,8 @@ public function deactivateWooCommerceAndConvertKitPlugins($I) // Deactivate WooCommerce Stripe Gateway before WooCommerce, to prevent WooCommerce throwing a fatal error. $I->deactivateThirdPartyPlugin($I, 'woocommerce-gateway-stripe'); $I->deactivateThirdPartyPlugin($I, 'woocommerce'); + + $I->deactivateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); } /**