Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#9 | getName_Null.patch | 1.61 KB | AvO WebWorks |
#7 | fix_export-3261949-7.patch | 1.31 KB | AdeleYounis |
bibtex_getName_null.patch | 911 bytes | rfmarcelino | |
Issue fork bibcite-3261949
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:
- 3261949-error-call-to changes, plain diff MR !7
Comments
Comment #2
Liam MorlandWhat is this line for? This adds an extra value to the array when
$field->entity->getName()
succeeds.Perhaps it could be done like this:
Comment #5
Liam MorlandI created a merge request with the suggestion from #2.
Comment #6
AardWolf CreditAttribution: AardWolf commentedHello @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.
Comment #7
AdeleYounis CreditAttribution: AdeleYounis at University of Waterloo commentedThis 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.
Comment #8
AvO WebWorks CreditAttribution: AvO WebWorks commentedI 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.
Comment #9
AvO WebWorks CreditAttribution: AvO WebWorks commentedHere is the new patch which adds the to the patch in #7 and includes the keywords issue.
Comment #12
hxdef CreditAttribution: hxdef at ADCI Solutions commentedThank you very much for your work! Added this to the module code.