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}

My PHP version is 8.1.31

CommentFileSizeAuthor
#6 image_field.png46.81 KBkoffer
#3 3506490-3.patch1.36 KBswentel

Comments

koffer created an issue. See original summary.

koffer’s picture

Issue summary: View changes
swentel’s picture

Status: Active » Needs review
StatusFileSize
new1.36 KB

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?

koffer’s picture

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

swentel’s picture

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)

koffer’s picture

StatusFileSize
new46.81 KB

There is a image field linked
image field

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

swentel’s picture

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.

  • swentel committed 2721cc8f on 1.0.x
    Issue #3506490: PHP error Drupal\file\FileInterface, null given, called...
swentel’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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