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

Replace deprecated global now() calls with Varien_Date::now() #2250

Merged
merged 1 commit into from
Jun 24, 2022
Merged

Replace deprecated global now() calls with Varien_Date::now() #2250

merged 1 commit into from
Jun 24, 2022

Conversation

Sdfendor
Copy link
Contributor

@Sdfendor Sdfendor commented Jun 24, 2022

Description (*)

Global function now() and static method Varien_Date::now() are equivalent. #1991 accommodated that by deprecating the global function. This PR does two things:

  • Replacing all calls to now() with Varien_Date::now()
  • Where possible a variable is used instead of multiple immediately subsequent calls of the method.

Additionally there is a reformat for an if-conditional in which the method is used.

Related Pull Requests

#1991

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)

@github-actions github-actions bot added Component: Adminhtml Relates to Mage_Adminhtml Component: Admin Relates to Mage_Admin Component: Api PageRelates to Mage_Api Component: CatalogRule Relates to Mage_CatalogRule Component: Cms Relates to Mage_Cms Component: ImportExport Relates to Mage_ImportExport Component: Log Relates to Mage_Log Component: Poll Relates to Mage_Poll Component: Reports Relates to Mage_Reports Component: Wishlist Relates to Mage_Wishlist labels Jun 24, 2022
Copy link
Contributor

@fballiano fballiano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ADDISON74
Copy link
Contributor

The PR idea is fine with one condition, to have consistency regarding the source code. I notice that either a $now variable or Varien_Date :: now() are used. My proposal is to give up declaring the $now variable everywhere.

@Sdfendor
Copy link
Contributor Author

Sdfendor commented Jun 24, 2022

@ADDISON74 $now is used only in cases where the method is called multiple times immediately one after another (e.g. to fill a 'created_at' field and a 'updated_at' field in the same array to be saved to DB). That made no sense to me.
Or take for example:
image
Why should (in case the $object has no id and is freshly created) Varien_Date::now() be called two times? The result will be the same anyways because the datetime format used doesn't include milliseconds.

@elidrissidev elidrissidev merged commit be12715 into OpenMage:1.9.4.x Jun 24, 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 be12715. ± Comparison against base commit 412bee0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Admin Relates to Mage_Admin Component: Adminhtml Relates to Mage_Adminhtml Component: Api PageRelates to Mage_Api Component: CatalogRule Relates to Mage_CatalogRule Component: Cms Relates to Mage_Cms Component: ImportExport Relates to Mage_ImportExport Component: Log Relates to Mage_Log Component: Poll Relates to Mage_Poll Component: Reports Relates to Mage_Reports Component: Wishlist Relates to Mage_Wishlist
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants