Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Deprecated Functionality plugin magento zendframework1 #36069

Closed
1 of 5 tasks
mohammedTBB opened this issue Sep 1, 2022 · 19 comments
Closed
1 of 5 tasks

Error Deprecated Functionality plugin magento zendframework1 #36069

mohammedTBB opened this issue Sep 1, 2022 · 19 comments
Labels
Area: Framework Component: DB Issue: needs update Additional information is require, waiting for response Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.4.5 Indicates original Magento version for the Issue report. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@mohammedTBB
Copy link

mohammedTBB commented Sep 1, 2022

Preconditions and environment

  • Magento v2.4.5
  • php v8.1

Steps to reproduce

1- Go to category page
2- Choose a product and go to product page (not all products)

Expected result

No error

Actual result

Exception #0 (Exception): Deprecated Functionality: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /vendor/magento/zendframework1/library/Zend/Db/Statement.php on line 222

#1 call_user_func_array() called at [app/code/Anowave/Ec/vendor/FacebookAds/CrashReporter.php:154]
#2 Anowave\Ec\vendor\FacebookAds\CrashReporter->Anowave\Ec\vendor\FacebookAds\{closure}()
#3 preg_replace() called at [vendor/magento/zendframework1/library/Zend/Db/Statement.php:222]
#4 Zend_Db_Statement->_stripQuoted() called at [vendor/magento/zendframework1/library/Zend/Db/Statement.php:139]
#5 Zend_Db_Statement->_parseParameters() called at [vendor/magento/zendframework1/library/Zend/Db/Statement.php:114]
#6 Zend_Db_Statement->__construct() called at [vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:184]
#7 Zend_Db_Adapter_Pdo_Abstract->prepare() called at [vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php:479]
#8 Zend_Db_Adapter_Abstract->query() called at [vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:238]
#9 Zend_Db_Adapter_Pdo_Abstract->query() called at [vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:564]
#10 Magento\Framework\DB\Adapter\Pdo\Mysql->_query() called at [vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:634]
#11 Magento\Framework\DB\Adapter\Pdo\Mysql->query() called at [vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php:737]
#12 Zend_Db_Adapter_Abstract->fetchAll() called at [vendor/magento/framework/Data/Collection/Db/FetchStrategy/Query.php:21]
#13 Magento\Framework\Data\Collection\Db\FetchStrategy\Query->fetchAll() called at [vendor/magento/framework/Data/Collection/AbstractDb.php:782]
#14 Magento\Framework\Data\Collection\AbstractDb->_fetchAll() called at [vendor/magento/framework/Data/Collection/AbstractDb.php:677]
#15 Magento\Framework\Data\Collection\AbstractDb->getData() called at [vendor/magento/framework/Data/Collection/AbstractDb.php:580]
#16 Magento\Framework\Data\Collection\AbstractDb->loadWithFilter() called at [vendor/magento/framework/Data/Collection/AbstractDb.php:565]
#17 Magento\Framework\Data\Collection\AbstractDb->load() called at [vendor/magento/module-eav/Model/Entity/Attribute/Source/Table.php:123]
#18 Magento\Eav\Model\Entity\Attribute\Source\Table->getSpecificOptions() called at [vendor/magento/module-eav/Model/Entity/Attribute/Source/Table.php:157]
#19 Magento\Eav\Model\Entity\Attribute\Source\Table->getOptionText() called at [vendor/magento/module-catalog/Model/Product.php:1807]
#20 Magento\Catalog\Model\Product->getAttributeText() called at [vendor/amasty/module-google-rich-snippets/Block/Product.php:427]
#21 Amasty\SeoRichData\Block\Product->updateCustomProperties() called at [vendor/amasty/module-google-rich-snippets/Block/Product.php:327]
#22 Amasty\SeoRichData\Block\Product->generateOffers() called at [vendor/amasty/module-google-rich-snippets/Block/Product.php:210]
#23 Amasty\SeoRichData\Block\Product->prepareOffers() called at [vendor/amasty/module-google-rich-snippets/Block/Product.php:150]
#24 Amasty\SeoRichData\Block\Product->getResultArray() called at [vendor/amasty/module-google-rich-snippets/Block/Product.php:133]
#25 Amasty\SeoRichData\Block\Product->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1095]
#26 Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1099]
#27 Magento\Framework\View\Element\AbstractBlock->_loadCache() called at [vendor/magento/framework/View/Element/AbstractBlock.php:660]
#28 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [vendor/magento/framework/View/Layout.php:578]
#29 Magento\Framework\View\Layout->_renderBlock() called at [vendor/magento/framework/View/Layout.php:555]
#30 Magento\Framework\View\Layout->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#31 Magento\Framework\View\Layout->renderElement() called at [vendor/magento/framework/View/Layout.php:606]
#32 Magento\Framework\View\Layout->_renderContainer() called at [vendor/magento/framework/View/Layout.php:557]
#33 Magento\Framework\View\Layout->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#34 Magento\Framework\View\Layout->renderElement() called at [vendor/magento/framework/View/Layout.php:606]
#35 Magento\Framework\View\Layout->_renderContainer() called at [vendor/magento/framework/View/Layout.php:557]
#36 Magento\Framework\View\Layout->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#37 Magento\Framework\View\Layout->renderElement() called at [vendor/magento/framework/View/Layout.php:606]
#38 Magento\Framework\View\Layout->_renderContainer() called at [vendor/magento/framework/View/Layout.php:557]
#39 Magento\Framework\View\Layout->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#40 Magento\Framework\View\Layout->renderElement() called at [vendor/magento/framework/View/Layout.php:975]
#41 Magento\Framework\View\Layout->getOutput() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#42 Magento\Framework\View\Layout\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#43 Magento\Framework\View\Layout\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#44 Magento\Framework\View\Layout\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:41]
#45 Magento\Framework\View\Layout\Interceptor->getOutput() called at [vendor/magento/framework/View/Result/Page.php:260]
#46 Magento\Framework\View\Result\Page->render() called at [vendor/magento/framework/View/Result/Layout.php:171]
#47 Magento\Framework\View\Result\Layout->renderResult() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#48 Magento\Framework\View\Result\Page\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#49 Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#50 Magento\Framework\View\Result\Page\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Result/Page/Interceptor.php:32]
#51 Magento\Framework\View\Result\Page\Interceptor->renderResult() called at [vendor/magento/framework/App/Http.php:120]
#52 Magento\Framework\App\Http->launch() called at [vendor/magento/framework/App/Bootstrap.php:264]
#53 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:30]

Additional information

Possible solution:

diff --git a/vendor/magento/zendframework1/library/Zend/Db/Statement.php b/vendor/magento/zendframework1/library/Zend/Db/Statement.php
index 46d175c..60c77a9 100644
--- a/vendor/magento/zendframework1/library/Zend/Db/Statement.php
+++ b/vendor/magento/zendframework1/library/Zend/Db/Statement.php
@@ -209,6 +209,10 @@ abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface
         // remove "foo\"bar"
         $sql = preg_replace("/\"(\\\\\"|[^\"])*\"/Us", '', $sql);
 
+        if ($sql === null) {
+            return '';
+        }
+
         // get the character for delimited id quotes,
         // this is usually " but in MySQL is `
         $d = $this->_adapter->quoteIdentifier('a');

Need to add this check after each preg_replace call i.e. 210 & 222.
The simplest way to reproduce this issue is by setting $sql as null and then running bin/magento setup:upgrade command. The below error will occur:
image

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@m2-assistant
Copy link

m2-assistant bot commented Sep 1, 2022

Hi @mohammedTBB. Thank you for your report.
To speed up processing of this issue, make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-assistant
Copy link

m2-assistant bot commented Sep 1, 2022

Hi @engcom-Dash. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

    1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
      DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
    1. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.
    1. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
    1. Verify that the issue is reproducible on 2.4-develop branch
      Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
      - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
      - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

@engcom-Dash engcom-Dash added the Reported on 2.4.5 Indicates original Magento version for the Issue report. label Sep 1, 2022
@engcom-Dash
Copy link
Contributor

Hi @mohammedTBB ,

We are trying to reproduce the issue in 2.4.5 magento instance....But we are not able to reproduce the issue.
We are getting expected result and it is not reproducible.

Steps:
1.install 2.4.5 magento instance
2.Go to category page
3.Select the product
4.got to product page
5.No error occurring

Let us know if we missing anything!

Thanks!!!

@engcom-Dash engcom-Dash added the Issue: needs update Additional information is require, waiting for response label Sep 1, 2022
@n2diving-dgx
Copy link

n2diving-dgx commented Sep 1, 2022

Maybe the Anowave E-commerce 3rd party package script (i.e. CrashReporter.php) detects an issue that triggers a call to Zend/DbStatement.php... which in turn then executes the deprecated functionality in M2 zendframework? Perhaps wouldn't be reproduceable unless Anowave EC extension tries to report the "crash". We've had a several of that kind of circumstance in debugging php8.1 compatibility issues in 3rd party extensions: fix the first bit of deprecated code, test and that reveals a new one downstream... rinse and repeat.

image

@sdzhepa sdzhepa added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Sep 1, 2022
@engcom-Dash engcom-Dash removed their assignment Sep 5, 2022
@engcom-Hotel engcom-Hotel self-assigned this Sep 5, 2022
@m2-assistant
Copy link

m2-assistant bot commented Sep 5, 2022

Hi @engcom-Hotel. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Hotel
Copy link
Contributor

Hello @mohammedTBB,

Thanks for the report and collaboration!

We have checked this issue in the Magento 2.4.5, 2.4.4, and 2.4-develop branches. And also examine the file vendor/magento/zendframework1/library/Zend/Db/Statement.php and found that the suggested possible fix as below:

if ($sql === null) {
           return '';
}

is already there in line no. 201.

https://github.com/magento/zf1/blob/2381396d2a9a528be2f367b5ce2dddf650eac1d0/library/Zend/Db/Statement.php#L201

Hello @n2diving-dgx,

Can you please suggest a way to reproduce the issue? Does we need to install the Anowave E-commerce, and the try to throw an issue. Please suggest.

Thanks

@hostep
Copy link
Contributor

hostep commented Sep 5, 2022

@engcom-Hotel: if you read the error message carefully, you'll see that the error happens on line 222.
Which means that the check on line 201 already passed.

So this most likely means that the second preg_replace call failed, which would explain why the $sql value changes to null.

Also, we have a third preg_replace call, which could potentially also fail, so maybe that one needs to be checked as well?

@mohammedTBB
Copy link
Author

Hello @engcom-Hotel

yes there is check in line 201 but then the value of $sql changed.

what worked for us is adding the check at line 222

image

to reproduce the error it is essential to have the plugin amasty google rich snippets,
knowing that disabling this plugin the error is no longer showing.

what seems to happen that the plugin amasty google rich snippets calls a zendfremwork funcion where the error happen.

@engcom-Hotel
Copy link
Contributor

engcom-Hotel commented Sep 6, 2022

Hello @hostep @mohammedTBB,

Thanks for the reply!

I agree with your point @hostep, we need to add the checks after each preg_replace call here ie. line numbers i.e. 210 & 222.

I have also gone through the preg_replace documentation, it can be returned as null, in case of error occurred.

Hence confirming the issue.

Thanks

@engcom-Hotel engcom-Hotel added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Area: Framework labels Sep 6, 2022
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-6632 is successfully created for this GitHub issue.

@m2-assistant
Copy link

m2-assistant bot commented Sep 6, 2022

✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@sdzhepa sdzhepa removed the Issue: needs update Additional information is require, waiting for response label Sep 6, 2022
@Aquive
Copy link

Aquive commented Nov 25, 2022

@mohammedTBB @hostep @n2diving-dgx does anyone of you know how to reproduce this issue? From what I can read, it does not always occur? I have the same situation for a client.

@hostep
Copy link
Contributor

hostep commented Nov 25, 2022

@Aquive: try outputting/debugging what the $sql variable contains just before this and this line.
That might reveal why preg_replace runs into an error in your case.

Feel free to report back here, it will most likely make it easier to understand for the people involved here how it can happen.

@Aquive
Copy link

Aquive commented Dec 2, 2022

@hostep the error sometimes occurs on production. But the problem for me is that I don't know how to reproduce this locally.

Any ideas?

@hostep
Copy link
Contributor

hostep commented Jan 2, 2023

The only thing I can think of, is to patch the code on production with some extra lines that try to detect this occurrence and add a bunch of logging to try to see what the $sql variable contains just before it turns into null...
And then hope that after a few days you'll find something interesting in your log files which can then hopefully explain what's going on.

@joshbourke
Copy link

joshbourke commented Jan 18, 2023

I stumbled across this recently. If you go to the Customer Grid in the admin and search:
':{}{}{":]a''a'a':{}{}{"a:]{":a'a':{}{}{":]a'']a''a'a':{}{}:]{":a'a':{}{}{":]a'']a''a'a':{}{}:]{":a'a':{}{}{":]a:]{":a'a':{}{}{":]a'']a''a'a':{}{}:]{":a'a':{}{:]{":a'a':{}{}{":]a'']a''a'a':{}{}:]{":a'a':]{":a'a':{}{}{":]a'']a''a'a':{}{}:]{"::]{":a'a':{}{}{":]a'']a''a'a':{}{}a'a':{}{}{":]a'']a''a'a':{}{}:{}{}{":]a'']a''a'a':{}{}}{":]a'']a''a'a':{}{}'']a''a'a':{}{}{"a:]a''a'a':{}':{}{}{":]a''a'a':{}{}{"a:]a''a'a':{}':{}{}{":]a''a'a':{}{}{"a:]a''a'a':{}':{}{}{":]a''a'a':{}{}{"a:]a''a'a':{}':{}{}{":]a''a'a':{}{}{"a:]a''a'a':{}':{}{}{":]a''a'a':{}{}{"a:]a''a'a':{}':{}{}{":]a''a'a':{}{}{"a:]a''a'a':{}':':

You create an exception that stems from the same problem.

Note that you may hit a server error if the request URI is too long. You may need to adjust server config.

You have to be in production mode or have error reporting off because of a check done here:
vendor/magento/framework/App/ErrorHandler.php:54

        $errorNo = $errorNo & error_reporting();
        if ($errorNo == 0) {
            return false;
        }

Exception:

[2023-01-18T19:42:07.045616+00:00] report.CRITICAL: Exception: Deprecated Functionality: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /chroot/home/website/html/vendor/magento/zendframework1/library/Zend/Db/Statement.php on line 222 in /chroot/home/website/html/vendor/magento/framework/App/ErrorHandler.php:62
Stack trace:
#0 [internal function]: Magento\Framework\App\ErrorHandler->handler(8192, 'preg_replace():...', '/chroot/home/mt...', 222)

@cptX
Copy link

cptX commented Mar 4, 2023

I hit the same issue but on a different case. I have magento 2.4.5.
When trying to rollback my database I got this:
Deprecated Functionality: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/xxxxxxx/vendor/magento/zendframework1/library/Zend/Db/Statement.php on line 222

This breaks the rollback of the database so I think is critical. At the moment I cannot restore my database!
Any suggestions?

@engcom-Hotel engcom-Hotel moved this to Ready for Development in High Priority Backlog Aug 19, 2024
@engcom-Hotel
Copy link
Contributor

Hello @mohammedTBB,

The issue is still relevant, tried the steps mentioned in this #36069 (comment), but it seems the issue does not belong to this repo.

It should be created in https://github.com/magento/magento-zend-db repo. After checking found a similar issue here in that repo:

magento/magento-zend-db#2

I think we can close this issue from here.

@engcom-Hotel engcom-Hotel added Issue: needs update Additional information is require, waiting for response Component: DB and removed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch labels Oct 9, 2024
@mohammedTBB
Copy link
Author

Hi @engcom-Hotel thanks for trying to reproduce the error and for this information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Framework Component: DB Issue: needs update Additional information is require, waiting for response Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.4.5 Indicates original Magento version for the Issue report. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Status: Ready for Development
Development

No branches or pull requests

10 participants