Problem/Motivation
When running cron, function bynder_cron makes it fail.
Steps to reproduce
I'm getting the following error when running cron:
php-error staging-38954 [11-Mar-2021 11:34:08 Europe/London] Error: Call to a member function mainPropertyName() on null in /mnt/www/html/sitedev/docroot/modules/contrib/bynder/src/Plugin/media/Source/Bynder.php on line 435 #0 /mnt/www/html/sitedev/docroot/modules/contrib/bynder/src/BynderService.php(218): Drupal\bynder\Plugin\media\Source\Bynder->getSourceFieldValue(Object(Drupal\media\Entity\Media))
Proposed resolution
Check if $field_item is null before returning the value.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | remove-legacy-helper-function-3203003-9.patch | 1.42 KB | lukus |
| #2 | byndermainpropertynamenull-3203003-2.patch | 500 bytes | guardiola86 |
Issue fork bynder-3203003
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
Comment #2
guardiola86 commentedI've attached a patch that fixes the error. Maybe there's a better solution though.
Comment #3
guardiola86 commentedComment #4
berdirThanks for the patch.
Looking at the parent method, that is basically identical except that it already contains a similar check. This is probably leftover of the old media_entity days when we had to do this ourself.
I'd suggest you just remove the whole method and confirm that this fixes your problem.
FWIW, if you do get this error then it sounds like you have broken bynder media entities in your system, you might want to search for them and delete them, as they might break things elsewhere too.
Comment #7
lukusHi
I can confirm that removing the method solves the problem.
The core method in D9.2 will allow for a source field with zero items:
The helper method that's bundled with the module doesn't:
Comment #8
lukus@berdir are you happy for me to create a patch to remove the full method?
Comment #9
lukusHere's a patch in any case :)
Comment #10
JvE commentedThe patch in #9 is almost identical to my merge request in #6. It just misses the increased dependency version.
Comment #11
JvE commentedComment #12
lukusHi @JvE
Sorry, I missed that.
Looks good :)
Best
Luke
Comment #13
berdirThat requirement is unnecessary though because in the very same .info.yml, we already require drupal core ^8.8 || 9, so there's no way that you could have drupal:media 8.4.
Comment #16
berdirAccidently merged the MR and reverted the .info.yml change again.