U4-9532 - logic in ContentRepository.ClearPublished is inefficient

Created by Shannon Deminick 15 Feb 2017, 10:23:37 Updated by Sebastiaan Janssen 16 Feb 2017, 07:12:15

Tags: Unscheduled

Currently it is this:


        public void ClearPublished(IContent content)
        {
            // race cond!
            var documentDtos = Database.Fetch<DocumentDto>("WHERE nodeId=@id AND published=@published", new { id = content.Id, published = true });
            foreach (var documentDto in documentDtos)
            {
                documentDto.Published = false;
                Database.Update(documentDto);
            }
        }

but it can just be:

        public void ClearPublished(IContent content)
        {
            var sql = "UPDATE cmsDocument SET published=0 WHERE nodeId=@id AND published=1";
            Database.Execute(sql, new {id = content.Id});
        }

Comments

Shannon Deminick 15 Feb 2017, 10:23:50

see rev: 0c613347aec424d136485aac73e590f0a54b6cc8


Shannon Deminick 15 Feb 2017, 10:25:02

and rev: 975c97cfb0c89a9c5d18c57e473c26b7b189879d


Sebastiaan Janssen 15 Feb 2017, 13:58:02

@Shandem Any reason this shouldn't go in 7.5.10? :) Seems like a no-brainer.


Shannon Deminick 15 Feb 2017, 22:56:13

I just didn't want to put anything else in there at the last minute. Happy to backport if you want, just say the word!


Sebastiaan Janssen 16 Feb 2017, 07:12:13

cherry picked both into 7.5.10 - https://github.com/umbraco/Umbraco-CMS/commit/acf10eeef0d5b6be4ac83f70ee933ef5fd8e24fd


Priority: Normal

Type: Bug

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.5.10

Sprint: Sprint 52

Story Points:

Cycle: