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

NEW Auto-publish objects on sort #292

Closed
wants to merge 1 commit into from

Conversation

amolswnz
Copy link

@amolswnz amolswnz commented May 12, 2019

Related SS4 PR: #289

Copy link
Contributor

@ScopeyNZ ScopeyNZ left a 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;
Copy link
Contributor

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);
Copy link
Contributor

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()) {
Copy link
Contributor

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.

@ScopeyNZ ScopeyNZ changed the title Sort order save in _Live table NEW Auto-publish objects on sort May 12, 2019
@amolswnz
Copy link
Author

I agree, I will change my code.

@amolswnz
Copy link
Author

Closing this pr, as this issue does not exists in fresh SS3 installation.

@amolswnz amolswnz closed this May 24, 2019
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.

3 participants