From a134b884071d7e2b9516e2a2a7aeca375ad6ef1f Mon Sep 17 00:00:00 2001 From: Brian Weaver <weaver.299@osu.edu> Date: Fri, 25 Jun 2021 07:31:59 -0400 Subject: [PATCH] Update core book module patch --- composer.json | 4 +- composer.lock | 2 +- vendor/composer/InstalledVersions.php | 4 +- vendor/composer/autoload_files.php | 8 +- vendor/composer/autoload_psr4.php | 2 +- vendor/composer/autoload_static.php | 12 +-- vendor/composer/installed.json | 1 + vendor/composer/installed.php | 4 +- web/core/PATCHES.txt | 2 +- web/core/modules/book/src/BookManager.php | 4 +- .../book/tests/src/Unit/BookManagerTest.php | 67 +++++++++++++-- .../tests/src/Unit/BookManagerTest.php.rej | 86 ------------------- 12 files changed, 82 insertions(+), 114 deletions(-) delete mode 100644 web/core/modules/book/tests/src/Unit/BookManagerTest.php.rej diff --git a/composer.json b/composer.json index df58977dfe..cacba619ae 100644 --- a/composer.json +++ b/composer.json @@ -257,7 +257,7 @@ "patches": { "drupal/core": { "2799049": "patches/role_based_email_access-2799049-d87.patch", - "2862291": "https://www.drupal.org/files/issues/2020-12-08/2862291-29.patch", + "2862291": "https://www.drupal.org/files/issues/2021-01-11/2862291-34.patch", "2949017": "https://www.drupal.org/files/issues/2019-12-12/2949017-59.patch" }, "drupal/addtocalendar": { @@ -297,4 +297,4 @@ "php": "7.3" } } -} +} \ No newline at end of file diff --git a/composer.lock b/composer.lock index cc9591119c..ea098a6d52 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1c30f4cf668eb053253a08a9877fd491", + "content-hash": "5e913ecc2674d50863351c9eb0543bd0", "packages": [ { "name": "alchemy/zippy", diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php index 12e365408d..65b8bbf59b 100644 --- a/vendor/composer/InstalledVersions.php +++ b/vendor/composer/InstalledVersions.php @@ -32,7 +32,7 @@ class InstalledVersions 'aliases' => array ( ), - 'reference' => 'da50bfb3a6bb9b6e96f2cffb2c0236a3e5e37a82', + 'reference' => '44d42d547d363bbf388a60a73f91adfd1aced20b', 'name' => 'osu-asc-webservices/d8-upstream', ), 'versions' => @@ -2228,7 +2228,7 @@ class InstalledVersions 'aliases' => array ( ), - 'reference' => 'da50bfb3a6bb9b6e96f2cffb2c0236a3e5e37a82', + 'reference' => '44d42d547d363bbf388a60a73f91adfd1aced20b', ), 'pantheon-systems/quicksilver-pushback' => array ( diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index 14f9b4807f..a032efc74b 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -9,18 +9,17 @@ '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php', '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php', + '0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php', + '23c18046f52bef3eea034657bafda50f' => $vendorDir . '/symfony/polyfill-php81/bootstrap.php', 'e69f7f6ee287b969198c3c9d6777bd38' => $vendorDir . '/symfony/polyfill-intl-normalizer/bootstrap.php', '25072dd6e2470089de65ae7bf11d3109' => $vendorDir . '/symfony/polyfill-php72/bootstrap.php', 'f598d06aa772fa33d905e87be6398fb1' => $vendorDir . '/symfony/polyfill-intl-idn/bootstrap.php', - '0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php', '6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php', - '23c18046f52bef3eea034657bafda50f' => $vendorDir . '/symfony/polyfill-php81/bootstrap.php', '7e9bd612cc444b3eed788ebbe46263a0' => $vendorDir . '/laminas/laminas-zendframework-bridge/src/autoload.php', '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php', - 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php', 'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php', + 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php', '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php', - 'def43f6c87e4f8dfd0c9e1b1bab14fe8' => $vendorDir . '/symfony/polyfill-iconv/bootstrap.php', '07d7f1a47144818725fd8d91a907ac57' => $vendorDir . '/laminas/laminas-diactoros/src/functions/create_uploaded_file.php', 'da94ac5d3ca7d2dbab84ce561ce72bfd' => $vendorDir . '/laminas/laminas-diactoros/src/functions/marshal_headers_from_sapi.php', '3d97c8dcdfba8cb85d3b34f116bb248b' => $vendorDir . '/laminas/laminas-diactoros/src/functions/marshal_method_from_sapi.php', @@ -37,6 +36,7 @@ 'cc8e14526dc240491e17a838cb78508c' => $vendorDir . '/laminas/laminas-diactoros/src/functions/normalize_server.legacy.php', '786bf90caabc9e09b6ad4cc5ca8f0e30' => $vendorDir . '/laminas/laminas-diactoros/src/functions/normalize_uploaded_files.legacy.php', '751a5a3f463e4be759be31748b61737c' => $vendorDir . '/laminas/laminas-diactoros/src/functions/parse_cookie_header.legacy.php', + 'def43f6c87e4f8dfd0c9e1b1bab14fe8' => $vendorDir . '/symfony/polyfill-iconv/bootstrap.php', '2f69d3914119f042cca9e44442d5ce95' => $baseDir . '/web/core/includes/bootstrap.inc', '5abda994d126976858eb25d2546ee3c9' => $vendorDir . '/simplesamlphp/simplesamlphp/lib/_autoload_modules.php', '667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php', diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index a648c2fbc6..55b590214f 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -83,7 +83,7 @@ 'ReCaptcha\\' => array($vendorDir . '/google/recaptcha/src/ReCaptcha'), 'Psy\\' => array($vendorDir . '/psy/psysh/src'), 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'), - 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src', $vendorDir . '/psr/http-factory/src'), + 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'), 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), 'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'), 'PhpParser\\' => array($vendorDir . '/nikic/php-parser/lib/PhpParser'), diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 772a44b891..4ef63c3eaf 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -10,18 +10,17 @@ class ComposerStaticInit5c689ffcd54b9e495ed983fdce09b530 '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', + '0d59ee240a4cd96ddbb4ff164fccea4d' => __DIR__ . '/..' . '/symfony/polyfill-php73/bootstrap.php', + '23c18046f52bef3eea034657bafda50f' => __DIR__ . '/..' . '/symfony/polyfill-php81/bootstrap.php', 'e69f7f6ee287b969198c3c9d6777bd38' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/bootstrap.php', '25072dd6e2470089de65ae7bf11d3109' => __DIR__ . '/..' . '/symfony/polyfill-php72/bootstrap.php', 'f598d06aa772fa33d905e87be6398fb1' => __DIR__ . '/..' . '/symfony/polyfill-intl-idn/bootstrap.php', - '0d59ee240a4cd96ddbb4ff164fccea4d' => __DIR__ . '/..' . '/symfony/polyfill-php73/bootstrap.php', '6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php', - '23c18046f52bef3eea034657bafda50f' => __DIR__ . '/..' . '/symfony/polyfill-php81/bootstrap.php', '7e9bd612cc444b3eed788ebbe46263a0' => __DIR__ . '/..' . '/laminas/laminas-zendframework-bridge/src/autoload.php', '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php', - 'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php', 'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php', + 'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php', '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php', - 'def43f6c87e4f8dfd0c9e1b1bab14fe8' => __DIR__ . '/..' . '/symfony/polyfill-iconv/bootstrap.php', '07d7f1a47144818725fd8d91a907ac57' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/create_uploaded_file.php', 'da94ac5d3ca7d2dbab84ce561ce72bfd' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/marshal_headers_from_sapi.php', '3d97c8dcdfba8cb85d3b34f116bb248b' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/marshal_method_from_sapi.php', @@ -38,6 +37,7 @@ class ComposerStaticInit5c689ffcd54b9e495ed983fdce09b530 'cc8e14526dc240491e17a838cb78508c' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/normalize_server.legacy.php', '786bf90caabc9e09b6ad4cc5ca8f0e30' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/normalize_uploaded_files.legacy.php', '751a5a3f463e4be759be31748b61737c' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/parse_cookie_header.legacy.php', + 'def43f6c87e4f8dfd0c9e1b1bab14fe8' => __DIR__ . '/..' . '/symfony/polyfill-iconv/bootstrap.php', '2f69d3914119f042cca9e44442d5ce95' => __DIR__ . '/../..' . '/web/core/includes/bootstrap.inc', '5abda994d126976858eb25d2546ee3c9' => __DIR__ . '/..' . '/simplesamlphp/simplesamlphp/lib/_autoload_modules.php', '667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php', @@ -537,8 +537,8 @@ class ComposerStaticInit5c689ffcd54b9e495ed983fdce09b530 ), 'Psr\\Http\\Message\\' => array ( - 0 => __DIR__ . '/..' . '/psr/http-message/src', - 1 => __DIR__ . '/..' . '/psr/http-factory/src', + 0 => __DIR__ . '/..' . '/psr/http-factory/src', + 1 => __DIR__ . '/..' . '/psr/http-message/src', ), 'Psr\\Container\\' => array ( diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 83cf21e3c6..934d826f39 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -3238,6 +3238,7 @@ } }, "patches_applied": { + "2862291": "https://www.drupal.org/files/issues/2021-01-11/2862291-34.patch", "2949017": "https://www.drupal.org/files/issues/2019-12-12/2949017-59.patch" } }, diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 33b6344d7d..c3040560cb 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -6,7 +6,7 @@ 'aliases' => array ( ), - 'reference' => 'da50bfb3a6bb9b6e96f2cffb2c0236a3e5e37a82', + 'reference' => '44d42d547d363bbf388a60a73f91adfd1aced20b', 'name' => 'osu-asc-webservices/d8-upstream', ), 'versions' => @@ -2202,7 +2202,7 @@ 'aliases' => array ( ), - 'reference' => 'da50bfb3a6bb9b6e96f2cffb2c0236a3e5e37a82', + 'reference' => '44d42d547d363bbf388a60a73f91adfd1aced20b', ), 'pantheon-systems/quicksilver-pushback' => array ( diff --git a/web/core/PATCHES.txt b/web/core/PATCHES.txt index 19c8c45be3..c514a92338 100644 --- a/web/core/PATCHES.txt +++ b/web/core/PATCHES.txt @@ -6,7 +6,7 @@ Source: patches/role_based_email_access-2799049-d87.patch 2862291 -Source: https://www.drupal.org/files/issues/2020-12-08/2862291-29.patch +Source: https://www.drupal.org/files/issues/2021-01-11/2862291-34.patch 2949017 diff --git a/web/core/modules/book/src/BookManager.php b/web/core/modules/book/src/BookManager.php index f338638b7c..a79d7c2db8 100644 --- a/web/core/modules/book/src/BookManager.php +++ b/web/core/modules/book/src/BookManager.php @@ -261,8 +261,8 @@ public function addFormElements(array $form, FormStateInterface $form_state, Nod } if (!$node->book['bid'] || $nid === 'new' || $node->book['original_bid'] === 0) { // The node is not currently in the hierarchy. - $options = [0 => $this->t('- None -')] + $options; - } + $options = [0 => $this->t('- None -')] + $options; + } // Add a drop-down to select the destination book. $form['book']['bid'] = [ diff --git a/web/core/modules/book/tests/src/Unit/BookManagerTest.php b/web/core/modules/book/tests/src/Unit/BookManagerTest.php index 3eb9b36920..8f773ca2b9 100644 --- a/web/core/modules/book/tests/src/Unit/BookManagerTest.php +++ b/web/core/modules/book/tests/src/Unit/BookManagerTest.php @@ -69,15 +69,68 @@ class BookManagerTest extends UnitTestCase { */ protected $bookOutlineStorage; + /** + * The mocked form state. + * + * @var \Drupal\Core\Form\FormState + */ + protected $form_state; + + /** + * The mocked node Interface. + * + * @var \Drupal\node\NodeInterface + */ + protected $node; + + /** + * The mocked User. + * + * @var \Drupal\user\Entity\User + */ + protected $account; + /** * {@inheritdoc} */ protected function setUp(): void { $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class); + $book_id = [ + 'nid' => 'new', + 'has_children' => 0, + 'original_bid' => 0, + 'parent_depth_limit' => 0, + 'bid' => 0, + 'pid' => 0, + 'weight' => 0, + 'parent_depth_limit' => 8, + 'options' => [], + ]; + $this->form_state = $this->getMockBuilder('Drupal\Core\Form\FormState') + ->disableOriginalConstructor()->disableOriginalConstructor() + ->setMethods(['hasValue', 'getValue'])->getMock(); + $this->form_state->expects($this->any()) + ->method('getValue') + ->willReturn($book_id); + $this->node = $this->getMockBuilder('Drupal\node\NodeInterface') + ->disableOriginalConstructor()->getMock(); + $this->node->book = $book_id; + $this->account = $this->getMockBuilder('Drupal\user\Entity\User') + ->disableOriginalConstructor()->getMock(); $this->translation = $this->getStringTranslationStub(); - $this->configFactory = $this->getConfigFactoryStub([]); + $config = [ + 'book.settings' => [ + 'allowed_types' => [ + 'page', + ], + ], + ]; + $this->configFactory = $this->getConfigFactoryStub($config); $this->bookOutlineStorage = $this->createMock('Drupal\book\BookOutlineStorageInterface'); $this->renderer = $this->createMock('\Drupal\Core\Render\RendererInterface'); + $container = new ContainerBuilder(); + $container->set('config.factory', $this->configFactory); + \Drupal::setContainer($container); $this->languageManager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface'); $this->entityRepository = $this->createMock('Drupal\Core\Entity\EntityRepositoryInterface'); $this->bookManager = new BookManager($this->entityTypeManager, $this->translation, $this->configFactory, $this->bookOutlineStorage, $this->renderer, $this->languageManager, $this->entityRepository); @@ -141,21 +194,21 @@ public function testAddFormElementsNodeAddWithBook() { $this->node->expects($this->any()) ->method('getType') ->willReturn('page'); - $addform = $this->bookManager->addFormElements($form, $this->form_state, $this->node, $this->account); - $this->assertArrayHasKey('book', $addform); + $add_form = $this->bookManager->addFormElements($form, $this->form_state, $this->node, $this->account); + $this->assertArrayHasKey('book', $add_form); } /** * Testing the Book Outline form element in node add article form. - * When the Book setting is not enabled for the Content Type 'Article' + * When the Book setting is not enabled for the Content Type 'Article'. */ public function testAddFormElementsNodeAddWithoutBook() { $form = []; $this->node->expects($this->any()) ->method('getType') - ->willReturn('artilce'); - $addform = $this->bookManager->addFormElements($form, $this->form_state, $this->node, $this->account); - $this->assertArrayNotHasKey('book', $addform); + ->willReturn('article'); + $add_form = $this->bookManager->addFormElements($form, $this->form_state, $this->node, $this->account); + $this->assertArrayNotHasKey('book', $form); } } diff --git a/web/core/modules/book/tests/src/Unit/BookManagerTest.php.rej b/web/core/modules/book/tests/src/Unit/BookManagerTest.php.rej deleted file mode 100644 index 7996626bba..0000000000 --- a/web/core/modules/book/tests/src/Unit/BookManagerTest.php.rej +++ /dev/null @@ -1,86 +0,0 @@ -*************** -*** 54,68 **** - */ - protected $bookOutlineStorage; - - /** - * {@inheritdoc} - */ - protected function setUp() { - $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class); - $this->translation = $this->getStringTranslationStub(); -- $this->configFactory = $this->getConfigFactoryStub([]); - $this->bookOutlineStorage = $this->createMock('Drupal\book\BookOutlineStorageInterface'); - $this->renderer = $this->createMock('\Drupal\Core\Render\RendererInterface'); - $this->bookManager = new BookManager($this->entityTypeManager, $this->translation, $this->configFactory, $this->bookOutlineStorage, $this->renderer); - } - ---- 55,122 ---- - */ - protected $bookOutlineStorage; - -+ /** -+ * The mocked form state -+ * -+ * @var \Drupal\Core\Form\FormState -+ */ -+ protected $form_state; -+ -+ /** -+ * The mocked node Interface. -+ * -+ * @var \Drupal\node\NodeInterface -+ */ -+ protected $node; -+ -+ /** -+ * The mocked User -+ * -+ * @var \Drupal\user\Entity\User -+ */ -+ protected $account; -+ - /** - * {@inheritdoc} - */ - protected function setUp() { - $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class); -+ $book_id = [ -+ 'nid' => 'new', -+ 'has_children' => 0, -+ 'original_bid' => 0, -+ 'parent_depth_limit' => 0, -+ 'bid' => 0, -+ 'pid' => 0, -+ 'weight' => 0, -+ 'parent_depth_limit' => 8, -+ 'options' => [], -+ ]; -+ $this->form_state = $this->getMockBuilder('Drupal\Core\Form\FormState') -+ ->disableOriginalConstructor()->disableOriginalConstructor() -+ ->setMethods(['hasValue', 'getValue'])->getMock(); -+ $this->form_state->expects($this->any()) -+ ->method('getValue') -+ ->willReturn($book_id); -+ $this->node = $this->getMockBuilder('Drupal\node\NodeInterface') -+ ->disableOriginalConstructor()->getMock(); -+ $this->node->book = $book_id; -+ $this->account = $this->getMockBuilder('Drupal\user\Entity\User') -+ ->disableOriginalConstructor()->getMock(); - $this->translation = $this->getStringTranslationStub(); -+ $config = [ -+ 'book.settings' => [ -+ 'allowed_types' => [ -+ 'page' -+ ] -+ ] -+ ]; -+ $this->configFactory = $this->getConfigFactoryStub($config); - $this->bookOutlineStorage = $this->createMock('Drupal\book\BookOutlineStorageInterface'); - $this->renderer = $this->createMock('\Drupal\Core\Render\RendererInterface'); -+ $container = new ContainerBuilder(); -+ $container->set('config.factory', $this->configFactory); -+ \Drupal::setContainer($container); - $this->bookManager = new BookManager($this->entityTypeManager, $this->translation, $this->configFactory, $this->bookOutlineStorage, $this->renderer); - } - -- GitLab