diff -u b/core/modules/media/media.module b/core/modules/media/media.module --- b/core/modules/media/media.module +++ b/core/modules/media/media.module @@ -52,7 +52,7 @@ * * Fix broken operations array in field UI for entities with restricted access. * - * @todo: This hook can be removed when issue 2836384 is fixed. + * @todo This hook can be removed when issue #2836384 is done. * @see https://www.drupal.org/node/2836384 */ function media_entity_operation_alter(array &$operations, EntityInterface $entity) { diff -u b/core/modules/media/src/Entity/Media.php b/core/modules/media/src/Entity/Media.php --- b/core/modules/media/src/Entity/Media.php +++ b/core/modules/media/src/Entity/Media.php @@ -17,7 +17,7 @@ /** * Defines the media entity class. * - * @todo Remove default/fallback entity form operation when #2006348 lands. + * @todo Remove default/fallback entity form operation when #2006348 is done. * @see https://www.drupal.org/node/2006348. * * @ContentEntityType( diff -u b/core/modules/media/src/Form/MediaDeleteMultipleConfirmForm.php b/core/modules/media/src/Form/MediaDeleteMultipleConfirmForm.php --- b/core/modules/media/src/Form/MediaDeleteMultipleConfirmForm.php +++ b/core/modules/media/src/Form/MediaDeleteMultipleConfirmForm.php @@ -92,7 +92,7 @@ /** * {@inheritdoc} * - * @todo: Change to trait or base class when #2843395 is done. + * @todo Change to trait or base class when #2843395 is done. * @see https://www.drupal.org/node/2843395 */ public function buildForm(array $form, FormStateInterface $form_state) { @@ -145,7 +145,7 @@ /** * {@inheritdoc} * - * @todo: Change to trait or base class when #2843395 is done. + * @todo Change to trait or base class when #2843395 is done. * @see https://www.drupal.org/node/2843395 */ public function submitForm(array &$form, FormStateInterface $form_state) { diff -u b/core/modules/media/src/MediaInterface.php b/core/modules/media/src/MediaInterface.php --- b/core/modules/media/src/MediaInterface.php +++ b/core/modules/media/src/MediaInterface.php @@ -16,7 +16,7 @@ /** * Returns the media item creation timestamp. * - * @todo Remove and use the new interface when #2006348 lands. + * @todo Remove and use the new interface when #2833378 is done. * @see https://www.drupal.org/node/2833378 * * @return int @@ -27,7 +27,7 @@ /** * Sets the media item creation timestamp. * - * @todo Remove and use the new interface when #2006348 lands. + * @todo Remove and use the new interface when #2833378 is done. * @see https://www.drupal.org/node/2833378 * * @param int $timestamp diff -u b/core/modules/media/src/MediaSourceInterface.php b/core/modules/media/src/MediaSourceInterface.php --- b/core/modules/media/src/MediaSourceInterface.php +++ b/core/modules/media/src/MediaSourceInterface.php @@ -44,8 +44,8 @@ * URL or other identifier, while sources that represent local files might * check the MIME type of the file. * - Providing a default name for a media item. This will save users from - * manually entering the name when it can be reliably set automatically. Media - * sources for local files will generally use the filename, while media + * manually entering the name when it can be reliably set automatically. + * Media sources for local files will generally use the filename, while media * sources for remote resources might obtain a title attribute through a * third-party API. The name can always be overridden by the user. * - Providing metadata specific to the given media type. For example, remote diff -u b/core/modules/media/src/MediaTypeForm.php b/core/modules/media/src/MediaTypeForm.php --- b/core/modules/media/src/MediaTypeForm.php +++ b/core/modules/media/src/MediaTypeForm.php @@ -313,8 +313,9 @@ // If the media source is using a source field, ensure it's // properly created. $source = $media_type->getSource(); - $source_field = $source->getSourceFieldDefinition($media_type) ?: $source->createSourceField($media_type); + $source_field = $source->getSourceFieldDefinition($media_type); if (!$source_field) { + $source_field = $source->createSourceField($media_type); /** @var \Drupal\field\FieldStorageConfigInterface $storage */ $storage = $source_field->getFieldStorageDefinition(); if ($storage->isNew() || !$storage->isLocked()) { diff -u b/core/modules/media/src/Plugin/Action/PublishMedia.php b/core/modules/media/src/Plugin/Action/PublishMedia.php --- b/core/modules/media/src/Plugin/Action/PublishMedia.php +++ b/core/modules/media/src/Plugin/Action/PublishMedia.php @@ -31,8 +31,10 @@ */ public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) { /** @var \Drupal\media\MediaInterface $object */ - return $object->access('update', $account, $return_as_object) - ->andIf($object->status->access('update', $account, $return_as_object)); + $result = $object->access('update', $account, TRUE) + ->andIf($object->status->access('update', $account, TRUE)); + + return $return_as_object ? $result : $result->isAllowed(); } } diff -u b/core/modules/media/src/Plugin/Action/UnpublishMedia.php b/core/modules/media/src/Plugin/Action/UnpublishMedia.php --- b/core/modules/media/src/Plugin/Action/UnpublishMedia.php +++ b/core/modules/media/src/Plugin/Action/UnpublishMedia.php @@ -31,8 +31,10 @@ */ public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) { /** @var \Drupal\media\MediaInterface $object */ - return $object->access('update', $account, $return_as_object) - ->andIf($object->status->access('update', $account, $return_as_object)); + $result = $object->access('update', $account, TRUE) + ->andIf($object->status->access('update', $account, TRUE)); + + return $return_as_object ? $result : $result->isAllowed(); } } diff -u b/core/modules/media/tests/src/Functional/MediaFunctionalTestCreateMediaTypeTrait.php b/core/modules/media/tests/src/Functional/MediaFunctionalTestCreateMediaTypeTrait.php --- b/core/modules/media/tests/src/Functional/MediaFunctionalTestCreateMediaTypeTrait.php +++ b/core/modules/media/tests/src/Functional/MediaFunctionalTestCreateMediaTypeTrait.php @@ -40,7 +40,9 @@ $media_type = MediaType::create($values); $status = $media_type->save(); - $this->assertSame(SAVED_NEW, $status, 'Media type was created successfully.'); + // @todo Rename to assertSame() when #1945040 is done. + // @see https://www.drupal.org/node/1945040 + $this->assertIdentical(SAVED_NEW, $status, 'Media type was created successfully.'); // Ensure that the source field exists. $source = $media_type->getSource(); diff -u b/core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php b/core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php --- b/core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php +++ b/core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php @@ -73,6 +73,10 @@ $media_name = $this->randomMachineName(); $page->fillField('name[0][value]', $media_name2); $page->pressButton('Save and keep published'); + /** @var \Drupal\media\MediaInterface $media */ + $media = $this->container->get('entity_type.manager') + ->getStorage('media') + ->loadUnchanged($media_id); $this->assertEquals($media->label(), $media_name2); $assert_session->titleEquals($media_name2 . ' | Drupal');