PHP error Drupal\file\FileInterface, null given, called in

Created on 13 February 2025, about 2 months ago

Problem/Motivation

Hi, I Uninstall and install again the newest version oft he module and some part are working but some others dont. The main problem is I cant publish notes in my fediverse account.

Steps to reproduce

This is the PHP error I get:

TypeError: Drupal\activitypub\Services\Type\TypePluginBase::getMediaType(): Argument #1 ($file) must be of type Drupal\file\FileInterface, null given, called in /var/www/mydomain.com/site/web/modules/contrib/activitypub/src/Services/Type/TypePluginBase.php on line 264 en Drupal\activitypub\Services\Type\TypePluginBase->getMediaType() (lΓ­nea 284 de /var/www/mydomain.com/site/web/modules/contrib/activitypub/src/Services/Type/TypePluginBase.php)
#0 /var/www/mydomain.com/site/web/modules/contrib/activitypub/src/Services/Type/TypePluginBase.php(264): Drupal\activitypub\Services\Type\TypePluginBase->getMediaType()
#1 /var/www/mydomain.com/site/web/modules/contrib/activitypub/src/Plugin/activitypub/type/DynamicTypes.php(158): Drupal\activitypub\Services\Type\TypePluginBase->getValue()
#2 /var/www/mydomain.com/site/web/modules/contrib/activitypub/src/Entity/ActivityPubActivity.php(357): Drupal\activitypub\Plugin\activitypub\type\DynamicTypes->build()
#3 /var/www/mydomain.com/site/web/modules/contrib/activitypub/src/Services/ActivityPubProcessClient.php(121): Drupal\activitypub\Entity\ActivityPubActivity->buildActivity()
#4 /var/www/mydomain.com/site/web/modules/contrib/activitypub/activitypub.module(92): Drupal\activitypub\Services\ActivityPubProcessClient->prepareOutboxQueue()
#5 /var/www/mydomain.com/site/web/core/lib/Drupal/Core/Cron.php(337): activitypub_cron()
#6 /var/www/mydomain.com/site/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(395): Drupal\Core\Cron->Drupal\Core\{closure}()
#7 /var/www/mydomain.com/site/web/core/lib/Drupal/Core/Cron.php(345): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
#8 /var/www/mydomain.com/site/web/core/lib/Drupal/Core/Cron.php(159): Drupal\Core\Cron->invokeCronHandlers()
#9 /var/www/mydomain.com/site/web/core/lib/Drupal/Core/ProxyClass/Cron.php(75): Drupal\Core\Cron->run()
#10 /var/www/mydomain.com/site/web/core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php(65): Drupal\Core\ProxyClass\Cron->run()
#11 [internal function]: Drupal\automated_cron\EventSubscriber\AutomatedCron->onTerminate()
#12 /var/www/mydomain.com/site/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func()
#13 /var/www/mydomain.com/site/vendor/symfony/http-kernel/HttpKernel.php(115): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#14 /var/www/mydomain.com/site/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(66): Symfony\Component\HttpKernel\HttpKernel->terminate()
#15 /var/www/mydomain.com/site/web/core/lib/Drupal/Core/DrupalKernel.php(715): Drupal\Core\StackMiddleware\StackedHttpKernel->terminate()
#16 /var/www/mydomain.com/site/web/index.php(22): Drupal\Core\DrupalKernel->terminate()
#17 {main}
πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡²πŸ‡½Mexico koffer

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

Comments & Activities

  • Issue created by @koffer
  • πŸ‡§πŸ‡ͺBelgium swentel

    Hmm, interesting. Attached patch makes sure $file is actually a valid object. However, it's interesting that there's no file loaded. Did you upload one? And if yes, is it a media field or a file/image field?

  • πŸ‡²πŸ‡½Mexico koffer

    mmm Is a file/image field. I'm not sure where it is configured, does the code above indicate it?

  • πŸ‡§πŸ‡ͺBelgium swentel

    It's configured on the activitypub types screen at /admin/config/services/activitypub/activitypub-type.
    If you are using the standard note, check which field is assigned to the attachment fields (there's image, video and audio) (e.g. at /admin/config/services/activitypub/activitypub-type/note)

  • πŸ‡²πŸ‡½Mexico koffer

    There is a image field linked

    May be, if I do not select a field will work.

  • πŸ‡§πŸ‡ͺBelgium swentel

    If you deselect it, that it will probably work indeed (but with the patch it will be ok too).

    Question is: did you upload a file for that note? If so, than there is a problem though with the code itself, I'll test it myself as well.

Production build 0.71.5 2024