From b29d50b02e7e7a3e14c039e9c28ba03d08500be1 Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Sat, 22 Jun 2024 13:28:40 +0200 Subject: [PATCH 01/11] feat: deprecate webook carriers --- .../Defaults}/Carrier/Webhook.php | 5 +++- .../Defaults}/Carrier/WebhookJson.php | 5 +++- .../src-deprecated}/Traits/Webhook.php | 4 +++ src/Compat/WebhookCompat.php | 28 +++++++++++++++++++ src/Repository/CarrierRepository.php | 11 ++++++-- src/Runtime.php | 1 + 6 files changed, 49 insertions(+), 5 deletions(-) rename {src/Repository => compat/src-deprecated/Defaults}/Carrier/Webhook.php (97%) rename {src/Repository => compat/src-deprecated/Defaults}/Carrier/WebhookJson.php (96%) rename {src => compat/src-deprecated}/Traits/Webhook.php (96%) create mode 100644 src/Compat/WebhookCompat.php diff --git a/src/Repository/Carrier/Webhook.php b/compat/src-deprecated/Defaults/Carrier/Webhook.php similarity index 97% rename from src/Repository/Carrier/Webhook.php rename to compat/src-deprecated/Defaults/Carrier/Webhook.php index 385ccb8d..d0fb658d 100644 --- a/src/Repository/Carrier/Webhook.php +++ b/compat/src-deprecated/Defaults/Carrier/Webhook.php @@ -8,14 +8,17 @@ declare(strict_types=1); -namespace BracketSpace\Notification\Repository\Carrier; +namespace BracketSpace\Notification\Defaults\Carrier; use BracketSpace\Notification\Interfaces\Triggerable; +use BracketSpace\Notification\Repository\Carrier\BaseCarrier; use BracketSpace\Notification\Repository\Field; use BracketSpace\Notification\Traits\Webhook as WebhookTrait; /** * Webhook Carrier + * + * @deprecated [Next] */ class Webhook extends BaseCarrier { diff --git a/src/Repository/Carrier/WebhookJson.php b/compat/src-deprecated/Defaults/Carrier/WebhookJson.php similarity index 96% rename from src/Repository/Carrier/WebhookJson.php rename to compat/src-deprecated/Defaults/Carrier/WebhookJson.php index a5e80d7b..3aa5b28d 100644 --- a/src/Repository/Carrier/WebhookJson.php +++ b/compat/src-deprecated/Defaults/Carrier/WebhookJson.php @@ -8,14 +8,17 @@ declare(strict_types=1); -namespace BracketSpace\Notification\Repository\Carrier; +namespace BracketSpace\Notification\Defaults\Carrier; use BracketSpace\Notification\Interfaces\Triggerable; +use BracketSpace\Notification\Repository\Carrier\BaseCarrier; use BracketSpace\Notification\Repository\Field; use BracketSpace\Notification\Traits\Webhook as WebhookTrait; /** * Webhook Carrier + * + * @deprecated [Next] */ class WebhookJson extends BaseCarrier { diff --git a/src/Traits/Webhook.php b/compat/src-deprecated/Traits/Webhook.php similarity index 96% rename from src/Traits/Webhook.php rename to compat/src-deprecated/Traits/Webhook.php index 62ed5348..e9b6ccb4 100644 --- a/src/Traits/Webhook.php +++ b/compat/src-deprecated/Traits/Webhook.php @@ -14,6 +14,8 @@ /** * Webhook trait + * + * @deprecated [Next] */ trait Webhook { @@ -26,6 +28,8 @@ trait Webhook */ public function __construct($name) { + notification_deprecated_class( __CLASS__, '[Next]' ); + $slug = strtolower(str_replace(' ', '_', $name)); parent::__construct($slug, __($name, 'notification')); diff --git a/src/Compat/WebhookCompat.php b/src/Compat/WebhookCompat.php new file mode 100644 index 00000000..7e3122f7 --- /dev/null +++ b/src/Compat/WebhookCompat.php @@ -0,0 +1,28 @@ +getSetting('carriers/webhook/enable')) { + if ( + ! \Notification::settings()->getSetting('carriers/webhook/enable') || + ! apply_filters('notification/compat/webhook/register', true) + ) { return; } - Register::carrier(DocHooksHelper::hook(new Carrier\Webhook('Webhook'))); - Register::carrier(DocHooksHelper::hook(new Carrier\WebhookJson('Webhook JSON'))); + Register::carrier(DocHooksHelper::hook(new Webhook('Webhook'))); + Register::carrier(DocHooksHelper::hook(new WebhookJson('Webhook JSON'))); } } diff --git a/src/Runtime.php b/src/Runtime.php index 833480bf..f71c6d37 100644 --- a/src/Runtime.php +++ b/src/Runtime.php @@ -273,6 +273,7 @@ public function singletons() $this->addComponent(new Integration\TwoFactor()); $this->addComponent(new Api\Api()); + $this->addComponent(new Compat\WebhookCompat()); } /** From 4575fb99583b757f2759ef71d35ccee5788cc841 Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Wed, 26 Jun 2024 10:16:35 +0200 Subject: [PATCH 02/11] chore: disable webhook sending --- .../Defaults/Carrier/Webhook.php | 40 +++++------------ .../Defaults/Carrier/WebhookJson.php | 43 +++++-------------- 2 files changed, 22 insertions(+), 61 deletions(-) diff --git a/compat/src-deprecated/Defaults/Carrier/Webhook.php b/compat/src-deprecated/Defaults/Carrier/Webhook.php index d0fb658d..310d0383 100644 --- a/compat/src-deprecated/Defaults/Carrier/Webhook.php +++ b/compat/src-deprecated/Defaults/Carrier/Webhook.php @@ -142,34 +142,16 @@ public function formFields() */ public function send(Triggerable $trigger) { - $data = $this->data; - - $args = $this->parseArgs($data['args']); - $args = apply_filters('notification/carrier/webhook/args', $args, $this, $trigger); - - if ($data['json']) { - $args = wp_json_encode($args); - } - - // Headers. - $headers = $data['json'] - ? ['Content-Type' => 'application/json'] - : []; - - if (\Notification::settings()->getSetting('carriers/webhook/headers')) { - $headers = array_merge($headers, $this->parseArgs($data['headers'])); - } - - // Call each URL separately. - foreach ($data['urls'] as $url) { - $filteredArgs = apply_filters( - sprintf('notification/carrier/webhook/args/%s', $url['type']), - $args, - $this, - $trigger - ); - - $this->httpRequest($url['recipient'], $filteredArgs, $headers, $url['type']); - } + /** + * ================== WARNING! ================== + * + * The Webhook carrier is not available in the plugin since version 9. + * + * We moved that function into a more robust paid extension that can + * also handle incoming webhooks. + * + * Read more: https://docs.bracketspace.com/notification/extensions/webhooks#webhooks-dont-work-after-upgrading-to-notification-v9 + * Extension: https://bracketspace.com/downloads/notification-webhooks/ + */ } } diff --git a/compat/src-deprecated/Defaults/Carrier/WebhookJson.php b/compat/src-deprecated/Defaults/Carrier/WebhookJson.php index 3aa5b28d..e60db714 100644 --- a/compat/src-deprecated/Defaults/Carrier/WebhookJson.php +++ b/compat/src-deprecated/Defaults/Carrier/WebhookJson.php @@ -111,37 +111,16 @@ public function formFields() */ public function send(Triggerable $trigger) { - $data = $this->data; - - $args = $this->parseArgs($data['args']); - $args = apply_filters('notification/carrier/webhook/args', $args, $this, $trigger); - - if ($data['json']) { - $args = $data['json']; - } - - // Headers. - $headers = $data['json'] - ? ['Content-Type' => 'application/json'] - : []; - - if (\Notification::settings()->getSetting('carriers/webhook/headers')) { - $headers = array_merge( - $headers, - $this->parseArgs($data['headers']) - ); - } - - // Call each URL separately. - foreach ($data['urls'] as $url) { - $filteredArgs = apply_filters( - sprintf('notification/carrier/webhook/args/%s', $url['type']), - $args, - $this, - $trigger - ); - - $this->httpRequest($url['recipient'], $filteredArgs, $headers, $url['type']); - } + /** + * ================== WARNING! ================== + * + * The Webhook carrier is not available in the plugin since version 9. + * + * We moved that function into a more robust paid extension that can + * also handle incoming webhooks. + * + * Read more: https://docs.bracketspace.com/notification/extensions/webhooks#webhooks-dont-work-after-upgrading-to-notification-v9 + * Extension: https://bracketspace.com/downloads/notification-webhooks/ + */ } } From efe338d2145741a47b4f23d2b8729589f41b8fa5 Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Wed, 26 Jun 2024 17:08:37 +0200 Subject: [PATCH 03/11] fix: message field printing actual message --- src/Repository/Field/MessageField.php | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/Repository/Field/MessageField.php b/src/Repository/Field/MessageField.php index 13495f3e..6c40cf09 100644 --- a/src/Repository/Field/MessageField.php +++ b/src/Repository/Field/MessageField.php @@ -58,10 +58,6 @@ public function __construct($params = []) $this->message = $params['message']; - if (isset($params['type'])) { - $this->type = $params['type']; - } - if (isset($params['name'])) { $this->name = $params['name']; } @@ -76,34 +72,17 @@ public function __construct($params = []) */ public function field() { - return sprintf( - '', - esc_attr($this->type), - esc_attr($this->getName()), - esc_attr($this->getId()), - esc_attr($this->getValue()), - esc_attr($this->placeholder), - esc_attr($this->cssClass()), - $this->maybeDisable(), - esc_attr($this->atts) - ); + return wp_kses_post(is_callable($this->message) ? $this->message() : $this->message); } /** * Sanitizes the value sent by user * * @param mixed $value value to sanitize. - * @return mixed sanitized value + * @return null */ public function sanitize($value) { - $value = preg_replace( - '@<(script|style)[^>]*?>.*?@si', - '', - $value - ); // Remove script and style tags. - - $value = trim($value); // Remove whitespace. - return $value; + return null; } } From fa10b481416fb2b9449a440d488d77f75914b6c2 Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Wed, 26 Jun 2024 17:08:52 +0200 Subject: [PATCH 04/11] feat: display webhook deprecation messages --- .../Defaults/Carrier/Webhook.php | 20 ++++++++ .../Defaults/Carrier/WebhookJson.php | 20 ++++++++ .../css/src/partials/_carriers-widget.scss | 9 ++++ .../templates/notice/webhook-deprecated.php | 50 +++++++++++++++++++ src/Compat/WebhookCompat.php | 29 ++++++++++- 5 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 resources/templates/notice/webhook-deprecated.php diff --git a/compat/src-deprecated/Defaults/Carrier/Webhook.php b/compat/src-deprecated/Defaults/Carrier/Webhook.php index 310d0383..dcf9f765 100644 --- a/compat/src-deprecated/Defaults/Carrier/Webhook.php +++ b/compat/src-deprecated/Defaults/Carrier/Webhook.php @@ -40,6 +40,26 @@ class Webhook extends BaseCarrier */ public function formFields() { + $this->addFormField( + new Field\MessageField( + [ + 'name' => 'deprecated', + 'label' => __('Deprecated', 'notification'), + 'type' => 'error', + 'message' => + '

' . __("This carrier doesn't work since Notification v9.", 'notification') . '

' . + '' . + esc_html__('Get Notification : Webhooks extension', 'notification') . + '', + ] + ) + ); + $this->addRecipientsField( [ 'label' => __('URLs', 'notification'), diff --git a/compat/src-deprecated/Defaults/Carrier/WebhookJson.php b/compat/src-deprecated/Defaults/Carrier/WebhookJson.php index e60db714..bf0faef4 100644 --- a/compat/src-deprecated/Defaults/Carrier/WebhookJson.php +++ b/compat/src-deprecated/Defaults/Carrier/WebhookJson.php @@ -40,6 +40,26 @@ class WebhookJson extends BaseCarrier */ public function formFields() { + $this->addFormField( + new Field\MessageField( + [ + 'name' => 'deprecated', + 'label' => __('Deprecated', 'notification'), + 'type' => 'error', + 'message' => + '

' . __("This carrier doesn't work since Notification v9.", 'notification') . '

' . + '' . + esc_html__('Get Notification : Webhooks extension', 'notification') . + '', + ] + ) + ); + $this->addRecipientsField( [ 'label' => __('URLs', 'notification'), diff --git a/resources/css/src/partials/_carriers-widget.scss b/resources/css/src/partials/_carriers-widget.scss index 69c79ff6..b8f15e45 100644 --- a/resources/css/src/partials/_carriers-widget.scss +++ b/resources/css/src/partials/_carriers-widget.scss @@ -261,3 +261,12 @@ text-align: center; } } + +// Deprecated Webhooks +#notification-carrier-webhook-box, +#notification-carrier-webhook_json-box { + .deprecated td { + background-color: #fcf0f1; + border-radius: 5px; + } +} diff --git a/resources/templates/notice/webhook-deprecated.php b/resources/templates/notice/webhook-deprecated.php new file mode 100644 index 00000000..78c16241 --- /dev/null +++ b/resources/templates/notice/webhook-deprecated.php @@ -0,0 +1,50 @@ + +
+

+

+ +
+ +

+

+ + + + or + + + +

+
diff --git a/src/Compat/WebhookCompat.php b/src/Compat/WebhookCompat.php index 7e3122f7..4d0b3083 100644 --- a/src/Compat/WebhookCompat.php +++ b/src/Compat/WebhookCompat.php @@ -9,6 +9,11 @@ namespace BracketSpace\Notification\Compat; +use BracketSpace\Notification\Core\Templates; +use BracketSpace\Notification\Database\DatabaseService; +use BracketSpace\Notification\Database\NotificationDatabaseService; +use BracketSpace\Notification\Store\Carrier; + /** * WebhookCompat class * @@ -21,8 +26,30 @@ class WebhookCompat * * @return bool */ - public function hasWebhookCarriers(): bool + public static function hasDeprecatedWebhookCarriers(): bool + { + return (bool)DatabaseService::db()->get_var( + DatabaseService::db()->prepare( + "SELECT COUNT(*) FROM %i WHERE slug IN ('webhook', 'webhook_json')", + NotificationDatabaseService::getNotificationCarriersTableName() + ) + ); + } + + /** + * Displays a notice message when someone is + * using the deprecated webhooks. + * + * @action admin_notices + * + * @return void + */ + public function displayNotice() { + if (! self::hasDeprecatedWebhookCarriers()) { + return; + } + Templates::render('notice/webhook-deprecated'); } } From 327bb3c32ba37c0806215d78bb3c56f6d6a24476 Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Wed, 26 Jun 2024 17:09:02 +0200 Subject: [PATCH 05/11] test: rebuild baseline --- phpstan-baseline.neon | 77 +++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 46 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index f3f8b699..f3ea326b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -455,6 +455,36 @@ parameters: count: 1 path: compat/src-deprecated/Database/Queries/NotificationQueries.php + - + message: "#^Cannot access offset 'hide' on mixed\\.$#" + count: 1 + path: compat/src-deprecated/Defaults/Carrier/Webhook.php + + - + message: "#^Cannot access offset 'key' on mixed\\.$#" + count: 1 + path: compat/src-deprecated/Defaults/Carrier/Webhook.php + + - + message: "#^Cannot access offset 'value' on mixed\\.$#" + count: 1 + path: compat/src-deprecated/Defaults/Carrier/Webhook.php + + - + message: "#^Cannot access offset 'hide' on mixed\\.$#" + count: 1 + path: compat/src-deprecated/Defaults/Carrier/WebhookJson.php + + - + message: "#^Cannot access offset 'key' on mixed\\.$#" + count: 1 + path: compat/src-deprecated/Defaults/Carrier/WebhookJson.php + + - + message: "#^Cannot access offset 'value' on mixed\\.$#" + count: 1 + path: compat/src-deprecated/Defaults/Carrier/WebhookJson.php + - message: "#^Method BracketSpace\\\\Notification\\\\Utils\\\\Interfaces\\\\Cacheable\\:\\:add\\(\\) has no return type specified\\.$#" count: 1 @@ -1085,46 +1115,6 @@ parameters: count: 1 path: src/Repository/Carrier/Email.php - - - message: "#^Cannot access offset 'hide' on mixed\\.$#" - count: 1 - path: src/Repository/Carrier/Webhook.php - - - - message: "#^Cannot access offset 'key' on mixed\\.$#" - count: 1 - path: src/Repository/Carrier/Webhook.php - - - - message: "#^Cannot access offset 'value' on mixed\\.$#" - count: 1 - path: src/Repository/Carrier/Webhook.php - - - - message: "#^Parameter \\#1 \\$args of method BracketSpace\\\\Notification\\\\Repository\\\\Carrier\\\\Webhook\\:\\:parseArgs\\(\\) expects array, mixed given\\.$#" - count: 1 - path: src/Repository/Carrier/Webhook.php - - - - message: "#^Cannot access offset 'hide' on mixed\\.$#" - count: 1 - path: src/Repository/Carrier/WebhookJson.php - - - - message: "#^Cannot access offset 'key' on mixed\\.$#" - count: 1 - path: src/Repository/Carrier/WebhookJson.php - - - - message: "#^Cannot access offset 'value' on mixed\\.$#" - count: 1 - path: src/Repository/Carrier/WebhookJson.php - - - - message: "#^Parameter \\#1 \\$args of method BracketSpace\\\\Notification\\\\Repository\\\\Carrier\\\\WebhookJson\\:\\:parseArgs\\(\\) expects array, mixed given\\.$#" - count: 1 - path: src/Repository/Carrier/WebhookJson.php - - message: "#^Parameter \\#1 \\$carrier of static method BracketSpace\\\\Notification\\\\Register\\:\\:carrier\\(\\) expects BracketSpace\\\\Notification\\\\Interfaces\\\\Sendable, mixed given\\.$#" count: 3 @@ -1231,12 +1221,7 @@ parameters: path: src/Repository/Field/InputField.php - - message: "#^Parameter \\#1 \\$text of function esc_attr expects string, mixed given\\.$#" - count: 1 - path: src/Repository/Field/MessageField.php - - - - message: "#^Parameter \\#3 \\$subject of function preg_replace expects array\\|string, mixed given\\.$#" + message: "#^Call to an undefined method BracketSpace\\\\Notification\\\\Repository\\\\Field\\\\MessageField\\:\\:message\\(\\)\\.$#" count: 1 path: src/Repository/Field/MessageField.php From da5d375f97f5cc527e6003ee862c3f216c41344c Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Wed, 26 Jun 2024 17:18:00 +0200 Subject: [PATCH 06/11] doc: changelog --- readme.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/readme.txt b/readme.txt index b4ff1d53..dc9f9490 100644 --- a/readme.txt +++ b/readme.txt @@ -306,6 +306,7 @@ Yes! We're offering a [custom plugin development](https://bracketspace.com/custo **Compatibility Breaking Changes** +- Webook and Webhook JSON Carriers are now deprecated and won't work. [Read more about that change](https://docs.bracketspace.com/notification/extensions/webhooks) - Notifications are now saved into the custom table instead of relying on wp_posts. - Class methods and properties has been changed from snake_case to camelCase. - In Post Triggers, dynamic property `$trigger->{$post_type}` has been replaced with static prop `$trigger->post`. @@ -382,6 +383,7 @@ Removed deprecated hooks: * [Fixed] User password reset link requires encoded username. * [Removed] DOING_NOTIFICATION_SAVE constant. * [Removed] NotificationQueries class in favor of NotificationDatabaseService. +* [Removed] Webook and Webhook JSON Carriers. == Upgrade Notice == @@ -389,6 +391,7 @@ Removed deprecated hooks: Minimum required PHP version is 7.4. Compatibility breaking changes. Please make sure to review the changelog before upgrading and adjust your customizations. The premium plugins won't work with Notification [Next] unless updated. +Webook and Webhook JSON Carriers are now deprecated and won't work unless you get an add-on. = 8.0.0 = Compatibility breaking changes and security fixes. Please make sure to review the changelog before upgrading and adjust your customizations. From 462093ec30f76bbbaf36ae32c3e2e494641f0db3 Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Wed, 26 Jun 2024 17:35:55 +0200 Subject: [PATCH 07/11] refactor: move rest api checking class to compat namespace --- compat/component-aliases.php | 3 ++- phpstan-baseline.neon | 10 +++++----- .../RestApiCompat.php} | 19 +++++++++++-------- src/Runtime.php | 2 +- tests/unit/Core/TestMain.php | 3 ++- 5 files changed, 21 insertions(+), 16 deletions(-) rename src/{Admin/CheckRestApi.php => Compat/RestApiCompat.php} (75%) diff --git a/compat/component-aliases.php b/compat/component-aliases.php index cb9bccec..be580f27 100644 --- a/compat/component-aliases.php +++ b/compat/component-aliases.php @@ -8,6 +8,7 @@ use BracketSpace\Notification\Admin; use BracketSpace\Notification\Api; use BracketSpace\Notification\Core; +use BracketSpace\Notification\Compat; use BracketSpace\Notification\Integration; return [ @@ -19,7 +20,7 @@ 'core_sync' => Core\Sync::class, 'core_binder' => Core\Binder::class, 'core_processor' => Core\Processor::class, - 'test_rest_api' => Admin\CheckRestApi::class, + 'test_rest_api' => Compat\RestApiCompat::class, 'admin_impexp' => Admin\ImportExport::class, 'admin_settings' => Admin\Settings::class, 'admin_duplicator' => Admin\NotificationDuplicator::class, diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index f3ea326b..b08324fd 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -565,11 +565,6 @@ parameters: count: 4 path: notification.php - - - message: "#^Cannot call method getEndpoint\\(\\) on mixed\\.$#" - count: 1 - path: src/Admin/CheckRestApi.php - - message: "#^Cannot call method removeLogs\\(\\) on mixed\\.$#" count: 1 @@ -930,6 +925,11 @@ parameters: count: 1 path: src/Api/Controller/SelectInputController.php + - + message: "#^Cannot call method getEndpoint\\(\\) on mixed\\.$#" + count: 1 + path: src/Compat/RestApiCompat.php + - message: "#^Parameter \\#1 \\$timestamp of function wp_unschedule_event expects int, int\\|false given\\.$#" count: 1 diff --git a/src/Admin/CheckRestApi.php b/src/Compat/RestApiCompat.php similarity index 75% rename from src/Admin/CheckRestApi.php rename to src/Compat/RestApiCompat.php index bcedb203..c6088f5d 100644 --- a/src/Admin/CheckRestApi.php +++ b/src/Compat/RestApiCompat.php @@ -1,28 +1,28 @@

%1$s

', - 'The Notification plugin requires enabled REST API endpoint:notification/v1/. - Please ensure your WP REST API works correctly.' + esc_html__( + "The Notification plugin requires enabled REST API endpoint: notification/v1/. + Please ensure your WP REST API works correctly and you're not blocking this endpoint from access.", + 'notification' + ) ); } } diff --git a/src/Runtime.php b/src/Runtime.php index f71c6d37..257b062b 100644 --- a/src/Runtime.php +++ b/src/Runtime.php @@ -251,7 +251,6 @@ public function singletons() $this->addComponent(new Core\Binder()); $this->addComponent(new Core\Processor()); - $this->addComponent(new Admin\CheckRestApi()); $this->addComponent(new Admin\ImportExport()); $this->addComponent(new Admin\Settings()); $this->addComponent(new Admin\NotificationDuplicator()); @@ -274,6 +273,7 @@ public function singletons() $this->addComponent(new Api\Api()); $this->addComponent(new Compat\WebhookCompat()); + $this->addComponent(new Compat\RestApiCompat()); } /** diff --git a/tests/unit/Core/TestMain.php b/tests/unit/Core/TestMain.php index 28888262..a4964754 100644 --- a/tests/unit/Core/TestMain.php +++ b/tests/unit/Core/TestMain.php @@ -52,7 +52,6 @@ public function test_boot() { 'BracketSpace\Notification\Core\Sync', 'BracketSpace\Notification\Core\Binder', 'BracketSpace\Notification\Core\Processor', - 'BracketSpace\Notification\Admin\CheckRestApi', 'BracketSpace\Notification\Admin\ImportExport', 'BracketSpace\Notification\Admin\Settings', 'BracketSpace\Notification\Admin\NotificationDuplicator', @@ -69,6 +68,8 @@ public function test_boot() { 'BracketSpace\Notification\Integration\WordPressEmails', 'BracketSpace\Notification\Integration\TwoFactor', 'BracketSpace\Notification\Api\Api', + 'BracketSpace\Notification\Compat\WebhookCompat', + 'BracketSpace\Notification\Compat\RestApiCompat', ]; foreach ($instances as $className) { From d0781992ce3fb5854c44036080a0a0608163bce7 Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Thu, 27 Jun 2024 10:45:58 +0200 Subject: [PATCH 08/11] chore: hide webhooks on the carrier list --- resources/css/src/partials/_carriers-widget.scss | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/resources/css/src/partials/_carriers-widget.scss b/resources/css/src/partials/_carriers-widget.scss index b8f15e45..1ff60e46 100644 --- a/resources/css/src/partials/_carriers-widget.scss +++ b/resources/css/src/partials/_carriers-widget.scss @@ -270,3 +270,10 @@ border-radius: 5px; } } + +.notification-carriers__carriers { + li[data-nt-button="webhook"], + li[data-nt-button="webhook_json"] { + display: none; + } +} From 9f54cec0f5a64df04c253912d7e32718b3221820 Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Thu, 27 Jun 2024 10:47:22 +0200 Subject: [PATCH 09/11] fix: css lint issue --- resources/css/src/partials/_carriers-widget.scss | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/resources/css/src/partials/_carriers-widget.scss b/resources/css/src/partials/_carriers-widget.scss index 1ff60e46..e2d2d636 100644 --- a/resources/css/src/partials/_carriers-widget.scss +++ b/resources/css/src/partials/_carriers-widget.scss @@ -43,6 +43,12 @@ flex-wrap: wrap; justify-content: center; margin: -10px; + + // Deprecated webhooks. + li[data-nt-button="webhook"], + li[data-nt-button="webhook_json"] { + display: none; + } } &__carrier { @@ -270,10 +276,3 @@ border-radius: 5px; } } - -.notification-carriers__carriers { - li[data-nt-button="webhook"], - li[data-nt-button="webhook_json"] { - display: none; - } -} From 0363cf08157006c04f487cc3eb00ce3ce74df249 Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Thu, 27 Jun 2024 11:06:07 +0200 Subject: [PATCH 10/11] fix: phpstan issues and upgrade phpstan --- composer.json | 2 +- composer.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index ab0a3711..05aebd75 100644 --- a/composer.json +++ b/composer.json @@ -60,7 +60,7 @@ "strauss": { "namespace_prefix": "BracketSpace\\Notification\\Dependencies\\", "target_directory": "dependencies", - "classmap_prefix": "BRSET_" + "classmap_prefix": "" } }, "scripts": { diff --git a/composer.lock b/composer.lock index 9b56c2b1..bfdd46d4 100644 --- a/composer.lock +++ b/composer.lock @@ -4761,16 +4761,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.67", + "version": "1.11.5", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493" + "reference": "490f0ae1c92b082f154681d7849aee776a7c1443" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/16ddbe776f10da6a95ebd25de7c1dbed397dc493", - "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/490f0ae1c92b082f154681d7849aee776a7c1443", + "reference": "490f0ae1c92b082f154681d7849aee776a7c1443", "shasum": "" }, "require": { @@ -4815,7 +4815,7 @@ "type": "github" } ], - "time": "2024-04-16T07:22:02+00:00" + "time": "2024-06-17T15:10:54+00:00" }, { "name": "phpunit/php-code-coverage", From f5858eab5c92f9b3db8f2bbc52e5f0e8ef86eef2 Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Thu, 27 Jun 2024 13:21:51 +0200 Subject: [PATCH 11/11] chore: update phpstan baseline --- phpstan-baseline.neon | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b08324fd..49cbece4 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -676,7 +676,7 @@ parameters: path: src/Admin/ImportExport.php - - message: "#^Parameter \\#2 \\$length of function fread expects int\\<0, max\\>, int\\<0, max\\>\\|false given\\.$#" + message: "#^Parameter \\#2 \\$length of function fread expects int\\<1, max\\>, int\\<0, max\\>\\|false given\\.$#" count: 1 path: src/Admin/ImportExport.php @@ -1050,6 +1050,11 @@ parameters: count: 1 path: src/Core/Upgrade.php + - + message: "#^Cannot access offset mixed on mixed\\.$#" + count: 2 + path: src/Database/NotificationDatabaseService.php + - message: "#^Method BracketSpace\\\\Notification\\\\Database\\\\Queries\\\\UserQueries\\:\\:all\\(\\) should return array\\ but returns mixed\\.$#" count: 1