diff --git a/composer.json b/composer.json index 62b3a7aba420d6555e03d704956c6144ed4a904a..4fbe629365d07258993a8e521fd1a198b8f89bdf 100644 --- a/composer.json +++ b/composer.json @@ -166,7 +166,7 @@ "drupal/ultimate_cron": "^2.0@alpha", "drupal/userprotect": "1.1", "drupal/video_embed_field": "2.4", - "drupal/view_unpublished": "1.0", + "drupal/view_unpublished": "1.1", "drupal/views_ajax_history": "1.7", "drupal/views_autocomplete_filters": "1.3", "drupal/views_bootstrap": "3.6", diff --git a/composer.lock b/composer.lock index 9fc4612e2d9c93c1881b89de4796488e60b78969..72515bee775e7b6e3b6a8ac7993311588fe59bc0 100644 --- a/composer.lock +++ b/composer.lock @@ -7498,26 +7498,26 @@ }, { "name": "drupal/view_unpublished", - "version": "1.0.0", + "version": "1.1.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/view_unpublished.git", - "reference": "8.x-1.0" + "reference": "8.x-1.1" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/view_unpublished-8.x-1.0.zip", - "reference": "8.x-1.0", - "shasum": "74ebdf1b4f6963f7bb63192bc314014c0132d03c" + "url": "https://ftp.drupal.org/files/projects/view_unpublished-8.x-1.1.zip", + "reference": "8.x-1.1", + "shasum": "f9f5e88cbaf1a1e71952d94cf67ef2f180e292be" }, "require": { - "drupal/core": "^8 || ^9" + "drupal/core": "^9.4 || ^10" }, "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-1.0", - "datestamp": "1597688978", + "version": "8.x-1.1", + "datestamp": "1681757575", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index d889cc2ffedc7be5d3ed2cb9609c9e1f95670484..7382acd59dc8e3e7abd45e834763b648ce7c5958 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -7766,27 +7766,27 @@ }, { "name": "drupal/view_unpublished", - "version": "1.0.0", - "version_normalized": "1.0.0.0", + "version": "1.1.0", + "version_normalized": "1.1.0.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/view_unpublished.git", - "reference": "8.x-1.0" + "reference": "8.x-1.1" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/view_unpublished-8.x-1.0.zip", - "reference": "8.x-1.0", - "shasum": "74ebdf1b4f6963f7bb63192bc314014c0132d03c" + "url": "https://ftp.drupal.org/files/projects/view_unpublished-8.x-1.1.zip", + "reference": "8.x-1.1", + "shasum": "f9f5e88cbaf1a1e71952d94cf67ef2f180e292be" }, "require": { - "drupal/core": "^8 || ^9" + "drupal/core": "^9.4 || ^10" }, "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-1.0", - "datestamp": "1597688978", + "version": "8.x-1.1", + "datestamp": "1681757575", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -7815,6 +7815,14 @@ { "name": "entendu", "homepage": "https://www.drupal.org/user/173461" + }, + { + "name": "fathima.asmat", + "homepage": "https://www.drupal.org/user/3622664" + }, + { + "name": "tobiasb", + "homepage": "https://www.drupal.org/user/183956" } ], "description": "Select which roles should be able to see unpublished nodes.", diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index dd96b6833c7f5df3d091179ff3bc9be277f620d3..d3d514e9035c4db43f3ada3ace540f2bee82ca7f 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1238,9 +1238,9 @@ 'dev_requirement' => false, ), 'drupal/view_unpublished' => array( - 'pretty_version' => '1.0.0', - 'version' => '1.0.0.0', - 'reference' => '8.x-1.0', + 'pretty_version' => '1.1.0', + 'version' => '1.1.0.0', + 'reference' => '8.x-1.1', 'type' => 'drupal-module', 'install_path' => __DIR__ . '/../../web/modules/view_unpublished', 'aliases' => array(), diff --git a/web/modules/view_unpublished/composer.json b/web/modules/view_unpublished/composer.json index 53d451f4f441b5e8a386e1927ae2ae99713f241d..fcea783cd4d1004a39b2beb033e9901b55dddaef 100644 --- a/web/modules/view_unpublished/composer.json +++ b/web/modules/view_unpublished/composer.json @@ -1,5 +1,6 @@ { "name": "drupal/view_unpublished", + "type": "drupal-module", "description": "Select which roles should be able to see unpublished nodes.", "license": "GPL-2.0-or-later", "authors": [ diff --git a/web/modules/view_unpublished/src/ViewUnpublishedInstallHelper.php b/web/modules/view_unpublished/src/ViewUnpublishedInstallHelper.php index de63ec48c550596828c92328b6ff6842de5445ee..46d740b9673ac133c9c6bc3d84a27c63220d8f30 100644 --- a/web/modules/view_unpublished/src/ViewUnpublishedInstallHelper.php +++ b/web/modules/view_unpublished/src/ViewUnpublishedInstallHelper.php @@ -7,9 +7,12 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; /** - * Class ViewUnpublishedInstallHelper. + * A helper class used by un-/install hooks. + * + * @see view_unpublished_install + * @see view_unpublished_uninstall */ -class ViewUnpublishedInstallHelper { +final class ViewUnpublishedInstallHelper { /** * Drupal\Core\Config\ConfigFactoryInterface definition. @@ -53,7 +56,11 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Con */ public function flagRebuild() { $query = $this->entityTypeManager->getStorage('node')->getQuery(); - $count_unpublished = (int) $query->condition('status', FALSE)->count()->execute(); + $count_unpublished = (int) $query + ->condition('status', FALSE) + ->accessCheck(FALSE) + ->count() + ->execute(); if ($count_unpublished > 0) { node_access_needs_rebuild(TRUE); } diff --git a/web/modules/view_unpublished/tests/src/Functional/ViewUnpublishedMultilingualTest.php b/web/modules/view_unpublished/tests/src/Functional/ViewUnpublishedMultilingualTest.php index ec79a1cb812a6b13a243645d0785d48da200763b..475d6666afbb56fb710e914d142bff5c7db082b2 100644 --- a/web/modules/view_unpublished/tests/src/Functional/ViewUnpublishedMultilingualTest.php +++ b/web/modules/view_unpublished/tests/src/Functional/ViewUnpublishedMultilingualTest.php @@ -23,7 +23,11 @@ class ViewUnpublishedMultilingualTest extends BrowserTestBase { * * @var array */ - public static $modules = ['view_unpublished', 'node', 'content_translation']; + protected static $modules = [ + 'view_unpublished', + 'node', + 'content_translation', + ]; /** * {@inheritdoc} @@ -40,7 +44,7 @@ class ViewUnpublishedMultilingualTest extends BrowserTestBase { /** * Sets up the test. */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); // Create Basic page node type. @@ -80,7 +84,8 @@ public function testIt() { $edit[$title_key] = $this->randomMachineName(8); $edit[$body_key] = $this->randomMachineName(16); $edit[$status_key] = 1; - $this->drupalPostForm('node/add/page', $edit, $this->t('Save')); + $this->drupalGet('node/add/page'); + $this->submitForm($edit, 'Save'); // Check the node language. $node = $this->getNodeByTitle($edit[$title_key]); @@ -95,7 +100,8 @@ public function testIt() { $this->drupalLogin($this->adminUser); $edit[$body_key] = $this->randomMachineName(16); $edit[$status_key] = 0; - $this->drupalPostForm($node->toUrl('edit-form'), $edit, $this->t('Save')); + $this->drupalGet($node->toUrl('edit-form')); + $this->submitForm($edit, 'Save'); $this->drupalLogout(); $this->drupalGet($node->toUrl()); $this->assertSession()->statusCodeEquals(403); @@ -109,7 +115,8 @@ public function testIt() { $this->drupalLogin($this->adminUser); $edit[$body_key] = $this->randomMachineName(16); $edit[$status_key] = 1; - $this->drupalPostForm($node->toUrl('edit-form'), $edit, $this->t('Save')); + $this->drupalGet($node->toUrl('edit-form')); + $this->submitForm($edit, 'Save'); $this->drupalLogout(); // Anonymous users should have access. @@ -129,7 +136,8 @@ public function testIt() { $edit[$status_key] = 0; // Unpublish the node and now anonymous users should not have access. $edit[$status_key] = 0; - $this->drupalPostForm($add_translation_url, $edit, $this->t('Save (this translation)')); + $this->drupalGet($add_translation_url); + $this->submitForm($edit, 'Save (this translation)'); // Reset the node so we pick up the translation. $node = $this->getNodeByTitle($edit[$title_key], TRUE); $this->drupalLogout(); diff --git a/web/modules/view_unpublished/tests/src/Functional/ViewUnpublishedViewsTest.php b/web/modules/view_unpublished/tests/src/Functional/ViewUnpublishedViewsTest.php index f44640dc2507b24041767a2b44e8902e0f6d4deb..20e550e70705ba05f4fc57711e09f18c59b0402c 100644 --- a/web/modules/view_unpublished/tests/src/Functional/ViewUnpublishedViewsTest.php +++ b/web/modules/view_unpublished/tests/src/Functional/ViewUnpublishedViewsTest.php @@ -19,7 +19,11 @@ class ViewUnpublishedViewsTest extends BrowserTestBase { * * @var array */ - public static $modules = ['view_unpublished', 'node', 'views']; + protected static $modules = [ + 'view_unpublished', + 'node', + 'views', + ]; /** * {@inheritdoc} @@ -29,7 +33,7 @@ class ViewUnpublishedViewsTest extends BrowserTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); // Rebuild node access which we have to do after installing the module. @@ -52,12 +56,18 @@ public function testIt() { $article_node->setUnPublished(); $article_node->save(); - $this->drupalLogin($this->createUser(['view any unpublished content', 'access content overview'])); + $this->drupalLogin($this->createUser([ + 'view any unpublished content', + 'access content overview', + ])); $this->drupalGet('admin/content'); $this->assertSession()->pageTextContains($page_node->label()); $this->assertSession()->pageTextContains($article_node->label()); - $this->drupalLogin($this->createUser(['view any unpublished page content', 'access content overview'])); + $this->drupalLogin($this->createUser([ + 'view any unpublished page content', + 'access content overview', + ])); $this->drupalGet('admin/content'); $this->assertSession()->pageTextContains($page_node->label()); $this->assertSession()->pageTextNotContains($article_node->label()); diff --git a/web/modules/view_unpublished/tests/src/Kernel/ViewUnpublishedDependencyTest.php b/web/modules/view_unpublished/tests/src/Kernel/ViewUnpublishedDependencyTest.php index b43938a72257a0a646238bb5fa6200f55000b404..f480ad0d2cd5c59c7334466733dc4e6b5e699247 100644 --- a/web/modules/view_unpublished/tests/src/Kernel/ViewUnpublishedDependencyTest.php +++ b/web/modules/view_unpublished/tests/src/Kernel/ViewUnpublishedDependencyTest.php @@ -17,7 +17,7 @@ class ViewUnpublishedDependencyTest extends KernelTestBase { * * @var array */ - public static $modules = [ + protected static $modules = [ 'field', 'node', 'system', @@ -30,7 +30,7 @@ class ViewUnpublishedDependencyTest extends KernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installEntitySchema('user'); diff --git a/web/modules/view_unpublished/view_unpublished.info.yml b/web/modules/view_unpublished/view_unpublished.info.yml index 1fc12ba4cb5871e33065a66a39c2f71c47be8c25..67a62a09a1f424c728f3622909db78524eef5c63 100644 --- a/web/modules/view_unpublished/view_unpublished.info.yml +++ b/web/modules/view_unpublished/view_unpublished.info.yml @@ -1,13 +1,12 @@ name: 'View Unpublished' description: 'Select which roles should be able to see unpublished nodes.' package: Permissions -core: 8.x -core_version_requirement: ^8 || ^9 +core_version_requirement: ^9.4 || ^10 type: module dependencies: - drupal:node -# Information added by Drupal.org packaging script on 2020-08-17 -version: '8.x-1.0' +# Information added by Drupal.org packaging script on 2023-04-17 +version: '8.x-1.1' project: 'view_unpublished' -datestamp: 1597688980 +datestamp: 1681757576