BibTeX export throws exception if reference does not have an author

Created on 19 May 2025, about 2 months ago

Problem/Motivation

When attempting to export a reference that has no author, an exception is thrown with this stack trace:

TypeError: implode(): Argument #1 ($array) must be of type array, string given in implode() (line 223 of modules/contrib/bibcite/modules/bibcite_bibtex/src/Encoder/BibtexEncoder.php).

Drupal\bibcite_bibtex\Encoder\BibtexEncoder->buildLine('author', NULL) (Line: 176)
Drupal\bibcite_bibtex\Encoder\BibtexEncoder->buildEntry(Array) (Line: 146)
Drupal\bibcite_bibtex\Encoder\BibtexEncoder->Drupal\bibcite_bibtex\Encoder\{closure}(Array)
array_map(Object, Array) (Line: 145)
Drupal\bibcite_bibtex\Encoder\BibtexEncoder->encode(Array, 'bibtex', Array) (Line: 43)
Symfony\Component\Serializer\Encoder\ChainEncoder->encode(Array, 'bibtex', Array) (Line: 418)
Symfony\Component\Serializer\Serializer->encode(Array, 'bibtex', Array) (Line: 143)
Symfony\Component\Serializer\Serializer->serialize(Array, 'bibtex') (Line: 75)
Drupal\bibcite_export\Controller\ExportController->processExport(Array, Object, 'bibcite_reference-921-BibTeX') (Line: 113)
Drupal\bibcite_export\Controller\ExportController->export(Object, 'bibcite_reference', Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
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: 53)
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: 40)
Drupal\ps_ban\BanMiddleware->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: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

  1. Enable BibTeX sub-module
  2. Create a Book reference and provide an editor but NOT an author
  3. Click link to export reference to BibTeX
  4. Observe exception

Note that is NO author or editor is provided, or BOTH an author and editor are provided, it exports fine. It's just a problem if ONLY an editor is provided and no author.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024