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.

Issue fork potx-3338225

Command icon 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:

Comments

seemas created an issue. See original summary.

seemas’s picture

A patch to remove deprecation message

seemas’s picture

seemas’s picture

arkener’s picture

Status: Needs review » Reviewed & tested by the community

Also ran into this issue. Extension::getExtensionFilename() can sometimes return NULL, mostly in the case of submodules, resulting in this issue. #2 fixed this issue for me.

tar_inet made their first commit to this issue’s fork.

pfructuoso’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work

tar_inet changed the visibility of the branch 3338225-deprecated-function-pregreplace to hidden.

pfructuoso’s picture

Status: Needs work » Needs review

Added patch to avoid reach a point where deprecation warning is launch.
Could somebody review my patch?
Thanks!

johnatas’s picture

StatusFileSize
new2.55 KB

Hi,

I'm able to reproduce the issue, even without any submodules.
Merge Request !17 does fix the problem for me.

I’m currently using:

  • Translation template extractor module version: 2.1.0
  • Drupal core version: 11.2.2

While waiting for the merge, for those interested, I'm attaching a patched version based on MR !17.

Thanks!

johnatas’s picture

Hello,

can we consider this issue as RTBC?

volman’s picture

Status: Needs review » Reviewed & tested by the community

I reproduced the issue on Drupal 11.2.2 with potx 8.x-1.1 and I confirm #13 fixes the warnings.

maxmendez’s picture

I've tested patch #13 on Drupal 11.2.8 with 8.x-1.1 and id solved the warning.