- ๐ฆ๐บAustralia nterbogt
I debugged this further and the error appears to be caused by the strict 'string' argument to `strnatcasecmp`.
Drupal is passing in strings or `Drupal\Core\StringTranslation\TranslatableMarkup` objects... which used to work when typecast to string.
- Status changed to Needs review
about 2 years ago 7:50am 30 January 2023 - ๐ฆ๐บAustralia nterbogt
Setting this to needs review. The risk of an empty label is gone, and the bug is clearer, imo.
- Status changed to Needs work
about 2 years ago 7:53am 30 January 2023 - ๐ฆ๐บAustralia nterbogt
Actually, I think I might have solved a different issue. More thinking required.
- ๐ฎ๐นItaly balbogbf
width #16 i have this error:
Error: Object of class Drupal\system\Entity\Menu could not be converted to string in Drupal\Core\Block\BlockManager->Drupal\Core\Plugin\{closure}() (linea 99 di ..../core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php). - last update
almost 2 years ago Patch Failed to Apply - ๐บ๐ธUnited States jimconte
Hello balbogbf ref #19
Regarding your error, I had the same error and it was due to the project drupal/we_megamenu
If this is also your issue, there is patch to fix this:we_megamenu blocks using "\Drupal\system\Entity\Menu" object as admin label
https://www.drupal.org/project/we_megamenu/issues/3357546 ๐ we_megamenu blocks using "\Drupal\system\Entity\Menu" object as admin label Fixed - First commit to issue fork.
- Merge request !5835Issue #3315678 by hanii.gerges, Prem Suthar: strnatcasecmp(): Passing null to... โ (Open) created by jrglasgow
- Merge request !5837Issue #3315678 by hanii.gerges, Prem Suthar: strnatcasecmp(): Passing null to... โ (Open) created by jrglasgow
- Status changed to Needs review
about 1 year ago 8:51pm 15 December 2023 - ๐บ๐ธUnited States jrglasgow Idaho
I found another similar error and I have it fixed in this updated patch... this patch applies to both 10.2.x and 11.x
- Status changed to Needs work
about 1 year ago 3:02pm 16 December 2023 - ๐บ๐ธUnited States smustgrave
We have test coverage of editing a layout in core and this error does not occur. This is pointing to an issue somewhere in contrib or custom code. Somewhere where a label is expected there is none.
Sounds like we need additional test coverage.
- ๐บ๐ธUnited States tawellman
I recently updated to 10.2 and am now getting the following on any Entity Manage form display pages.
Deprecated function: strnatcasecmp(): Passing null to parameter #2 ($string2) of type string is deprecated in Drupal\Core\Layout\LayoutPluginManager->Drupal\Core\Layout\{closure}() (line 204 of core/lib/Drupal/Core/Layout/LayoutPluginManager.php). Drupal\Core\Layout\LayoutPluginManager->Drupal\Core\Layout\{closure}(Object, Object) uasort(Array, Object) (Line: 207) Drupal\Core\Layout\LayoutPluginManager->getSortedDefinitions(Array, 'label') (Line: 217) Drupal\Core\Layout\LayoutPluginManager->getGroupedDefinitions() (Line: 230) Drupal\Core\Layout\LayoutPluginManager->getLayoutOptions() (Line: 64) Drupal\field_layout\Form\FieldLayoutEntityFormDisplayEditForm->form(Array, Object) (Line: 107) Drupal\Core\Entity\EntityForm->buildForm(Array, Object) call_user_func_array(Array, Array) (Line: 536) Drupal\Core\Form\FormBuilder->retrieveForm('entity_form_display_edit_form', Object) (Line: 283) Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73) Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39) Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object) call_user_func_array(Array, Array) (Line: 123) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50) Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36) Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51) Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704) Drupal\Core\DrupalKernel->handle(Object) (Line: 19) Deprecated function: strnatcasecmp(): Passing null to parameter #2 ($string2) of type string is deprecated in Drupal\Core\Layout\LayoutPluginManager->Drupal\Core\Layout\{closure}() (line 204 of core/lib/Drupal/Core/Layout/LayoutPluginManager.php). Deprecated function: strnatcasecmp(): Passing null to parameter #2 ($string2) of type string is deprecated in Drupal\Core\Layout\LayoutPluginManager->Drupal\Core\Layout\{closure}() (line 204 of core/lib/Drupal/Core/Layout/LayoutPluginManager.php). Deprecated function: strnatcasecmp(): Passing null to parameter #2 ($string2) of type string is deprecated in Drupal\Core\Layout\LayoutPluginManager->Drupal\Core\Layout\{closure}() (line 204 of core/lib/Drupal/Core/Layout/LayoutPluginManager.php). Deprecated function: strnatcasecmp(): Passing null to parameter #1 ($string1) of type string is deprecated in Drupal\Core\Layout\LayoutPluginManager->Drupal\Core\Layout\{closure}() (line 204 of core/lib/Drupal/Core/Layout/LayoutPluginManager.php).
I have searched for a solution. I can confirm the patch from #25 worked for me.
- ๐ฆ๐นAustria jordik
I see the same message as in #27, but the patch in #25 did not solve it for me.
- ๐ฆ๐นAustria jordik
Here is a full list of occurrences of the function with file name, line number and in which function. I can gladly look into it and provide a patch, but we I would need guidance on whether we do a typecasting like in #16 or a check if NULL as in #25?
\core\lib\Drupal\Component\Utility\SortArray.php"(105,12): return strnatcasecmp($a_title, $b_title);
\core\lib\Drupal\Core\Config\Entity\ConfigEntityBase.php"(237,14): return strnatcasecmp($a_label, $b_label);
\core\lib\Drupal\Core\Datetime\Entity\DateFormat.php"(91,14): return strnatcasecmp($a_label, $b_label);
\core\lib\Drupal\Core\Entity\EntityDisplayModeBase.php"(72,19): $type_order = strnatcasecmp($a_type, $b_type);
\core\lib\Drupal\Core\Language\Language.php"(161,16): return strnatcasecmp($a_name, $b_name);
\core\lib\Drupal\Core\Layout\LayoutPluginManager.php"(204,16): return strnatcasecmp($a->getCategory() ?? '', $b->getCategory() ?? '');
\core\lib\Drupal\Core\Layout\LayoutPluginManager.php"(206,14): return strnatcasecmp($a->getLabel() ?? '', $b->getLabel() ?? '');
\core\lib\Drupal\Core\Plugin\CategorizingPluginManagerTrait.php"(95,16): return strnatcasecmp($a['category'], $b['category']);
\core\lib\Drupal\Core\Plugin\CategorizingPluginManagerTrait.php"(97,14): return strnatcasecmp($a[$label_key], $b[$label_key]);
\core\lib\Drupal\Core\Plugin\DefaultLazyPluginCollection.php"(100,12): return strnatcasecmp($a->getPluginId(), $b->getPluginId());
\core\lib\Drupal\Core\Test\TestDiscovery.php"(190,20): uksort($list, 'strnatcasecmp');
\core\lib\Drupal\Core\Test\TestDiscovery.php"(192,23): uksort($tests, 'strnatcasecmp');
\core\modules\config\src\Form\ConfigSingleExportForm.php"(89,28): uasort($entity_types, 'strnatcasecmp');
\core\modules\config\src\Form\ConfigSingleImportForm.php"(262,28): uasort($entity_types, 'strnatcasecmp');
\core\modules\config_translation\src\Controller\ConfigTranslationEntityListBuilder.php"(123,12): return strnatcasecmp($a_value, $b_value);
\core\modules\config_translation\src\Controller\ConfigTranslationMapperList.php"(69,16): return strnatcasecmp($a_title, $b_title);
\core\modules\filter\src\FilterPluginCollection.php"(100,14): return strnatcasecmp($a->provider, $b->provider);
\core\modules\help\src\Plugin\HelpSection\HelpTopicSection.php"(146,16): return strnatcasecmp($a_label, $b_label);
\core\modules\shortcut\src\Entity\Shortcut.php"(186,14): return strnatcasecmp($a->getTitle(), $b->getTitle());
\core\modules\system\src\Entity\Action.php"(178,14): return strnatcasecmp($a_type, $b_type);
\core\modules\views_ui\tests\src\Functional\FilterEntityReferenceWebTest.php"(46,14): return strnatcasecmp($a->getTitle(), $b->getTitle());
\core\modules\workspaces\src\WorkspaceRepository.php"(67,16): return strnatcasecmp($a->label(), $b->label()); - ๐ฎ๐ณIndia prashant.c Dharamshala
Prashant.c โ made their first commit to this issueโs fork.
- Status changed to Needs review
about 1 year ago 7:23am 8 January 2024 - ๐ฎ๐ณIndia prashant.c Dharamshala
Added the
null coalescing operator
to occurrences ofstrnatcasecmp()
wherever it was applicable.I was not able to apply the patches provided in
11.x
therefore submitting the patch file as well.
Changes needs to be reviewed.Thank you.
- Status changed to Needs work
about 1 year ago 1:24pm 8 January 2024 - ๐บ๐ธUnited States smustgrave
Still say we need to research why/how this value got null.
Will need test coverage
- ๐บ๐ธUnited States tjtj
I am also getting this error in Drupal\Core\Layout\LayoutPluginManager->Drupal\Core\Layout\{
closure}() (line 2 - Status changed to Closed: duplicate
about 1 year ago 3:36am 10 February 2024 - ๐บ๐ธUnited States benjifisher Boston area
@tawellman, thanks for posting the stack trace in Comment #27. That shows the (core, experimental)
field_layout
module. When I enable that, I can reproduce the error by visiting/en/admin/structure/types/manage/article/form-display
(Umami demo profile) as you suggested.I have updated the steps to reproduce on that issue, and I am closing this one as a duplicate.