Problem/Motivation
I'm using focal_point in conjunction with Drupal Core 9.5.0 media and PHP 8.1.12. I recently installed the modules media_thumbnails and media_thumbnails_pdf which auto generate a thumbnail for PDF files using imagemagick. The thumbnail generates when I save a media item but I am greeted by a WSOD with the "The website encountered an unexpected error. Please try again later." message. In the log messages I see:
TypeError: Drupal\focal_point\FocalPointManager::saveCropEntity(): Argument #3 ($width) must be of type int, null given, called in /app/web/modules/contrib/focal_point/focal_point.module on line 99 in Drupal\focal_point\FocalPointManager->saveCropEntity() (line 94 of /app/web/modules/contrib/focal_point/src/FocalPointManager.php)
Full trace:
TypeError: Drupal\focal_point\FocalPointManager::saveCropEntity(): Argument #3 ($width) must be of type int, null given, called in /app/web/modules/contrib/focal_point/focal_point.module on line 99 in Drupal\focal_point\FocalPointManager->saveCropEntity() (line 94 of /app/web/modules/contrib/focal_point/src/FocalPointManager.php)
#0 /app/web/modules/contrib/focal_point/focal_point.module(99): Drupal\focal_point\FocalPointManager->saveCropEntity(50.0, 50.0, NULL, NULL, Object(Drupal\crop\Entity\Crop))
#1 [internal function]: focal_point_entity_update(Object(Drupal\media\Entity\Media))
#2 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(426): call_user_func_array(Object(Closure), Array)
#3 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(405): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object(Closure), 'focal_point')
#4 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(433): Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_update', Object(Closure))
#5 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(251): Drupal\Core\Extension\ModuleHandler->invokeAll('entity_update', Array)
#6 /app/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(903): Drupal\Core\Entity\EntityStorageBase->invokeHook('update', Object(Drupal\media\Entity\Media))
#7 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(598): Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('update', Object(Drupal\media\Entity\Media))
#8 /app/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(784): Drupal\Core\Entity\EntityStorageBase->doPostSave(Object(Drupal\media\Entity\Media), true)
#9 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(523): Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object(Drupal\media\Entity\Media), true)
#10 /app/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(804): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\media\Entity\Media))
#11 /app/web/core/modules/media/src/MediaStorage.php(29): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object(Drupal\media\Entity\Media))
#12 /app/web/core/lib/Drupal/Core/Entity/EntityBase.php(339): Drupal\media\MediaStorage->save(Object(Drupal\media\Entity\Media))
#13 /app/web/core/lib/Drupal/Core/Entity/EntityForm.php(285): Drupal\Core\Entity\EntityBase->save()
#14 /app/web/core/modules/media/src/MediaForm.php(61): Drupal\Core\Entity\EntityForm->save(Array, Object(Drupal\Core\Form\FormState))
#15 [internal function]: Drupal\media\MediaForm->save(Array, Object(Drupal\Core\Form\FormState))
#16 /app/web/core/lib/Drupal/Core/Form/FormSubmitter.php(114): call_user_func_array(Array, Array)
#17 /app/web/core/lib/Drupal/Core/Form/FormSubmitter.php(52): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState))
#18 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(595): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState))
#19 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(323): Drupal\Core\Form\FormBuilder->processForm('media_svg_edit_...', Array, Object(Drupal\Core\Form\FormState))
#20 /app/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\media\MediaForm), Object(Drupal\Core\Form\FormState))
#21 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#22 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#23 /app/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#24 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#25 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#26 /app/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#27 /app/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#28 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#33 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#34 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#35 /app/web/core/lib/Drupal/Core/DrupalKernel.php(707): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#36 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#37 {main}.
Steps to reproduce
Install D9.5.
Install focal_point
Upload PDF to Drupal media library.
Install media_thumbnails and media_thumbnails_pdf modules
Go to media library and edit and save the PDF media item
Observe WSOD and error message in logs
Go to media library and see thumbnail indeed generated
Go to /app/web/modules/contrib/focal_point/focal_point.module on line 99 and kint or ksm or dump the $item.
There is no width or height properties because $item is a media item and does not have those properties.
Proposed resolution
Unsure. To be clear though I am not attempting to use focal_point in the generation of the thumbnail so I'm unclear as to why focal_point is even firing?
Remaining tasks
Unsure.
User interface changes
None.
API changes
Unsure.
Data model changes
Unsure.
If I can provide anything further that may be helpful please let me know.