Description
An issue with a regular expression was found. Line:
https://github.com/magento/zf1/blob/master/library/Zend/Db/Statement.php#L198
Executed with some Sql queries it can return NULL, which means that the function had an error.
I reproduced the issue with a specific query from PageBuilder module (see Steps to reproduce section).
In this case the error was: PREG_BACKTRACK_LIMIT_ERROR - Backtrack limit exhausted
This problem is known as Catastrophic backtracking. (regex101) , most likely the pattern is not entirely correct.
To fix the related issue on PHP 8.1., which caused by the issue described, a temporary fix was introduced:
magento/zf1#42
However, it doesn't fix the issue itself. It only makes the method behaviour same as it was on PHP < 8.1.
Preconditions (*)
Reproducible on PHP 7.4, 8.0, 8.1
Steps to reproduce (*)
A possible way to reproduce the issue:
Execute \Magento\PageBuilder\Setup\Patch\Data\UpgradePageBuilderStripStyles
Data patch and set a debug point on a problematic line.
I run into the error with a query
SELECT MAX(block_id) as max, COUNT(*) as cnt FROM (SELECT `cms_block`.`block_id`, `cms_block`.`content` FROM `cms_block` WHERE (content IS NOT NULL) AND (content LIKE ('%data-content-type=\"%')) AND (`cms_block`.`block_id` > 0) ORDER BY `cms_block`.`block_id` ASC
LIMIT 50000) AS `t`
Function preg_last_error_msg
may be useful to check the preg_replace error, because preg_replace doesn't throw any warning or notice.
Expected result (*)
A correct execution of a preg_replace
function on the mentioned line with all queries. Pattern has to be fixed.
Actual result (*)
Some Sql queries will not be executed, existing code replaces them with an empty string because of preg_replace
error.