From 4cd8a5603e8f19b252c8339cf7eb4e3d9958953d Mon Sep 17 00:00:00 2001 From: malinajirka Date: Tue, 11 Jun 2019 16:25:45 +0200 Subject: [PATCH 1/8] Update release notes --- RELEASE-NOTES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 1dfd9acbf983..72e6fbe3c6fb 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -12,6 +12,7 @@ * Fixed issue where text appeared behind list of themes on the theme screen * Domain Registration functionality for Business plan customers on a site without a custom domain during plugin installation +* Fix issue where post with "Publish" status got automatically published 12.6 ----- * Add Insights management introductory card From a16790399bd44d2d2bcf7d5d9bee476b51838610 Mon Sep 17 00:00:00 2001 From: malinajirka Date: Tue, 11 Jun 2019 16:07:58 +0200 Subject: [PATCH 2/8] Prevent LocalDraftUploadStarter from publishing a post --- .../org/wordpress/android/ui/uploads/LocalDraftUploadStarter.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarter.kt b/WordPress/src/main/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarter.kt index ebf60d09ad7e..33fe8b242da7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarter.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarter.kt @@ -14,6 +14,7 @@ import kotlinx.coroutines.async import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch import org.wordpress.android.fluxc.model.SiteModel +import org.wordpress.android.fluxc.model.post.PostStatus import org.wordpress.android.fluxc.store.PageStore import org.wordpress.android.fluxc.store.PostStore import org.wordpress.android.fluxc.store.SiteStore @@ -136,6 +137,7 @@ open class LocalDraftUploadStarter @Inject constructor( postsAndPages .filterNot { uploadServiceFacade.isPostUploadingOrQueued(it) } .filter { postUtilsWrapper.isPublishable(it) } + .filter { PostStatus.DRAFT.toString() == it.status || PostStatus.PENDING.toString() == it.status } .forEach { localDraft -> uploadServiceFacade.uploadPost( context = context, From 7a41da4d2894a83ed3e8cb96a30ac8cd3bbdc5fe Mon Sep 17 00:00:00 2001 From: Maxime Biais Date: Wed, 10 Jul 2019 16:46:33 +0200 Subject: [PATCH 3/8] Remove pending posts from the filter --- .../org/wordpress/android/ui/uploads/LocalDraftUploadStarter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarter.kt b/WordPress/src/main/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarter.kt index 33fe8b242da7..feda982aff14 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarter.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarter.kt @@ -137,7 +137,7 @@ open class LocalDraftUploadStarter @Inject constructor( postsAndPages .filterNot { uploadServiceFacade.isPostUploadingOrQueued(it) } .filter { postUtilsWrapper.isPublishable(it) } - .filter { PostStatus.DRAFT.toString() == it.status || PostStatus.PENDING.toString() == it.status } + .filter { PostStatus.DRAFT.toString() == it.status } .forEach { localDraft -> uploadServiceFacade.uploadPost( context = context, From 23144830b9ac3c9ca2dd392986abce8ba54466f9 Mon Sep 17 00:00:00 2001 From: Maxime Biais Date: Wed, 10 Jul 2019 16:49:13 +0200 Subject: [PATCH 4/8] Update release notes for 12.7.1 --- RELEASE-NOTES.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 72e6fbe3c6fb..ad254458541a 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,6 +1,9 @@ 12.8 ----- +12.7.1 +------ +* Fix issue where local draft with "Publish" status got automatically published 12.7 ----- @@ -12,12 +15,10 @@ * Fixed issue where text appeared behind list of themes on the theme screen * Domain Registration functionality for Business plan customers on a site without a custom domain during plugin installation -* Fix issue where post with "Publish" status got automatically published 12.6 ----- * Add Insights management introductory card * Local draft pages will be automatically uploaded to the server as soon as an internet connection is available. - * Block Editor: A new block is available: video block. * Block Editor: Added UI to display a warning when a block has invalid content. * Block Editor: Fixed issue with link settings where “Open in New Tab” was always OFF on open. From 8903f1620a21b9c2132832b6d37695f62d625174 Mon Sep 17 00:00:00 2001 From: Maxime Biais Date: Wed, 10 Jul 2019 17:10:08 +0200 Subject: [PATCH 5/8] Update tests, only use draft in there --- .../LocalDraftUploadStarterConcurrentTest.kt | 21 ++++---- .../ui/uploads/LocalDraftUploadStarterTest.kt | 48 ++++++++++--------- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarterConcurrentTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarterConcurrentTest.kt index fedae65dbd76..219f4e39c93f 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarterConcurrentTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarterConcurrentTest.kt @@ -15,6 +15,7 @@ import org.junit.runner.RunWith import org.mockito.junit.MockitoJUnitRunner import org.wordpress.android.fluxc.model.PostModel import org.wordpress.android.fluxc.model.SiteModel +import org.wordpress.android.fluxc.model.post.PostStatus import org.wordpress.android.fluxc.store.PageStore import org.wordpress.android.fluxc.store.PostStore import org.wordpress.android.ui.posts.PostUtilsWrapper @@ -31,16 +32,16 @@ class LocalDraftUploadStarterConcurrentTest { @get:Rule val rule = InstantTaskExecutorRule() private val site = SiteModel() - private val posts = listOf( - PostModel(), - PostModel(), - PostModel(), - PostModel(), - PostModel() + private val draftPosts = listOf( + createDraftPostModel(), + createDraftPostModel(), + createDraftPostModel(), + createDraftPostModel(), + createDraftPostModel() ) private val postStore = mock { - on { getLocalDraftPosts(eq(site)) } doReturn posts + on { getLocalDraftPosts(eq(site)) } doReturn draftPosts } private val pageStore = mock { onBlocking { getLocalDraftPages(any()) } doReturn emptyList() @@ -59,7 +60,7 @@ class LocalDraftUploadStarterConcurrentTest { } // Then - verify(uploadServiceFacade, times(posts.size)).uploadPost( + verify(uploadServiceFacade, times(draftPosts.size)).uploadPost( context = any(), post = any(), trackAnalytics = any(), @@ -93,5 +94,9 @@ class LocalDraftUploadStarterConcurrentTest { fun createMockedPostUtilsWrapper() = mock { on { isPublishable(any()) } doReturn true } + + fun createDraftPostModel() = PostModel().apply { + status = PostStatus.DRAFT.toString() + } } } diff --git a/WordPress/src/test/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarterTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarterTest.kt index 9be172d6f232..430f9395ce17 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarterTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarterTest.kt @@ -25,6 +25,7 @@ import org.junit.runner.RunWith import org.mockito.junit.MockitoJUnitRunner import org.wordpress.android.fluxc.model.PostModel import org.wordpress.android.fluxc.model.SiteModel +import org.wordpress.android.fluxc.model.post.PostStatus import org.wordpress.android.fluxc.store.PageStore import org.wordpress.android.fluxc.store.PostStore import org.wordpress.android.fluxc.store.SiteStore @@ -41,35 +42,35 @@ class LocalDraftUploadStarterTest { @get:Rule val rule = InstantTaskExecutorRule() private val sites = listOf(SiteModel(), SiteModel()) - private val sitesAndPosts: Map> = mapOf( - sites[0] to listOf(createPostModel(), createPostModel()), + private val sitesAndDraftPosts: Map> = mapOf( + sites[0] to listOf(createDraftPostModel(), createDraftPostModel()), sites[1] to listOf( - createPostModel(), - createPostModel(), - createPostModel(), - createPostModel(), - createPostModel() + createDraftPostModel(), + createDraftPostModel(), + createDraftPostModel(), + createDraftPostModel(), + createDraftPostModel() ) ) - private val posts = sitesAndPosts.values.flatten() + private val draftPosts = sitesAndDraftPosts.values.flatten() - private val sitesAndPages: Map> = mapOf( - sites[0] to listOf(createPostModel(), createPostModel()), - sites[1] to listOf(createPostModel(), createPostModel(), createPostModel(), createPostModel()) + private val sitesAndDraftPages: Map> = mapOf( + sites[0] to listOf(createDraftPostModel(), createDraftPostModel()), + sites[1] to listOf(createDraftPostModel(), createDraftPostModel(), createDraftPostModel(), createDraftPostModel()) ) - private val pages = sitesAndPages.values.flatten() + private val draftPages = sitesAndDraftPages.values.flatten() private val siteStore = mock { on { sites } doReturn sites } private val postStore = mock { sites.forEach { - on { getLocalDraftPosts(eq(it)) } doReturn sitesAndPosts.getValue(it) + on { getLocalDraftPosts(eq(it)) } doReturn sitesAndDraftPosts.getValue(it) } } private val pageStore = mock { sites.forEach { - onBlocking { getLocalDraftPages(eq(it)) } doReturn sitesAndPages.getValue(it) + onBlocking { getLocalDraftPages(eq(it)) } doReturn sitesAndDraftPages.getValue(it) } } @@ -93,7 +94,7 @@ class LocalDraftUploadStarterTest { connectionStatus.postValue(AVAILABLE) // Then - verify(uploadServiceFacade, times(posts.size + pages.size)).uploadPost( + verify(uploadServiceFacade, times(draftPosts.size + draftPages.size)).uploadPost( context = any(), post = any(), trackAnalytics = any(), @@ -142,7 +143,7 @@ class LocalDraftUploadStarterTest { lifecycle.handleLifecycleEvent(Event.ON_START) // Then - verify(uploadServiceFacade, times(posts.size + pages.size)).uploadPost( + verify(uploadServiceFacade, times(draftPosts.size + draftPages.size)).uploadPost( context = any(), post = any(), trackAnalytics = any(), @@ -165,7 +166,7 @@ class LocalDraftUploadStarterTest { starter.queueUploadFromSite(site) // Then - val expectedUploadPostExecutions = sitesAndPosts.getValue(site).size + sitesAndPages.getValue(site).size + val expectedUploadPostExecutions = sitesAndDraftPosts.getValue(site).size + sitesAndDraftPages.getValue(site).size verify(uploadServiceFacade, times(expectedUploadPostExecutions)).uploadPost( context = any(), post = any(), @@ -185,7 +186,7 @@ class LocalDraftUploadStarterTest { val postUtilsWrapper = mock { on { isPublishable(any()) } doAnswer { // return isPublishable = false on the first post of the site - it.getArgument(0) != sitesAndPosts[site]?.get(0)!! + it.getArgument(0) != sitesAndDraftPosts[site]?.get(0)!! } } @@ -196,7 +197,7 @@ class LocalDraftUploadStarterTest { // Then // subtract - 1 as we've returned isPublishable = false for the first post of the site - val expectedUploadPostExecutions = sitesAndPosts.getValue(site).size + sitesAndPages.getValue(site).size - 1 + val expectedUploadPostExecutions = sitesAndDraftPosts.getValue(site).size + sitesAndDraftPages.getValue(site).size - 1 verify(uploadServiceFacade, times(expectedUploadPostExecutions)).uploadPost( context = any(), post = any(), @@ -210,14 +211,14 @@ class LocalDraftUploadStarterTest { fun `when uploading, it ignores local drafts that are already queued`() { // Given val site: SiteModel = sites[1] - val (expectedQueuedPosts, expectedUploadedPosts) = sitesAndPosts.getValue(site).let { posts -> + val (expectedQueuedPosts, expectedUploadedPosts) = sitesAndDraftPosts.getValue(site).let { posts -> // Split into halves of already queued and what should be uploaded return@let Pair( posts.subList(0, posts.size / 2), posts.subList(posts.size / 2, posts.size) ) } - val (expectedQueuedPages, expectedUploadedPages) = sitesAndPages.getValue(site).let { pages -> + val (expectedQueuedPages, expectedUploadedPages) = sitesAndDraftPages.getValue(site).let { pages -> // Split into halves of already queued and what should be uploaded return@let Pair( pages.subList(0, pages.size / 2), @@ -250,7 +251,7 @@ class LocalDraftUploadStarterTest { ) verify( uploadServiceFacade, - times(sitesAndPosts.getValue(site).size + sitesAndPages.getValue(site).size) + times(sitesAndDraftPosts.getValue(site).size + sitesAndDraftPages.getValue(site).size) ).isPostUploadingOrQueued(any()) verifyNoMoreInteractions(uploadServiceFacade) } @@ -296,9 +297,10 @@ class LocalDraftUploadStarterTest { on { this.lifecycle } doReturn lifecycle } - fun createPostModel() = PostModel().apply { + fun createDraftPostModel() = PostModel().apply { id = Random.nextInt() title = UUID.randomUUID().toString() + status = PostStatus.DRAFT.toString() } } } From 8b185582a83efaf0a81184fb9ac447d17ebe0258 Mon Sep 17 00:00:00 2001 From: Maxime Biais Date: Wed, 10 Jul 2019 17:15:46 +0200 Subject: [PATCH 6/8] Fix checkstyle issues --- .../ui/uploads/LocalDraftUploadStarterTest.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarterTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarterTest.kt index 430f9395ce17..7412fc7218f2 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarterTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarterTest.kt @@ -56,7 +56,12 @@ class LocalDraftUploadStarterTest { private val sitesAndDraftPages: Map> = mapOf( sites[0] to listOf(createDraftPostModel(), createDraftPostModel()), - sites[1] to listOf(createDraftPostModel(), createDraftPostModel(), createDraftPostModel(), createDraftPostModel()) + sites[1] to listOf( + createDraftPostModel(), + createDraftPostModel(), + createDraftPostModel(), + createDraftPostModel() + ) ) private val draftPages = sitesAndDraftPages.values.flatten() @@ -166,7 +171,8 @@ class LocalDraftUploadStarterTest { starter.queueUploadFromSite(site) // Then - val expectedUploadPostExecutions = sitesAndDraftPosts.getValue(site).size + sitesAndDraftPages.getValue(site).size + val expectedUploadPostExecutions = sitesAndDraftPosts.getValue(site).size + + sitesAndDraftPages.getValue(site).size verify(uploadServiceFacade, times(expectedUploadPostExecutions)).uploadPost( context = any(), post = any(), @@ -197,7 +203,8 @@ class LocalDraftUploadStarterTest { // Then // subtract - 1 as we've returned isPublishable = false for the first post of the site - val expectedUploadPostExecutions = sitesAndDraftPosts.getValue(site).size + sitesAndDraftPages.getValue(site).size - 1 + val expectedUploadPostExecutions = sitesAndDraftPosts.getValue(site).size + + sitesAndDraftPages.getValue(site).size - 1 verify(uploadServiceFacade, times(expectedUploadPostExecutions)).uploadPost( context = any(), post = any(), From 1ddb6b6699ecc166f5873fc8102df230f431db2f Mon Sep 17 00:00:00 2001 From: Lorenzo Mattei Date: Wed, 10 Jul 2019 18:59:05 +0200 Subject: [PATCH 7/8] Readd required filter --- .../wordpress/android/ui/uploads/LocalDraftUploadStarter.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarter.kt b/WordPress/src/main/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarter.kt index 9616cbbc5774..ceea110e4e14 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarter.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/LocalDraftUploadStarter.kt @@ -140,6 +140,9 @@ open class LocalDraftUploadStarter @Inject constructor( postsAndPages .filterNot { uploadServiceFacade.isPostUploadingOrQueued(it) } .filter { postUtilsWrapper.isPublishable(it) } + .filter { + uploadStore.getNumberOfPostUploadErrorsOrCancellations(it) < MAXIMUM_AUTO_INITIATED_UPLOAD_RETRIES + } .filter { PostStatus.DRAFT.toString() == it.status } .forEach { localDraft -> uploadServiceFacade.uploadPost( From 1afcc47b6dedac28d239d3efe886bcb8c4d5da67 Mon Sep 17 00:00:00 2001 From: Lorenzo Mattei Date: Wed, 10 Jul 2019 23:31:45 +0200 Subject: [PATCH 8/8] Bump version to 12.7.1/749 --- WordPress/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 1f6e2875536f..c9da5e349d3f 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -44,8 +44,8 @@ android { defaultConfig { applicationId "org.wordpress.android" - versionName "12.7" - versionCode 744 + versionName "12.7.1" + versionCode 749 minSdkVersion 21 targetSdkVersion 26