From f23df0b91c6c2014028c7911f81682394f829fd9 Mon Sep 17 00:00:00 2001 From: Alex P Date: Tue, 16 Nov 2021 16:09:02 +0200 Subject: [PATCH] Make sanitize_custom_id more correct --- modules/ppcp-webhooks/src/Handler/PrefixTrait.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/ppcp-webhooks/src/Handler/PrefixTrait.php b/modules/ppcp-webhooks/src/Handler/PrefixTrait.php index db65f224b..bc92d9e36 100644 --- a/modules/ppcp-webhooks/src/Handler/PrefixTrait.php +++ b/modules/ppcp-webhooks/src/Handler/PrefixTrait.php @@ -31,7 +31,10 @@ trait PrefixTrait { */ private function sanitize_custom_id( string $custom_id ): int { - $id = str_replace( $this->prefix, '', $custom_id ); + $id = $custom_id; + if ( strlen( $this->prefix ) > 0 && 0 === strpos( $id, $this->prefix ) ) { + $id = substr( $id, strlen( $this->prefix ) ); + } return (int) $id; } }