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
Install a module without .module file and with submodules, then go to export form page /admin/config/regional/translate/extract. EG:
my_module/
- modules/
- my_module_submodule1/
- my_module_submodule1.info.yml
- my_module_submodule2/
- my_module_submodule2.info.yml
- my_module.info.yml
Proposed resolution
Build the form based on mandatory files like .info.yml.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 3338225-13.patch | 2.55 KB | johnatas |
| #2 | potx-deprecation_in_preg_replace-3338225-1_2023-02-01.patch | 556 bytes | seemas |
Issue fork potx-3338225
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 8.x-1.x
changes, plain diff MR !17
- 3338225-deprecated-function-pregreplace
changes, plain diff MR !16
Comments
Comment #2
seemas commentedA patch to remove deprecation message
Comment #3
seemas commentedComment #4
seemas commentedComment #5
arkener commentedAlso ran into this issue.
Extension::getExtensionFilename()can sometimes returnNULL, mostly in the case of submodules, resulting in this issue. #2 fixed this issue for me.Comment #7
pfructuoso commentedComment #12
pfructuoso commentedAdded patch to avoid reach a point where deprecation warning is launch.
Could somebody review my patch?
Thanks!
Comment #13
johnatas commentedHi,
I'm able to reproduce the issue, even without any submodules.
Merge Request !17 does fix the problem for me.
I’m currently using:
While waiting for the merge, for those interested, I'm attaching a patched version based on MR !17.
Thanks!
Comment #14
johnatas commentedHello,
can we consider this issue as RTBC?
Comment #15
volmanI reproduced the issue on Drupal 11.2.2 with potx 8.x-1.1 and I confirm #13 fixes the warnings.
Comment #16
maxmendez commentedI've tested patch #13 on Drupal 11.2.8 with 8.x-1.1 and id solved the warning.