Problem/Motivation
On /admin/config/system/mailer page
I get this error
Deprecated function: strnatcasecmp(): Passing null to parameter #1 ($string1) of type string is deprecated in Drupal\symfony_mailer\Entity\MailerPolicy::sort() (line 362 of modules/contrib/symfony_mailer/src/Entity/MailerPolicy.php).
Drupal\symfony_mailer\Entity\MailerPolicy::sort(Object, Object)
uasort(Array, Array) (Line: 24)
Drupal\Core\Config\Entity\ConfigEntityListBuilder->load() (Line: 69)
Drupal\symfony_mailer\MailerPolicyListBuilder->load() (Line: 218)
Drupal\Core\Entity\EntityListBuilder->render() (Line: 23)
Drupal\Core\Entity\Controller\EntityListController->listing('mailer_policy')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
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: 159)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
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: 130)
Drupal\cdn\StackMiddleware\DuplicateContentPreventionMiddleware->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: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 707)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
adamps commentedThanks probably the cause is MailerPolicy::getEntityLabel() which can return NULL. We could change it to return ''. Patches welcome.
It's hard to hit this problem. It would need two policies with the same type and sub-type plus
has_entityis FALSE (for at least one of them - but they are the same type, so will share this value). However in that case they are both the same policy.Ah maybe you have two policies of different unknown types - so they are different policy but the same label.
Comment #3
trickfun commentedI had 2 unknow sub-type
deleted it fix the problem
thank you
Comment #4
adamps commentedComment #5
juancec commentedHi, I'll review it.
Comment #6
juancec commentedHi @AdamPS, I couldn't reproduce the error, so I couldn't test the patch #4. I'm sorry.
Comment #8
adamps commentedNo problem - it is tricky to reproduce as it requires a specific unusual condition. I hit the condition myself yesterday so I fixed it😃.