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

Inconsistent escaping during database migration with MySQL #39491

Open
1 of 5 tasks
LouisdeLooze opened this issue Dec 17, 2024 · 7 comments
Open
1 of 5 tasks

Inconsistent escaping during database migration with MySQL #39491

LouisdeLooze opened this issue Dec 17, 2024 · 7 comments
Labels
Area: Framework Component: Framework/DB USE ONLY for FRAMEWORK RELATED BUG! Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reported on 2.4.7-p3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@LouisdeLooze
Copy link

LouisdeLooze commented Dec 17, 2024

Preconditions and environment

  • Clean Magento 2.4.7-p3
  • Reproducible on MySQL 8, cannot be reproduced on MariaDB 10.6

Steps to reproduce

  1. Make custom module with a declarative schema that contains a PHP class as default. For example:
<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <table name="test_module_db" resource="default" engine="innodb">
        <column xsi:type="varchar" name="model" nullable="true" default="Test\\Module\\Model\\Default" comment="Corresponding Model"/>
    </table>
</schema>
  1. Run setup:upgrade
  2. Run setup:db:status

Expected result

No database migrations needed, just ran the migrations.

Actual result

Migration is needed (breaking zero-downtime deployments for no reason), this is the difference:
from xml:

array(5) {
  ["type"]=>
  string(7) "varchar"
  ["nullable"]=>
  bool(true)
  ["default"]=>
  string(28) "Test\\Module\\Model\\Default"
  ["length"]=>
  int(255)
  ["comment"]=>
  string(19) "Corresponding Model"
}

from MySQL:

array(5) {
  ["type"]=>
  string(7) "varchar"
  ["nullable"]=>
  bool(true)
  ["default"]=>
  string(25) "Test\Module\Model\Default"
  ["length"]=>
  int(255)
  ["comment"]=>
  string(19) "Corresponding Model"
}

for reference, MariaDB:

array(5) {
  ["type"]=>
  string(7) "varchar"
  ["nullable"]=>
  bool(true)
  ["default"]=>
  string(25) "Test\\Module\\Model\\Default"
  ["length"]=>
  int(255)
  ["comment"]=>
  string(19) "Corresponding Model"
}

Additional information

No response

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”.
Copy link

m2-assistant bot commented Dec 17, 2024

Hi @LouisdeLooze. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce.


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ 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.

@github-project-automation github-project-automation bot moved this to Ready for Confirmation in Issue Confirmation and Triage Board Dec 17, 2024
@engcom-Bravo engcom-Bravo added Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it Reported on 2.4.7-p3 Indicates original Magento version for the Issue report. labels Dec 18, 2024
@engcom-Hotel engcom-Hotel self-assigned this Dec 18, 2024
Copy link

m2-assistant bot commented Dec 18, 2024

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).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- 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 @LouisdeLooze,

Thanks for the report and collaboration!

But we are unable to get the expected and actual result, request you to please elaborate on those.

Thanks

@engcom-Hotel engcom-Hotel moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Dec 18, 2024
@engcom-Hotel engcom-Hotel added Issue: needs update Additional information is require, waiting for response and removed Issue: ready for confirmation labels Dec 18, 2024
@LouisdeLooze
Copy link
Author

LouisdeLooze commented Dec 18, 2024

Hi @engcom-Hotel

Directly after running setup:upgrade, running setup:db:status will output (does not matter how many times DB upgrade command is ran):

Declarative Schema is not up to date
Run 'setup:upgrade' to update your DB schema and data.

The extra output from above is when debugging \Magento\Framework\Setup\Declaration\Schema\Comparator::compare.
I added the following before the return to show the differences between the sensitive parameters:

if (! (get_class($first) === get_class($second) &&
       $first->getDiffSensitiveParams() === $second->getDiffSensitiveParams())) {
       var_dump($first->getDiffSensitiveParams());
       var_dump($second->getDiffSensitiveParams());
}

And that shows the difference in escaping the backslashes, which makes the comparator think they are different. Resulting in a permanent state of the declarative schema being not up to date.

@engcom-Hotel
Copy link
Contributor

Hello @LouisdeLooze,

Thanks for the report and collaboration!

We have tried to reproduce the issue in the latest 2.4-develop branch and the issue has been reproducible for us. Please refer to the screenshot below for reference:

image

The below module has been created by us to reproduce the issue:
Issue39491.zip

Hence confirming the issue.

Thanks

@engcom-Hotel engcom-Hotel added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Component: Framework/DB USE ONLY for FRAMEWORK RELATED BUG! 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 and removed Issue: needs update Additional information is require, waiting for response labels Dec 19, 2024
@github-jira-sync-bot
Copy link

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

Copy link

m2-assistant bot commented Dec 19, 2024

✅ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Framework Component: Framework/DB USE ONLY for FRAMEWORK RELATED BUG! Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reported on 2.4.7-p3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
None yet
Development

No branches or pull requests

4 participants