Skip to content

[Backport 2.3] #12625: Add Current Date to update_time Field for Block and Pages #12637

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

Merged
merged 1 commit into from
Dec 20, 2017

Conversation

osrecio
Copy link
Member

@osrecio osrecio commented Dec 11, 2017

Set Current Date Time to update_time field

Description

add current date time to 'update_time' in _beforeSave method for Page and Block

Fixed Issues (if relevant)

  1. when saving a page in magento 2.2.1, 'Modified' date field is not getting updated #12625: when saving a page in magento 2.2.1, 'Modified' date field is not getting updated

Manual testing scenarios

  1. Login to magento admin
  2. Go to Content > Pages
  3. In Action column, click select > edit
  4. Make changes to that page and click 'Save Page'

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team magento-engcom-team added Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Dec 11, 2017
@dmanners
Copy link
Contributor

This is a backport of #12636

@@ -126,6 +126,10 @@ protected function _beforeSave(AbstractModel $object)
__('The page URL key cannot be made of only numbers.')
);
}

$date = (new \DateTime())->format(DateTime::DATETIME_PHP_FORMAT);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, use framework implementation for date value \Magento\Framework\Stdlib\DateTime\DateTime::date

@osrecio
Copy link
Member Author

osrecio commented Dec 14, 2017

@sidolov Changes made, and added integration tests for Cms Block 😃

@osrecio osrecio force-pushed the PR#12625_2.3 branch 5 times, most recently from e91243e to 29812aa Compare December 18, 2017 07:08
@sidolov
Copy link
Contributor

sidolov commented Dec 18, 2017

Hi @osrecio , i investigated this issue deeper and find that field 'update_time' should be automatically updated by Mysql engine. In db this field has type timestamp and must be automatically updated after row has been changed. We had the same issue with quote (bf9ea28).
This behavior fixing by unset 'update_time' field before model save:

if ($this->hasDataChanges()) {
    $this->unsUpdateTime();
}

@osrecio
Copy link
Member Author

osrecio commented Dec 18, 2017

Hi @sidolov I changed Models to add in method beforeSave:

if ($this->hasDataChanges()) {
    $this->unsUpdateTime();
}

Thanks for catch it, I made my life complicated changing Resource Model :)

@magento-team magento-team merged commit 5cce625 into magento:2.3-develop Dec 20, 2017
magento-team pushed a commit that referenced this pull request Dec 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Progress: accept Release Line: 2.3 Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants