Similar to #2289603: "Cannot define PRIMARY KEY constraint on nullable column in table file_metadata", I was updating from Media v1 to v2-dev on a site running against SQL Server, when the following errors arose while running the database updates:

Notice: Undefined property: stdClass::$streams in media_update_7208() (line 859 of media/media.install).
array_merge(): Argument #2 is not an array media.install:846           [warning]
array_merge(): Argument #2 is not an array media.install:846           [warning]
array_merge(): Argument #2 is not an array media.install:846           [warning]
Performed update: media_update_7208                                         [ok]
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

antondavidsen’s picture

If the $new_type->streams is empty or not an array, array_merge() will throw an error. A patch against revision fe09f096029e7c495f0023afd7192aa081f0e080 is supplied.

// Merge existing type with new ones.
if ($new_type = file_type_load($type->name)) {
  $new_type->mimetypes = array_merge($type->mimetypes, $new_type->mimetypes);
   if (is_array($new_type->streams)) {
     $new_type->streams = array_merge($type->streams, $new_type->streams);
   }
}
Devin Carlson’s picture

Status: Active » Needs review
jwilson3’s picture

Issue summary: View changes

In addition to the "Argument #2 is not an array media.install" error, I'm also getting another error message related to this issue:

Notice: Undefined property: stdClass::$streams in media_update_7208() (line 859 of media/media.install).
Warning: array_merge(): Argument #2 is not an array in media_update_7208() (line 859 of media/media.install).

I'm currently testing patch in #1 and will report back...

Chris Matthews’s picture

Status: Needs review » Closed (outdated)
Issue tags: +Needs reroll

The 4 year old patch in #1 to media.install does not apply to the latest media 7.x-2.x-dev and per joseph.olstad's closing as outdated. However, if you still need this and want it reviewed, feel free to submit a re-rolled patch and he will consider re-opening.

Checking patch media.install...
error: while searching for:
      // Merge existing type with new ones.
      if ($new_type = file_type_load($type->name)) {
        $new_type->mimetypes = array_merge($type->mimetypes, $new_type->mimetypes);
        $new_type->streams = array_merge($type->streams, $new_type->streams);
      }
      else {
        $new_type = $type;

error: patch failed: media.install:856
error: media.install: patch does not apply