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

M 2.4.0 upgrading issue - Unable to apply patch Magento\Review\Setup\Patch\Schema\AddUniqueConstraintToReviewEntitySummary #29352

Closed
jesperbrejning opened this issue Jul 31, 2020 · 7 comments
Labels
Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Reported on 2.3.5 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S0 A problem that is blocking the ability to work. An immediate fix is needed.

Comments

@jesperbrejning
Copy link

jesperbrejning commented Jul 31, 2020

Preconditions

Install Magento 2.3.5 CE using composer

Steps to reproduce

  1. Run SQL command
INSERT INTO review*entity*summary 
(`entity*pk_value`, `entity_type`, `reviews_count`, `rating_summary`, `store*id`) 
VALUES (1, 1, 1, 1, 1),(1, 1, 1, 2, 1);
{code}
1. Follow a general upgrade flow <https://devdocs.magento.com/guides/v2.4/comp-mgr/cli/cli-upgrade.html] and upgrade to 2.4.0

(<ins>) Upgrade completed successfully
 (-)
{code:bash}
Unable to apply patch Magento\Review\Setup\Patch\Schema\AddUniqueConstraintToReviewEntitySummary for module Magento*Review. Original exception message: Warning: preg*match(): Compilation failed: invalid range in character class at offset 40 in /Users/max/srv/composer/m2ee.composer/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php on line 2779
{code}
**Overview**:

When upgrading from 2.3.5 to 2.4.0 and running **php bin/magento setup:upgrade**, the following error appears:

*Unable to apply patch Magento\Review\Setup\Patch\Schema\AddUniqueConstraintToReviewEntitySummary for module Magento_Review. Original exception message: Warning: preg_match(): Compilation failed: invalid range in character class at offset 40 in /home/babygear/www/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php on line 2779*

This issue is caused by a regular expression used in Magento code, which is not compatible with PHP 7.3 and PHP 7.4 


{code:bash}
#SQLSTATE\[23000\]: [<sup>:]</ins>: 1062[</sup>\']<ins>\'([\d-\.]</ins>)\'#

 

Please find more details here [https://github.com//issues/29352>

 

@m2-assistant
Copy link

m2-assistant bot commented Jul 31, 2020

Hi @jesperbrejning. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

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

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

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

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ 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, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

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

@magento-engcom-team magento-engcom-team added the Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed label Jul 31, 2020
@ghost ghost added this to Ready for QA in Community Backlog Jul 31, 2020
@hostep
Copy link
Contributor

hostep commented Aug 1, 2020

Hmm, that's interesting, the regex you refer to is #SQLSTATE\[23000\]: [^:]+: 1062[^\']+\'([\d-\.]+)\'#

I think you have a point here, the problem is inside the [\d-\.] character class, the range character - is considered a true range character because it wasn't specified as the last character in the group, so the solution is most likely to change the regex from:

#SQLSTATE\[23000\]: [^:]+: 1062[^\']+\'([\d-\.]+)\'#

to:

#SQLSTATE\[23000\]: [^:]+: 1062[^\']+\'([\d\-\.]+)\'#

or:

#SQLSTATE\[23000\]: [^:]+: 1062[^\']+\'([\d\.-]+)\'#

Could you test both these suggested regexes and let me know which ones fixes your issue?

For completeness sake, can you specify the PHP version and the version of the pcre library you are using.
You can find these on the command line using:

php --version
php -i | grep PCRE

Thanks!

@hostep
Copy link
Contributor

hostep commented Aug 1, 2020

I can very easily reproduce the problem using PHP 7.3 and 7.4 (it works on PHP 7.2) with:

$ php -r "preg_match('#SQLSTATE\[23000\]: [^:]+: 1062[^\']+\'([\d-\.]+)\'#', 'whatever');"
PHP Warning:  preg_match(): Compilation failed: invalid range in character class at offset 40 in Command line code on line 1

Warning: preg_match(): Compilation failed: invalid range in character class at offset 40 in Command line code on line 1

I'm using:

PCRE Library Version => 10.35 2020-05-09
PCRE Unicode Version => 13.0.0

This most likely happens because PHP 7.3 and 7.4 upgraded from the pcre library version 1 to version 2 and the last one is probably more stricter: https://php.watch/versions/7.3#pcre2

Thanks for the bug report, it's truly an important bug and hopefully somebody will fix this shortly (and search the entire codebase for other possible variants of this bug and also fix those)

@martysmojo
Copy link

Can confirm I see this bug with a 2.4. upgrade

$ php -i | grep PCRE PCRE (Perl Compatible Regular Expressions) Support => enabled PCRE Library Version => 10.32 2018-09-10 PCRE Unicode Version => 11.0.0 PCRE JIT Support => enabled PCRE JIT Target => x86 64bit (little endian + unaligned)

$ php --version PHP 7.3.20 (cli) (built: Jul 22 2020 09:57:21) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.20, Copyright (c) 1998-2018 Zend Technologies with the ionCube PHP Loader + ionCube24 v10.4.1, Copyright (c) 2002-2020, by ionCube Ltd. with SourceGuardian v11.4.1, Copyright (c) 2000-2020, by SourceGuardian Ltd. with Zend OPcache v7.3.20, Copyright (c) 1999-2018, by Zend Technologies

@martysmojo
Copy link

To amend my other comment, I couldn't replicate this using vanilla Magento installs from 2.3.4 to 2.4.0 (the above case was 2.3.4 to 2.4.0) so its not clear why its failing to update in our case.

@ghost ghost moved this from Ready for QA to Ready for Dev in Community Backlog Aug 3, 2020
@magento-engcom-team magento-engcom-team added the Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release label Aug 3, 2020
@fascinosum
Copy link
Contributor

Hello @jesperbrejning, @hostep, @martysmojo
thank you for your contribution. An internal ticket has been created to track this issue MC-36428
@martysmojo this issue can be reproduced using a specific data set

@fascinosum fascinosum added the Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch label Aug 3, 2020
@magento-engcom-team magento-engcom-team added Severity: S0 A problem that is blocking the ability to work. An immediate fix is needed. Progress: dev in progress and removed Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Progress: ready for dev labels Aug 3, 2020
@ghost ghost moved this from Ready for Dev to Dev in Progress in Community Backlog Aug 3, 2020
@magento-engcom-team magento-engcom-team added Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done and removed Progress: dev in progress labels Aug 4, 2020
@ghost ghost moved this from Dev in Progress to Done (last 30 days) in Community Backlog Aug 6, 2020
@magento-engcom-team magento-engcom-team added the Fixed in 2.4.x The issue has been fixed in 2.4-develop branch label Aug 11, 2020
@magento-engcom-team
Copy link
Contributor

Hi @jesperbrejning.

Thank you for your report and collaboration!

The issue was fixed by Magento team. The fix was delivered into magento/magento2:2.4-develop branch(es).
Related commit(s):

The fix will be available with the upcoming 2.4.1 release.

@magento-engcom-team magento-engcom-team added the Reported on 2.3.5 Indicates original Magento version for the Issue report. label Nov 13, 2020
@m2-community-project m2-community-project bot removed this from Done (last 30 days) in Community Backlog Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Reported on 2.3.5 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S0 A problem that is blocking the ability to work. An immediate fix is needed.
Projects
Development

No branches or pull requests

5 participants