-
Notifications
You must be signed in to change notification settings - Fork 125
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
NEW Auto-publish objects on sort #292
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments. Also this is essentially a backport of a change in the SS4 branch of this module - the difference is that it is opt-in configuration. I think that you should do the same - we don't want to immediately change the functionality here because you're not actually fixing a bug.
@@ -463,6 +463,9 @@ protected function reorderItems($list, array $values, array $sortedIDs) { | |||
if ($class == $this->getSortTable($list)) { | |||
$isVersioned = $class::has_extension('Versioned'); | |||
} | |||
if ($class::has_extension('Versioned')) { | |||
$isVersioned = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you added this to use it later but it's unused?
@@ -505,11 +508,15 @@ protected function reorderItems($list, array $values, array $sortedIDs) { | |||
// similar to the SiteTree where you change the position, and then | |||
// you go into the record and publish it. | |||
foreach($sortedIDs as $sortValue => $id) { | |||
if($map[$id] != $sortValue) { | |||
$record = $class::get()->byID($id); | |||
$record = $class::get()->byID($id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this could be left inside the condition below? It's a sliiiight performance impact moving it out of the condition because you're loading a DataObject for every item regardless of the following condition...
$record->$sortField = $sortValue; | ||
$record->write(); | ||
} | ||
// Update stage to live only for published records | ||
if ($record->isPublished()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only relevant if there's a write, so you can move it into the condition. Also this is probably where you want to use $isVersioned
you prepared earlier.
I agree, I will change my code. |
Closing this pr, as this issue does not exists in fresh SS3 installation. |
Related SS4 PR: #289