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

Prevent Zend_Date from checking locale for know date codes #2050

Merged

Conversation

MarcinNowakWebdeveloper
Copy link
Contributor

Add U, X and c, as we know the codes are not real locales.

Add U, X and c, as we know the codes are not real locales.
@joshua-bn
Copy link
Contributor

With this many, I would use in_array() or isset() so it's more readable. But, looks good.

@fballiano
Copy link
Contributor

can we know a little bit more about this?

@tmotyl
Copy link
Contributor

tmotyl commented Apr 21, 2022

@fballiano sure, this change is a performance optimization that we run on prod since more than a year.
Without it, Zend_Date tries to detect Locale for a given date even though the date is not locale aware.
The logic of fetching Locale is expensive at its requires a cache lookup.
So basically this change prevents multiple calls to Zend cache during request. Its especially painful/visible on requests with many date formatting e.g. reports.

@fballiano
Copy link
Contributor

Thanks @tmotyl!
How did you find these "UXc" parts that you've added? Also, where there specific reasons to move from "!=" to "!=="?

@tmotyl
Copy link
Contributor

tmotyl commented Apr 21, 2022

@fballiano
See constants in https://github.com/OpenMage/magento-lts/blob/1.9.4.x/app/code/core/Zend/Date.php#L94-L94 and then look for their usage in the code.
And also
https://github.com/OpenMage/magento-lts/blob/1.9.4.x/app/code/core/Zend/Date.php#L800-L800

I have found the issue when investigating (profiling with blackfire) why some magento reports are taking ages to load / timeout.

Also, where there specific reasons to move from "!=" to "!=="?

Its a best practice, as both sides are strings, it doesn't make sense to have "!="

@fballiano fballiano merged commit bcb8390 into OpenMage:1.9.4.x May 12, 2022
@github-actions
Copy link
Contributor

Unit Test Results

1 files  ±0  1 suites  ±0   0s ⏱️ ±0s
0 tests ±0  0 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
7 runs  ±0  5 ✔️ ±0  2 💤 ±0  0 ❌ ±0 

Results for commit bcb8390. ± Comparison against base commit 8e9ac45.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants