Unverified Commit 4cea777d authored by larowlan's avatar larowlan
Browse files

Issue #3106659 by phenaproxima, aleevas, rajanvalecha12, Drupaldev2013,...

Issue #3106659 by phenaproxima, aleevas, rajanvalecha12, Drupaldev2013, audacus, mulukallaarun, Kristen Pol, dpi: Media types with missing source fields break the status report page

(cherry picked from commit b2686e3d)
parent 74f21c45
......@@ -135,7 +135,7 @@ function media_requirements($phase) {
->getViewDisplay('media', $type->id());
$source_field_definition = $type->getSource()->getSourceFieldDefinition($type);
if (!is_a($source_field_definition->getItemDefinition()->getClass(), ImageItem::class, TRUE)) {
if (empty($source_field_definition) || !is_a($source_field_definition->getItemDefinition()->getClass(), ImageItem::class, TRUE)) {
continue;
}
......
<?php
namespace Drupal\Tests\media\Functional;
/**
* Tests the Media module's requirements checks.
*
* @group media
*/
class MediaRequirementsTest extends MediaFunctionalTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests that the requirements check can handle a missing source field.
*/
public function testMissingSourceFieldDefinition() {
$media_type = $this->createMediaType('test');
/** @var \Drupal\field\FieldConfigInterface $field_definition */
$field_definition = $media_type->getSource()
->getSourceFieldDefinition($media_type);
/** @var \Drupal\field\FieldStorageConfigInterface $field_storage_definition */
$field_storage_definition = $field_definition->getFieldStorageDefinition();
$field_definition->delete();
$field_storage_definition->delete();
$this->drupalLogin($this->rootUser);
$this->drupalGet('/admin/reports/status');
$this->assertSession()->statusCodeEquals(200);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment