TypeError: array_merge(): Argument #2 must be of type array, null given in array_merge() (line 324 of modules/contrib/drowl_paragraphs/modules/drowl_paragraphs_types/drowl_paragraphs_types.module).

Created on 8 July 2022, over 2 years ago
Updated 17 October 2023, over 1 year ago

Problem/Motivation

On fresh installations, drowl_paragraphs doesn't have a default value for its /admin/config/system/drowl-paragraphs => breakpoint matching setting.

So this:

$drowl_paragraphs_breakpoint_mapping_sizes = $drowl_paragraphs_config->get('breakpoint_mapping_sizes');

will return NULL, as a result, this returns this error:

        $drowl_paragraphs_breakpoint_mapping_sizes = array_merge($drowl_paragraphs_breakpoint_mapping_sizes_fallbacks, $drowl_paragraphs_breakpoint_mapping_sizes);

Proposed resolution

Two things:
1) Check $drowl_paragraphs_breakpoint_mapping_sizes for empty
2) Set a default breakpoint-group? We recently discussed this for drowl_media I guess, so maybe drowl_paragraphs also need to define its own breakpoint group to have a reliable default.

🐛 Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany Anybody Porta Westfalica

    Hoply crap!

    breakpoint_mapping_sizes is entirely missing in the settings form and for most parts in the config, but still queried in the PHP code at various places.

    I'll take a look where and why we removed this (intentionally or not ;))

  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica

    Okay, here's the reason: There's no form input, we're calculating these values when submitting the form!

    The code was written 5 years ago 😂
    https://git.drupalcode.org/project/drowl_paragraphs/-/commit/d8b7e43df4a...

    I think we need to call it in an update hook unce to recalculate the breakpoint mapping sizes without needing to resave the form everywhere.
    So copy and align this code in an update hook:

        $breakpoint_mapping = !empty($form_values['breakpoints']['breakpoint_mapping']) ? $form_values['breakpoints']['breakpoint_mapping'] : [];
        // Calculate min / max for breakpoints.
        $breakpoint_mapping_sizes = [];
        if (!empty($breakpoint_mapping)) {
          $breakpoint_mapping_sizes = self::breakpointMappingToDeviceSizes($breakpoint_mapping);
        }
    
  • Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.0 & MySQL 5.7
    last update over 1 year ago
    Waiting for branch to pass
  • @anybody opened merge request.
  • Issue was unassigned.
  • Status changed to Fixed over 1 year ago
  • 🇩🇪Germany Anybody Porta Westfalica

    Implemented the update hook.

  • Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.0 & MySQL 5.7
    last update over 1 year ago
    Waiting for branch to pass
    • Anybody committed cee5e6e5 on 4.x
      Issue #3294972 by Anybody, thomas.frobieter: TypeError: array_merge():...
  • Assigned to thomas.frobieter
  • Status changed to Needs work over 1 year ago
  • 🇩🇪Germany Anybody Porta Westfalica

    Ah sorry back to NW!

    We need to add reasonable defaults for sm, md, lg in the drowl_paragraphs.settings.yml! Currently it's just:

    breakpoint_mapping_sizes:
      sm:
        max-width:
          mediaQuery: 'all and (min-width: 1921px)'
          type: max-width
          size: 99999999
          unit: px
        min-width:
          mediaQuery: 'all and (max-width: 640px)'
          type: min-width
          size: 0
          unit: px
    

    missing sm and md. Furthermore, the current values should be checked, I guess?

  • 🇩🇪Germany Anybody Porta Westfalica

    Ok it works, here we go:

    sm:
        max-width:
          mediaQuery: 'all and (max-width: 640px)'
          type: max-width
          size: 640
          unit: px
        min-width:
          mediaQuery: 'all and (max-width: 640px)'
          type: min-width
          size: 0
          unit: px
      md:
        max-width:
          mediaQuery: 'all and (min-width: 641px) and (max-width: 1024px)'
          type: max-width
          size: 1024
          unit: px
        min-width:
          mediaQuery: 'all and (min-width: 641px) and (max-width: 1024px)'
          type: min-width
          size: '641'
          unit: px
      lg:
        max-width:
          mediaQuery: 'all and (min-width: 1921px)'
          type: max-width
          size: 99999999
          unit: px
        min-width:
          mediaQuery: 'all and (min-width: 1025px) and (max-width: 1366px)'
          type: min-width
          size: '1025'
          unit: px
    
  • 🇩🇪Germany Anybody Porta Westfalica
  • Issue was unassigned.
  • Status changed to Fixed over 1 year ago
    • Anybody committed 85e0e920 on 4.x
      Issue #3294972 by Anybody, thomas.frobieter: TypeError: array_merge():...
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024