Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 296347

Saving media entity without an owner crashes

$
0
0

Problem/Motivation

The uid field on media entities is not set to required, but the database field is set to NOT NULL.

To reproduce:

- go to /media/add/image
- fill in the required form elements
- delete the contents of the Authored by form element
- save the form

The site crashes with a storage exception because the uid database field may not be NULL.

Steps to reproduce

Proposed resolution

Ideally, deal with #3260173: EntityOwnerTrait does not define the owner field as required, but the DB field is NOT NULL so it's fixed for all entities.

As an interim, copy the code from Node::preSave() to Media::preSave():

      // If no owner has been set explicitly, make the anonymous user the owner.
      if (!$translation->getOwner()) {
        $translation->setOwnerId(0);
      }
    }

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 296347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>