- Issue created by @Jared Nolt
- π¬π§United Kingdom joachim
Could you do some debugging to see what's causing the error?
BTW, please don't add random tags to issues; tags have specific purposes. And it's better to copy-paste error text rather than take screenshots, as then the error text can be used to search the codebase.
- πΊπΈUnited States Jared Nolt
Thanks for replying! I know this wasn't the right thing to do but there was a discussion on the Drupal SEO Slack channel
Summary from Slack:
- There isn't anything in the browser console after I changed the "Entity type" selector to "Product".
- When the selector is changed there is no AJAX callback to the server to get the list of bundles.
- I installed Metatags Import Export csv on 2 other sites. The "Bundle" on the one site only show node types. The other new test site I built only has 5 products and "bundle" is empty.
This is the error message that shows after I click to download the csv. "The website encountered an unexpected error. Try again later."
This is the log messages:
Type php Date Tuesday, February 27, 2024 - 06:37 User Drupal Jared Admin Location https://www.horningmfg.com/batch?id=556&op=finished Referrer https://www.horningmfg.com/batch?id=556&op=start Message TypeError: array_unshift(): Argument #1 ($array) must be of type array, null given in array_unshift() (line 80 of /home/horningmfg/public_html/horning/web/modules/contrib/metatag_import_export_csv/src/MetatagExport.php). Severity Error Operations Backtrace #0 /home/horningmfg/public_html/horning/web/modules/contrib/metatag_import_export_csv/src/MetatagExport.php(80): array_unshift(NULL, 'entity_id', 'entity_title', 'entity_bundle', 'entity_type', 'field_machine_n...', 'alias') #1 /home/horningmfg/public_html/horning/web/core/includes/batch.inc(457): Drupal\metatag_import_export_csv\MetatagExport::downloadCsv(true, Array, Array, Object(Drupal\Core\StringTranslation\TranslatableMarkup)) #2 /home/horningmfg/public_html/horning/web/core/includes/batch.inc(99): _batch_finished() #3 /home/horningmfg/public_html/horning/web/core/modules/system/src/Controller/BatchController.php(52): _batch_page(Object(Symfony\Component\HttpFoundation\Request)) #4 [internal function]: Drupal\system\Controller\BatchController->batchPage(Object(Symfony\Component\HttpFoundation\Request)) #5 /home/horningmfg/public_html/horning/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #6 /home/horningmfg/public_html/horning/web/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #7 /home/horningmfg/public_html/horning/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #8 /home/horningmfg/public_html/horning/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #9 /home/horningmfg/public_html/horning/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #10 /home/horningmfg/public_html/horning/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #11 /home/horningmfg/public_html/horning/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #12 /home/horningmfg/public_html/horning/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #13 /home/horningmfg/public_html/horning/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #14 /home/horningmfg/public_html/horning/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #15 /home/horningmfg/public_html/horning/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #16 /home/horningmfg/public_html/horning/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #17 /home/horningmfg/public_html/horning/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #18 /home/horningmfg/public_html/horning/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #19 /home/horningmfg/public_html/horning/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #20 /home/horningmfg/public_html/horning/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /home/horningmfg/public_html/horning/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 /home/horningmfg/public_html/horning/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #23 {main}
- π¬π§United Kingdom joachim
Could you put a debug breakpoint in getBundlesList() and see what happens when Product is selected?
- πΊπΈUnited States Jared Nolt
I'm sorry, debugging like that is new for me. I have been trying awhile but I'm not sure what I should look for.
This message showed on the Metatage export page of my test site:
Warning: Undefined variable $bundle_options in Drupal\metatag_import_export_csv\Form\MetaTagDownloadForm->buildForm() (line 106 of modules/contrib/metatag_import_export_csv/src/Form/MetaTagDownloadForm.php). Drupal\metatag_import_export_csv\Form\MetaTagDownloadForm->buildForm(Array, Object) call_user_func_array(Array, Array) (Line: 536) Drupal\Core\Form\FormBuilder->retrieveForm('metatag_import_export_download', Object) (Line: 283) 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: 592) 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: 48) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51) Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
- πΊπΈUnited States Jared Nolt
I added 2 screenshots. One of where I added the breakpoint and the other of what happens when I click the product tab. Please let me know if I should provide this info in some other format.
- π¬π§United Kingdom joachim
I meant PHP breakpoints.
And just the lines where it goes wrong will do.
When you change the entity type, there's an AJAX callback which should be returning bundles.
- πΊπΈUnited States Jared Nolt
Does this help? This is what shows when I click export now:
The website encountered an unexpected error. Try again later. TypeError: array_unshift(): Argument #1 ($array) must be of type array, null given in array_unshift() (line 80 of modules/contrib/metatag_import_export_csv/src/MetatagExport.php). Drupal\metatag_import_export_csv\MetatagExport::downloadCsv(1, Array, Array, Object) (Line: 457) _batch_finished() (Line: 99) _batch_page(Object) (Line: 52) Drupal\system\Controller\BatchController->batchPage(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: 28) Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32) Drupal\big_pipe\StackMiddleware\ContentLength->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: 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)
- π¬π§United Kingdom joachim
No, that's a false error because the form gets submitted with broken values.
I need the error that causes an empty list of bundles for products.
- πΊπΈUnited States Jared Nolt
I'm still working at getting the error but I did notice that when I changed the default_value on the MetaTagDownloadForm.php from "node" to "commerce_product" it shows the commerce "Bundle". But it didn't export all of the Metatag fields.
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $form['entity_type'] = [ '#title' => $this->t('Entity type'), '#type' => 'select', '#required' => TRUE, '#options' => $this->getEntityTypes(), '#default_value' => isset($this->getEntityTypes()['commerce_product']) ? 'commerce_product' : '', '#ajax' => [ 'callback' => '::getBundlesList', 'event' => 'change', ], ];
- πΊπΈUnited States Jared Nolt
On comment #10 - The ajax progress wheel spins when the Entity type is switched from content to products but nothing changes in the Bundle field.
- π¬π§United Kingdom joachim
Yes, because this callback is failing somehow:
> 'callback' => '::getBundlesList',
That's the bit that needs debugging.
- πΊπΈUnited States Jared Nolt
joachim, I don't think I'm getting anything you can use. Could you give me tips on how to get the errors please? Or where is the best place that I could go to learn about debugging?
- π¬π§United Kingdom joachim
- Status changed to Needs work
9 months ago 10:53am 12 March 2024 - π¬π§United Kingdom joachim
I've got it working *better*, but I can only change the entity type ONCE. I can't change it back! Leaving this for now, I hate debugging ajax forms :/
- Status changed to Fixed
6 months ago 9:04am 21 May 2024 -
joachim β
committed 427baee6 on 8.x-1.x
Issue #3421982 by joachim: Fixed export form bundles element doesn't...
-
joachim β
committed 427baee6 on 8.x-1.x
Automatically closed - issue fixed for 2 weeks with no activity.