Problem/Motivation
While using UI (/admin/config/regional/translate/extract) extract page. It comes by this deprecation message:
Deprecated function: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in Drupal\potx\Form\PotxExtractTranslationForm->getFormElementId() (line 353 of modules/contrib/potx/src/Form/PotxExtractTranslationForm.php).
Drupal\potx\Form\PotxExtractTranslationForm->getFormElementId('com', NULL) (Line: 321)
Drupal\potx\Form\PotxExtractTranslationForm->buildComponentSelector(Array, Array, '/profiles/SOME_PROFILE_HERE') (Line: 333)
Drupal\potx\Form\PotxExtractTranslationForm->buildComponentSelector(Array, Array, '/profiles') (Line: 333)
Drupal\potx\Form\PotxExtractTranslationForm->buildComponentSelector(Array, Array) (Line: 80)
Drupal\potx\Form\PotxExtractTranslationForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 534)
Drupal\Core\Form\FormBuilder->retrieveForm('potx_extract_transation', Object) (Line: 281)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
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: 169)
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: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 49)
Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle(Object, 1, 1) (Line: 57)
Drupal\debug_bar\DebugBarMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 713)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
I do not know if using profile triggers this deprecation or something else. But in this case it seams so.
My other versions that I use curently:
Drupal version : 9.5.1
Drush version : 10.6.2
PHP 8.1.9
"drupal/potx": "^1.0-dev@dev"
with patches:
"drupal/potx" : {
"2816601 - String not extracted from twig template": "https://www.drupal.org/files/issues/2022-10-10/2816601-1.patch",
"3030218 - Not discovering profiles properly": "https://www.drupal.org/files/issues/2019-02-02/3030218-3.patch",
"3028920 - Problem with customized languages and Plural-Forms in header Potx files extracted": "https://www.drupal.org/files/issues/2023-01-05/fix-usage-potx-with-custom-language-prefix-6.patch",
"3318924 - Config rewrite": "https://www.drupal.org/files/issues/2023-01-25/potx_config_rewrite_3318924_5.patch",
"3159088 - Extract english translations": "https://www.drupal.org/files/issues/2020-07-14/extract-english-translations-3159088-2.patch",
"3180277 - Warning when 0 strings are found": "https://www.drupal.org/files/issues/2020-11-02/potx-3180277-2.patch",
"3090507 - Make 'folder' option multiple": "https://www.drupal.org/files/issues/2019-10-28/3090507-3.potx_.Make-folder-option-multiple.patch"
}
Proposed resolution
Quick solution in my attached patch is to typecast to string. This solves the issue for now.