From ec1b7527e31c706bddda7cdd76febc27fddc05b5 Mon Sep 17 00:00:00 2001 From: Shady Sharaf Date: Mon, 20 Nov 2023 13:26:55 +0000 Subject: [PATCH 1/5] Fix dynamic callback method detection --- classes/class-connector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-connector.php b/classes/class-connector.php index 62142f0c4..ccedadf10 100644 --- a/classes/class-connector.php +++ b/classes/class-connector.php @@ -110,7 +110,7 @@ public function unregister() { */ public function callback() { $action = current_filter(); - $callback = array( $this, 'callback_' . preg_replace( '/[^a-z0-9_\-]/', '_', $action ) ); + $callback = array( $this, 'callback_' . preg_replace( '/[^a-z0-9_]/', '_', $action ) ); // For the sake of testing, trigger an action with the name of the callback. if ( defined( 'WP_STREAM_TESTS' ) && WP_STREAM_TESTS ) { From ef055c7ae7bdb97135dd5c3986ce5a7c7ae501f3 Mon Sep 17 00:00:00 2001 From: Shady Sharaf Date: Mon, 20 Nov 2023 14:21:52 +0000 Subject: [PATCH 2/5] Add unit tests --- tests/tests/test-class-connector.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/tests/test-class-connector.php b/tests/tests/test-class-connector.php index b631fb11d..a19fbf442 100644 --- a/tests/tests/test-class-connector.php +++ b/tests/tests/test-class-connector.php @@ -53,6 +53,17 @@ public function test_callback() { $this->assertGreaterThan( 0, did_action( $this->action_prefix . 'child_callback_' . $action ) ); } + public function test_callback_hyphenated() { + global $wp_current_filter; + $action = $this->connector->actions[1]; + $wp_current_filter[] = $action; + + $this->connector->callback(); + + $this->assertGreaterThan( 0, did_action( $this->action_prefix . 'callback_hyphenated_action' ) ); + $this->assertGreaterThan( 0, did_action( $this->action_prefix . 'child_callback_hyphenated_action' ) ); + } + public function test_action_links() { $current_links = array( 'IMDB' => '', @@ -194,6 +205,7 @@ class Connector_Maintenance extends Connector { */ public $actions = array( 'simulate_fault', + 'hyphenated-action' ); /** @@ -236,4 +248,15 @@ public function callback_simulate_fault() { // This is used to check if this callback method actually ran do_action( 'wp_stream_test_child_callback_simulate_fault' ); } + + /** + * Log the hyphenated action callback. + * + * @action hyphenated-action + * + * @return void + */ + public function callback_hyphenated_action() { + do_action( 'wp_stream_test_child_callback_hyphenated_action' ); + } } From c4e96822fab330c1cb8b15017a600a87ccee7305 Mon Sep 17 00:00:00 2001 From: Shady Sharaf Date: Mon, 20 Nov 2023 14:22:07 +0000 Subject: [PATCH 3/5] Bump version and changelog --- classes/class-plugin.php | 2 +- readme.txt | 6 +++++- stream.php | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/classes/class-plugin.php b/classes/class-plugin.php index 376e0a170..37cd68616 100755 --- a/classes/class-plugin.php +++ b/classes/class-plugin.php @@ -18,7 +18,7 @@ class Plugin { * * @const string */ - const VERSION = '3.10.0'; + const VERSION = '3.10.1'; /** * WP-CLI command diff --git a/readme.txt b/readme.txt index 41f4d145b..720137e1c 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: xwp Tags: wp stream, stream, activity, logs, track Requires at least: 4.5 Tested up to: 6.3 -Stable tag: 3.10.0 +Stable tag: 3.10.1 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -103,6 +103,10 @@ Track changes to posts when using the block editor. == Changelog == += 3.10.1 - October 9, 2023 = + +- Fix: Fixed the dynamic callback locating routine by removing the hyphen as a valid function name character. + = 3.10.0 - October 9, 2023 = - Fix: Improve PHP 8.1 compatibility by updating `filter_*()` calls referencing `FILTER_SANITIZE_STRING` (issue [#1422](https://github.com/xwp/stream/pull/1422)). diff --git a/stream.php b/stream.php index 46dbc44c1..446a8d117 100644 --- a/stream.php +++ b/stream.php @@ -3,7 +3,7 @@ * Plugin Name: Stream * Plugin URI: https://xwp.co/work/stream/ * Description: Stream tracks logged-in user activity so you can monitor every change made on your WordPress site in beautifully organized detail. All activity is organized by context, action and IP address for easy filtering. Developers can extend Stream with custom connectors to log any kind of action. - * Version: 3.10.0 + * Version: 3.10.1 * Author: XWP * Author URI: https://xwp.co * License: GPLv2+ From 6267d62fab80a3788bbd5f2e2cd1be8c0e823232 Mon Sep 17 00:00:00 2001 From: Piotr Delawski Date: Mon, 22 Jul 2024 13:19:12 +0200 Subject: [PATCH 4/5] Plugin version will be bumped in upcoming release --- classes/class-plugin.php | 2 +- readme.txt | 6 +----- stream.php | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/classes/class-plugin.php b/classes/class-plugin.php index 37cd68616..376e0a170 100755 --- a/classes/class-plugin.php +++ b/classes/class-plugin.php @@ -18,7 +18,7 @@ class Plugin { * * @const string */ - const VERSION = '3.10.1'; + const VERSION = '3.10.0'; /** * WP-CLI command diff --git a/readme.txt b/readme.txt index 720137e1c..41f4d145b 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: xwp Tags: wp stream, stream, activity, logs, track Requires at least: 4.5 Tested up to: 6.3 -Stable tag: 3.10.1 +Stable tag: 3.10.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -103,10 +103,6 @@ Track changes to posts when using the block editor. == Changelog == -= 3.10.1 - October 9, 2023 = - -- Fix: Fixed the dynamic callback locating routine by removing the hyphen as a valid function name character. - = 3.10.0 - October 9, 2023 = - Fix: Improve PHP 8.1 compatibility by updating `filter_*()` calls referencing `FILTER_SANITIZE_STRING` (issue [#1422](https://github.com/xwp/stream/pull/1422)). diff --git a/stream.php b/stream.php index 446a8d117..46dbc44c1 100644 --- a/stream.php +++ b/stream.php @@ -3,7 +3,7 @@ * Plugin Name: Stream * Plugin URI: https://xwp.co/work/stream/ * Description: Stream tracks logged-in user activity so you can monitor every change made on your WordPress site in beautifully organized detail. All activity is organized by context, action and IP address for easy filtering. Developers can extend Stream with custom connectors to log any kind of action. - * Version: 3.10.1 + * Version: 3.10.0 * Author: XWP * Author URI: https://xwp.co * License: GPLv2+ From d1bd6484c462de9370929c7cf129512ab3cd3e30 Mon Sep 17 00:00:00 2001 From: Piotr Delawski Date: Mon, 22 Jul 2024 13:28:50 +0200 Subject: [PATCH 5/5] Cleanup after resolving merge conflicts with `develop` --- tests/tests/test-class-connector.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/tests/tests/test-class-connector.php b/tests/tests/test-class-connector.php index 8601e9955..15df3b5f7 100644 --- a/tests/tests/test-class-connector.php +++ b/tests/tests/test-class-connector.php @@ -27,7 +27,7 @@ public function setUp(): void { */ public $actions = array( 'simulate_fault', - 'hyphenated-action', + 'hyphenated-action', ); /** @@ -71,16 +71,16 @@ public function callback_simulate_fault() { do_action( 'wp_stream_test_child_callback_simulate_fault' ); } - /** - * Log the hyphenated action callback. - * - * @action hyphenated-action - * - * @return void - */ - public function callback_hyphenated_action() { + /** + * Log the hyphenated action callback. + * + * @action hyphenated-action + * + * @return void + */ + public function callback_hyphenated_action() { do_action( 'wp_stream_test_child_callback_hyphenated_action' ); - } + } }; $this->assertNotEmpty( $this->connector ); @@ -259,7 +259,6 @@ public function test_is_dependency_satisfied() { $this->assertTrue( $this->connector->is_dependency_satisfied() ); } - /** * Test that percentages are escaped. *