{"action":"created","comment":{"url":"https://api.github.com/repos/drupalcommerce/commerce/pulls/comments/85683519","pull_request_review_id":6384187,"id":85683519,"diff_hunk":"@@ -83,10 +85,33 @@ public function loadUnchanged($id) {\n   /**\n    * {@inheritdoc}\n    */\n+  protected function doPreSave(EntityInterface $entity) {\n+    $id = parent::doPreSave($entity);\n+    /** @var \\Drupal\\commerce_order\\Entity\\OrderInterface $entity */\n+    if ($entity->getRefreshState() == OrderInterface::REFRESH_ON_SAVE) {\n+      $this->orderRefresh->refresh($entity);\n+    }\n+    // Only the REFRESH_ON_LOAD state needs to be persisted on the entity.\n+    if ($entity->getRefreshState() != OrderInterface::REFRESH_ON_LOAD) {","path":"modules/order/src/OrderStorage.php","position":20,"original_position":20,"commit_id":"98598c074833017c14450da88c165d2523e4218e","original_commit_id":"98598c074833017c14450da88c165d2523e4218e","user":{"login":"mglaman","id":3698644,"avatar_url":"https://avatars.githubusercontent.com/u/3698644?v=3","gravatar_id":"","url":"https://api.github.com/users/mglaman","html_url":"https://github.com/mglaman","followers_url":"https://api.github.com/users/mglaman/followers","following_url":"https://api.github.com/users/mglaman/following{/other_user}","gists_url":"https://api.github.com/users/mglaman/gists{/gist_id}","starred_url":"https://api.github.com/users/mglaman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mglaman/subscriptions","organizations_url":"https://api.github.com/users/mglaman/orgs","repos_url":"https://api.github.com/users/mglaman/repos","events_url":"https://api.github.com/users/mglaman/events{/privacy}","received_events_url":"https://api.github.com/users/mglaman/received_events","type":"User","site_admin":false},"body":"To be honest it took me a bit to grok this.\r\n\r\nI would if \r\n\r\n```\r\nswitch (refreshState) :\r\n\r\n  case REFRESH_ON_LOAD:\r\n     // We do nothing so this persists.\r\n  case REFRESH_ON_SAVE:\r\n    refresh($entity);\r\n   // no break so it also uses skip/default\r\n\r\n  case REFRESH_SKIP:\r\n  default:\r\n    setRefreshState(NULL);\r\n  break;\r\n\r\nendswitch\r\n```\r\n\r\nLittle bit easier to understand.","created_at":"2016-10-31T04:07:42Z","updated_at":"2016-10-31T04:15:22Z","html_url":"https://github.com/drupalcommerce/commerce/pull/540#discussion_r85683519","pull_request_url":"https://api.github.com/repos/drupalcommerce/commerce/pulls/540","_links":{"self":{"href":"https://api.github.com/repos/drupalcommerce/commerce/pulls/comments/85683519"},"html":{"href":"https://github.com/drupalcommerce/commerce/pull/540#discussion_r85683519"},"pull_request":{"href":"https://api.github.com/repos/drupalcommerce/commerce/pulls/540"}}},"pull_request":{"url":"https://api.github.com/repos/drupalcommerce/commerce/pulls/540","id":90590215,"html_url":"https://github.com/drupalcommerce/commerce/pull/540","diff_url":"https://github.com/drupalcommerce/commerce/pull/540.diff","patch_url":"https://github.com/drupalcommerce/commerce/pull/540.patch","issue_url":"https://api.github.com/repos/drupalcommerce/commerce/issues/540","number":540,"state":"open","locked":false,"title":"Issue #2813583 by mglaman, bojanz: Expand the order refresh logic","user":{"login":"bojanz","id":330162,"avatar_url":"https://avatars.githubusercontent.com/u/330162?v=3","gravatar_id":"","url":"https://api.github.com/users/bojanz","html_url":"https://github.com/bojanz","followers_url":"https://api.github.com/users/bojanz/followers","following_url":"https://api.github.com/users/bojanz/following{/other_user}","gists_url":"https://api.github.com/users/bojanz/gists{/gist_id}","starred_url":"https://api.github.com/users/bojanz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bojanz/subscriptions","organizations_url":"https://api.github.com/users/bojanz/orgs","repos_url":"https://api.github.com/users/bojanz/repos","events_url":"https://api.github.com/users/bojanz/events{/privacy}","received_events_url":"https://api.github.com/users/bojanz/received_events","type":"User","site_admin":false},"body":"- Added getRefreshState() and setRefreshState() to orders.\n- Added a guarantee that order refresh frequency is always at least 1s, used it to remove the static from OrderRefresh\n- Improved the order refresh frequency form element (OrderTypeForm)\n- Changed the default refresh frequency to 300s (5min), default refresh mode to \"customer\" (matching 1.x)\n- Added logic that always refreshes if the day has changed.\n- Split needsRefresh into needsRefresh and shouldRefresh. Allows us to show a message to the admin saying \"looks like this order needs to be refreshed, would you like to do that?\"\n- Rewrote the order refresh tests.\n- Fixed bug where order items were saved before the processors had a chance to modify them.\n- Fixed wrong typehint for $current_user.\n- Copied the Drupal 8.3.x Time object into Commerce, added it to the refresh process.\n","created_at":"2016-10-24T10:59:08Z","updated_at":"2016-10-31T04:15:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5a3d4900f261465e31101ed6d447699d538c3fb9","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/drupalcommerce/commerce/pulls/540/commits","review_comments_url":"https://api.github.com/repos/drupalcommerce/commerce/pulls/540/comments","review_comment_url":"https://api.github.com/repos/drupalcommerce/commerce/pulls/comments{/number}","comments_url":"https://api.github.com/repos/drupalcommerce/commerce/issues/540/comments","statuses_url":"https://api.github.com/repos/drupalcommerce/commerce/statuses/98598c074833017c14450da88c165d2523e4218e","head":{"label":"drupalcommerce:expand-order-refresh","ref":"expand-order-refresh","sha":"98598c074833017c14450da88c165d2523e4218e","user":{"login":"drupalcommerce","id":183176,"avatar_url":"https://avatars.githubusercontent.com/u/183176?v=3","gravatar_id":"","url":"https://api.github.com/users/drupalcommerce","html_url":"https://github.com/drupalcommerce","followers_url":"https://api.github.com/users/drupalcommerce/followers","following_url":"https://api.github.com/users/drupalcommerce/following{/other_user}","gists_url":"https://api.github.com/users/drupalcommerce/gists{/gist_id}","starred_url":"https://api.github.com/users/drupalcommerce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drupalcommerce/subscriptions","organizations_url":"https://api.github.com/users/drupalcommerce/orgs","repos_url":"https://api.github.com/users/drupalcommerce/repos","events_url":"https://api.github.com/users/drupalcommerce/events{/privacy}","received_events_url":"https://api.github.com/users/drupalcommerce/received_events","type":"Organization","site_admin":false},"repo":{"id":21392057,"name":"commerce","full_name":"drupalcommerce/commerce","owner":{"login":"drupalcommerce","id":183176,"avatar_url":"https://avatars.githubusercontent.com/u/183176?v=3","gravatar_id":"","url":"https://api.github.com/users/drupalcommerce","html_url":"https://github.com/drupalcommerce","followers_url":"https://api.github.com/users/drupalcommerce/followers","following_url":"https://api.github.com/users/drupalcommerce/following{/other_user}","gists_url":"https://api.github.com/users/drupalcommerce/gists{/gist_id}","starred_url":"https://api.github.com/users/drupalcommerce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drupalcommerce/subscriptions","organizations_url":"https://api.github.com/users/drupalcommerce/orgs","repos_url":"https://api.github.com/users/drupalcommerce/repos","events_url":"https://api.github.com/users/drupalcommerce/events{/privacy}","received_events_url":"https://api.github.com/users/drupalcommerce/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/drupalcommerce/commerce","description":"Commerce 2.x development","fork":false,"url":"https://api.github.com/repos/drupalcommerce/commerce","forks_url":"https://api.github.com/repos/drupalcommerce/commerce/forks","keys_url":"https://api.github.com/repos/drupalcommerce/commerce/keys{/key_id}","collaborators_url":"https://api.github.com/repos/drupalcommerce/commerce/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/drupalcommerce/commerce/teams","hooks_url":"https://api.github.com/repos/drupalcommerce/commerce/hooks","issue_events_url":"https://api.github.com/repos/drupalcommerce/commerce/issues/events{/number}","events_url":"https://api.github.com/repos/drupalcommerce/commerce/events","assignees_url":"https://api.github.com/repos/drupalcommerce/commerce/assignees{/user}","branches_url":"https://api.github.com/repos/drupalcommerce/commerce/branches{/branch}","tags_url":"https://api.github.com/repos/drupalcommerce/commerce/tags","blobs_url":"https://api.github.com/repos/drupalcommerce/commerce/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/drupalcommerce/commerce/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/drupalcommerce/commerce/git/refs{/sha}","trees_url":"https://api.github.com/repos/drupalcommerce/commerce/git/trees{/sha}","statuses_url":"https://api.github.com/repos/drupalcommerce/commerce/statuses/{sha}","languages_url":"https://api.github.com/repos/drupalcommerce/commerce/languages","stargazers_url":"https://api.github.com/repos/drupalcommerce/commerce/stargazers","contributors_url":"https://api.github.com/repos/drupalcommerce/commerce/contributors","subscribers_url":"https://api.github.com/repos/drupalcommerce/commerce/subscribers","subscription_url":"https://api.github.com/repos/drupalcommerce/commerce/subscription","commits_url":"https://api.github.com/repos/drupalcommerce/commerce/commits{/sha}","git_commits_url":"https://api.github.com/repos/drupalcommerce/commerce/git/commits{/sha}","comments_url":"https://api.github.com/repos/drupalcommerce/commerce/comments{/number}","issue_comment_url":"https://api.github.com/repos/drupalcommerce/commerce/issues/comments{/number}","contents_url":"https://api.github.com/repos/drupalcommerce/commerce/contents/{+path}","compare_url":"https://api.github.com/repos/drupalcommerce/commerce/compare/{base}...{head}","merges_url":"https://api.github.com/repos/drupalcommerce/commerce/merges","archive_url":"https://api.github.com/repos/drupalcommerce/commerce/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/drupalcommerce/commerce/downloads","issues_url":"https://api.github.com/repos/drupalcommerce/commerce/issues{/number}","pulls_url":"https://api.github.com/repos/drupalcommerce/commerce/pulls{/number}","milestones_url":"https://api.github.com/repos/drupalcommerce/commerce/milestones{/number}","notifications_url":"https://api.github.com/repos/drupalcommerce/commerce/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/drupalcommerce/commerce/labels{/name}","releases_url":"https://api.github.com/repos/drupalcommerce/commerce/releases{/id}","deployments_url":"https://api.github.com/repos/drupalcommerce/commerce/deployments","created_at":"2014-07-01T15:05:51Z","updated_at":"2016-10-24T16:25:17Z","pushed_at":"2016-10-31T01:03:54Z","git_url":"git://github.com/drupalcommerce/commerce.git","ssh_url":"git@github.com:drupalcommerce/commerce.git","clone_url":"https://github.com/drupalcommerce/commerce.git","svn_url":"https://github.com/drupalcommerce/commerce","homepage":"https://drupal.org/project/commerce","size":6058,"stargazers_count":212,"watchers_count":212,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":142,"mirror_url":null,"open_issues_count":26,"forks":142,"open_issues":26,"watchers":212,"default_branch":"8.x-2.x"}},"base":{"label":"drupalcommerce:8.x-2.x","ref":"8.x-2.x","sha":"99463545a2b03aae56856a9a58170a24e047a33d","user":{"login":"drupalcommerce","id":183176,"avatar_url":"https://avatars.githubusercontent.com/u/183176?v=3","gravatar_id":"","url":"https://api.github.com/users/drupalcommerce","html_url":"https://github.com/drupalcommerce","followers_url":"https://api.github.com/users/drupalcommerce/followers","following_url":"https://api.github.com/users/drupalcommerce/following{/other_user}","gists_url":"https://api.github.com/users/drupalcommerce/gists{/gist_id}","starred_url":"https://api.github.com/users/drupalcommerce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drupalcommerce/subscriptions","organizations_url":"https://api.github.com/users/drupalcommerce/orgs","repos_url":"https://api.github.com/users/drupalcommerce/repos","events_url":"https://api.github.com/users/drupalcommerce/events{/privacy}","received_events_url":"https://api.github.com/users/drupalcommerce/received_events","type":"Organization","site_admin":false},"repo":{"id":21392057,"name":"commerce","full_name":"drupalcommerce/commerce","owner":{"login":"drupalcommerce","id":183176,"avatar_url":"https://avatars.githubusercontent.com/u/183176?v=3","gravatar_id":"","url":"https://api.github.com/users/drupalcommerce","html_url":"https://github.com/drupalcommerce","followers_url":"https://api.github.com/users/drupalcommerce/followers","following_url":"https://api.github.com/users/drupalcommerce/following{/other_user}","gists_url":"https://api.github.com/users/drupalcommerce/gists{/gist_id}","starred_url":"https://api.github.com/users/drupalcommerce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drupalcommerce/subscriptions","organizations_url":"https://api.github.com/users/drupalcommerce/orgs","repos_url":"https://api.github.com/users/drupalcommerce/repos","events_url":"https://api.github.com/users/drupalcommerce/events{/privacy}","received_events_url":"https://api.github.com/users/drupalcommerce/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/drupalcommerce/commerce","description":"Commerce 2.x development","fork":false,"url":"https://api.github.com/repos/drupalcommerce/commerce","forks_url":"https://api.github.com/repos/drupalcommerce/commerce/forks","keys_url":"https://api.github.com/repos/drupalcommerce/commerce/keys{/key_id}","collaborators_url":"https://api.github.com/repos/drupalcommerce/commerce/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/drupalcommerce/commerce/teams","hooks_url":"https://api.github.com/repos/drupalcommerce/commerce/hooks","issue_events_url":"https://api.github.com/repos/drupalcommerce/commerce/issues/events{/number}","events_url":"https://api.github.com/repos/drupalcommerce/commerce/events","assignees_url":"https://api.github.com/repos/drupalcommerce/commerce/assignees{/user}","branches_url":"https://api.github.com/repos/drupalcommerce/commerce/branches{/branch}","tags_url":"https://api.github.com/repos/drupalcommerce/commerce/tags","blobs_url":"https://api.github.com/repos/drupalcommerce/commerce/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/drupalcommerce/commerce/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/drupalcommerce/commerce/git/refs{/sha}","trees_url":"https://api.github.com/repos/drupalcommerce/commerce/git/trees{/sha}","statuses_url":"https://api.github.com/repos/drupalcommerce/commerce/statuses/{sha}","languages_url":"https://api.github.com/repos/drupalcommerce/commerce/languages","stargazers_url":"https://api.github.com/repos/drupalcommerce/commerce/stargazers","contributors_url":"https://api.github.com/repos/drupalcommerce/commerce/contributors","subscribers_url":"https://api.github.com/repos/drupalcommerce/commerce/subscribers","subscription_url":"https://api.github.com/repos/drupalcommerce/commerce/subscription","commits_url":"https://api.github.com/repos/drupalcommerce/commerce/commits{/sha}","git_commits_url":"https://api.github.com/repos/drupalcommerce/commerce/git/commits{/sha}","comments_url":"https://api.github.com/repos/drupalcommerce/commerce/comments{/number}","issue_comment_url":"https://api.github.com/repos/drupalcommerce/commerce/issues/comments{/number}","contents_url":"https://api.github.com/repos/drupalcommerce/commerce/contents/{+path}","compare_url":"https://api.github.com/repos/drupalcommerce/commerce/compare/{base}...{head}","merges_url":"https://api.github.com/repos/drupalcommerce/commerce/merges","archive_url":"https://api.github.com/repos/drupalcommerce/commerce/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/drupalcommerce/commerce/downloads","issues_url":"https://api.github.com/repos/drupalcommerce/commerce/issues{/number}","pulls_url":"https://api.github.com/repos/drupalcommerce/commerce/pulls{/number}","milestones_url":"https://api.github.com/repos/drupalcommerce/commerce/milestones{/number}","notifications_url":"https://api.github.com/repos/drupalcommerce/commerce/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/drupalcommerce/commerce/labels{/name}","releases_url":"https://api.github.com/repos/drupalcommerce/commerce/releases{/id}","deployments_url":"https://api.github.com/repos/drupalcommerce/commerce/deployments","created_at":"2014-07-01T15:05:51Z","updated_at":"2016-10-24T16:25:17Z","pushed_at":"2016-10-31T01:03:54Z","git_url":"git://github.com/drupalcommerce/commerce.git","ssh_url":"git@github.com:drupalcommerce/commerce.git","clone_url":"https://github.com/drupalcommerce/commerce.git","svn_url":"https://github.com/drupalcommerce/commerce","homepage":"https://drupal.org/project/commerce","size":6058,"stargazers_count":212,"watchers_count":212,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":142,"mirror_url":null,"open_issues_count":26,"forks":142,"open_issues":26,"watchers":212,"default_branch":"8.x-2.x"}},"_links":{"self":{"href":"https://api.github.com/repos/drupalcommerce/commerce/pulls/540"},"html":{"href":"https://github.com/drupalcommerce/commerce/pull/540"},"issue":{"href":"https://api.github.com/repos/drupalcommerce/commerce/issues/540"},"comments":{"href":"https://api.github.com/repos/drupalcommerce/commerce/issues/540/comments"},"review_comments":{"href":"https://api.github.com/repos/drupalcommerce/commerce/pulls/540/comments"},"review_comment":{"href":"https://api.github.com/repos/drupalcommerce/commerce/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/drupalcommerce/commerce/pulls/540/commits"},"statuses":{"href":"https://api.github.com/repos/drupalcommerce/commerce/statuses/98598c074833017c14450da88c165d2523e4218e"}}}}
{"actor":{"display_login":"mglaman"}}