Problem/Motivation

While exporting to Bibtex, an error occur:
Message Error: Call to a member function getName() on null in Drupal\bibcite_bibtex\Normalizer\BibtexReferenceNormalizer->extractContributors() (line 98 of /path/web/modules/contrib/bibcite/modules/bibcite_bibtex/src/Normalizer/BibtexReferenceNormalizer.php)

Likely related with missing information on a reference (content), but this will avoid the export from breaking.

Issue fork bibcite-3261949

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rfmarcelino created an issue. See original summary.

Liam Morland’s picture

What is this line for? This adds an extra value to the array when $field->entity->getName() succeeds.

$contributors[$role][] = '';

Perhaps it could be done like this:

$contributors[$role][] = $field->entity ? $field->entity->getName() : NULL;

Status: Needs review » Needs work

The last submitted patch, bibtex_getName_null.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Liam Morland’s picture

Status: Needs work » Needs review

I created a merge request with the suggestion from #2.

AardWolf’s picture

Hello @Liam-Morland.
Thank you for the issue and for the patch.
I'm not sure it is the right behavior to fix an error in data. At least the error must not fatal but can inform users about incorrect data.
So I want to reproduce this error and think if it is the correct way.

In any case, this patch looks good and can be used if needed.

AdeleYounis’s picture

This seems to have something to do with authors getting deleted outside of the reference, without the reference getting resaved. We found that it affects the ability to export all formats, not just Bibtex, though Liam's merge request only fixes Bibtex export.

Attached is a new patch, using Liam's method, that seems to fix all the exports. Note that we did test to confirm that both files need the change - fixing the "generic" ReferenceNormalizerBase doesn't fix Bibtex, but does fix everything else.

AvO WebWorks’s picture

I had a very similar issue:
Error: Call to a member function label() on null in Drupal\bibcite_entity\Normalizer\ReferenceNormalizerBase->extractKeywords()
line 284: $keywords[] = $field->entity->label();
Changed to:
$keywords[] = $field->entity ? $field->entity ->label() : NULL;
Fixed the issue.

AvO WebWorks’s picture

Here is the new patch which adds the to the patch in #7 and includes the keywords issue.

  • AvO WebWorks authored b49a89c3 on 2.0.x
    Issue #3261949 by bkosborne, Liam Morland, rfmarcelino, AvO WebWorks,...

hxdef’s picture

Status: Needs review » Fixed

Thank you very much for your work! Added this to the module code.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.