strnatcasecmp(): Passing null to parameter #1 ($string) of type string is deprecated

Created on 21 October 2022, over 1 year ago
Updated 1 November 2023, 8 months ago

Passing null to parameter #1 ($string) of type string is deprecated.

strnatcasecmp deprecated warning temporary fix with this patch.

๐Ÿ› Bug report
Status

Closed: duplicate

Version

11.0 ๐Ÿ”ฅ

Component
Pluginย  โ†’

Last updated 8 days ago

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia dipanjan.kundu

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.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Since there hasn't been a follow up going to close for now.

    If still a valid bug please reopen adding steps to reproduce. Will have to determine what has a NULL lable though per #8.

    Thanks all!

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Anybody Porta Westfalica

    More or less happy to be able to add the missing information here. At least in my case it's the layout_builder_blank layout causing this.

    These are the values it has

    layout_builder_blank => Drupal\Core\Layout\LayoutDefinition#1237 (19)
            Properties (19)
            protected id -> string (20) "layout_builder_blank"
            protected class -> string (47) "Drupal\layout_builder\Plugin\Layout\BlankLayout"
            protected provider -> string (14) "layout_builder"
            protected deriver -> null
            protected label -> null
            protected description -> null
            protected category -> null
            protected template -> null
            protected templatePath -> null
            protected theme_hook -> string (6) "layout"
            โง‰protected path -> string (27) "core/modules/layout_builder"
            protected library -> null
            protected icon -> null
            protected icon_map -> null
            protected regions -> array (0)
            protected default_region -> null
            protected additional -> array (0)
            protected contextDefinitions -> array (0)
            protected config_dependencies -> array (0)

    within the getSortedDefinitions() function in LayoutPluginManager.php:

      /**
       * {@inheritdoc}
       *
       * @return \Drupal\Core\Layout\LayoutDefinition[]
       */
      public function getSortedDefinitions(array $definitions = NULL, $label_key = 'label') {
        // Sort the plugins first by category, then by label.
        $definitions = $definitions ?? $this->getDefinitions();
        uasort($definitions, function (LayoutDefinition $a, LayoutDefinition $b) {
          if ($a->getCategory() != $b->getCategory()) {
            return strnatcasecmp($a->getCategory(), $b->getCategory());
          }
          return strnatcasecmp($a->getLabel(), $b->getLabel());
        });
        return $definitions;
      }
    

    This is the BlankLayout.php definition:

    <?php
    
    namespace Drupal\layout_builder\Plugin\Layout;
    
    use Drupal\Core\Layout\LayoutDefault;
    
    /**
     * Provides a layout plugin that produces no output.
     *
     * @see \Drupal\layout_builder\Field\LayoutSectionItemList::removeSection()
     * @see \Drupal\layout_builder\SectionListTrait::addBlankSection()
     * @see \Drupal\layout_builder\SectionListTrait::hasBlankSection()
     *
     * @internal
     *   This layout plugin is intended for internal use by Layout Builder only.
     *
     * @Layout(
     *   id = "layout_builder_blank",
     * )
     */
    class BlankLayout extends LayoutDefault {
    
      /**
       * {@inheritdoc}
       */
      public function build(array $regions) {
        // Return no output.
        return [];
      }
    
    }
    
    

    So it makes sense that ->getLabel and ->getCategory return NULL.

    The question is, why it's not being sorted out.

    I'm building a list of layouts using
    Drupal\Core\Layout\LayoutPluginManager->getLayoutOptions()
    and would expect this internal layout isn't returned there, but it is!

    Any ideas? Why do I have to sort it out manually when calling the above function?

    Layout builder does the following:

    /**
     * Implements hook_plugin_filter_TYPE_alter().
     */
    function layout_builder_plugin_filter_layout_alter(array &$definitions, array $extra, $consumer) {
      // Hide the blank layout plugin from listings.
      unset($definitions['layout_builder_blank']);
    }
    

    But it doesn't have any effect here?

    Related issues:
    ๐Ÿ› layout_builder_blank must not be disabled Fixed

  • Status changed to Active 8 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Anybody Porta Westfalica
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Anybody Porta Westfalica

    I guess we should close this as duplicate of ๐Ÿ› Add missing category to Drupal\layout_builder\Plugin\Layout\BlankLayout and let modules and themes alter the list of layouts RTBC but try to fix it.

    @longwave & @cilefen would you mind taking a look perhaps?

  • Status changed to Closed: duplicate 8 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Anybody Porta Westfalica

    Closing this as duplicate of ๐Ÿ› Add missing category to Drupal\layout_builder\Plugin\Layout\BlankLayout and let modules and themes alter the list of layouts RTBC . Let's proceed there.

    @longwave & @cilefen would you mind taking a look perhaps? Or anyone else who can tell why layout_builder_plugin_filter_layout_alter() is not called to sort out that internal layout?

Production build 0.69.0 2024