Problem/Motivation

Hi there,

running latest version of Drupal 9 and I'm unable to add any font displays for Google Fonts. Any suggestions?

Web Server: Apache
Drupal Version: 9.0.3
PHP Version: 7.4.5
Database Version: 5.7.28-nmm1-log

The website encountered an unexpected error. Please try again later.

Location: admin/appearance/font/font_display/add
Referrer: /admin/appearance/font/font_display/add
Message: Drupal\Core\Config\Schema\SchemaIncompleteException: Entity type 'Drupal\Core\Config\Entity\ConfigEntityType' is missing 'config_export' definition in its annotation in Drupal\Core\Config\Entity\ConfigEntityBase->toArray() (line 251 of ***/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php).

Steps to reproduce

Add Font display

Comments

hilrap created an issue. See original summary.

hilrap’s picture

Not possible to add loacal font either:

Error: Call to undefined function file_prepare_directory() in local_fonts_save_and_generate_css() (line 105 of /***/modules/fontyourface/modules/local_fonts/local_fonts.module)

#0 /***/modules/fontyourface/modules/local_fonts/local_fonts.module(53): local_fonts_save_and_generate_css(Object(Drupal\local_fonts\Entity\LocalFontConfigEntity))
#1 [internal function]: local_fonts_entity_presave(Object(Drupal\local_fonts\Entity\LocalFontConfigEntity), 'local_font_conf...')
#2 /***/core/lib/Drupal/Core/Extension/ModuleHandler.php(403): call_user_func_array('local_fonts_ent...', Array)
#3 /***/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(349): Drupal\Core\Extension\ModuleHandler->invokeAll('entity_presave', Array)
#4 /***/core/lib/Drupal/Core/Entity/EntityStorageBase.php(495): Drupal\Core\Config\Entity\ConfigEntityStorage->invokeHook('presave', Object(Drupal\local_fonts\Entity\LocalFontConfigEntity))
#5 /***/core/lib/Drupal/Core/Entity/EntityStorageBase.php(449): Drupal\Core\Entity\EntityStorageBase->doPreSave(Object(Drupal\local_fonts\Entity\LocalFontConfigEntity))
#6 /***/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(263): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\local_fonts\Entity\LocalFontConfigEntity))
#7 /***/core/lib/Drupal/Core/Entity/EntityBase.php(339): Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object(Drupal\local_fonts\Entity\LocalFontConfigEntity))
#8 /***/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(591): Drupal\Core\Entity\EntityBase->save()
#9 /***/modules/fontyourface/modules/local_fonts/src/Form/LocalFontConfigEntityForm.php(136): Drupal\Core\Config\Entity\ConfigEntityBase->save()
#10 [internal function]: Drupal\local_fonts\Form\LocalFontConfigEntityForm->save(Array, Object(Drupal\Core\Form\FormState))
#11 /***/core/lib/Drupal/Core/Form/FormSubmitter.php(113): call_user_func_array(Array, Array)
#12 /***/core/lib/Drupal/Core/Form/FormSubmitter.php(51): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState))
#13 /***/core/lib/Drupal/Core/Form/FormBuilder.php(593): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState))
#14 /***/core/lib/Drupal/Core/Form/FormBuilder.php(321): Drupal\Core\Form\FormBuilder->processForm('local_font_conf...', Array, Object(Drupal\Core\Form\FormState))
#15 /***/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\local_fonts\Form\LocalFontConfigEntityForm), Object(Drupal\Core\Form\FormState))
#16 /***/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#17 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#18 /***/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#19 /***/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#20 /***/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#21 /***/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#22 /***/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#23 /***/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#24 /***/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /***/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /***/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /***/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /***/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 /***/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 /***/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 /***/core/lib/Drupal/Core/DrupalKernel.php(705): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 /***/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#33 {main}

hilrap’s picture

Issue summary: View changes
neslee canil pinto’s picture

@hilrap did you run drupal update after updating your site to drupal 9?

hilrap’s picture

@Neslee Canil Pinto yea i did. It's actuall a new Drupal 9 install, no upgrade from Durpal 8.

back from 7’s picture

I get the same issue when trying to add a font display.

Once I save the font display, white screen error "The website encountered an unexpected error. Please try again later."

biabremer’s picture

I also have the same problem trying to add a custom font, with the same message "The website encountered an unexpected error. Please try again later.".

neslee canil pinto’s picture

Status: Active » Needs review
StatusFileSize
new863 bytes

Patch that fixes the issue. Can you apply and confirm

GDH’s picture

That patch didn't work for me. I was getting an error regarding calling a non-static function.
I tried:
\Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
But then I get a new error.
Uncaught PHP Exception Drupal\\Core\\Config\\Schema\\SchemaIncompleteException: "Entity type 'Drupal\\Core\\Config\\Entity\\ConfigEntityType' is missing 'config_export' definition in its annotation" at /var/www/MYSITE/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php line 251, referer: http://127.0.0.1/MYSITE/web/admin/appearance/font/local_font_config_enti...

Although it takes me to the same white page with the error message, it listed the local_font I uploaded in the browse section of http://127.0.0.1/MYSITE/web/admin/appearance/font

  • Neslee Canil Pinto committed 4989987 on 8.x-3.x
    Issue #3166900 by Neslee Canil Pinto: Add font display causes unexpected...
neslee canil pinto’s picture

@GDH did you tried clearing cache. I am not getting that error in my drupal 9 site. And made a new release, which fixes this issue, can you please update the module to latest release.

sameer’s picture

I'm getting the same error as GDH. I'm using version 8.x-3.4 and Drupal 9.0.5.

I enable @fontyourface and @fontyourface - Local Fonts
Add custom font.
Get error:
Drupal\Core\Config\Schema\SchemaIncompleteException: Entity type 'Drupal\Core\Config\Entity\ConfigEntityType' is missing 'config_export' definition in its annotation in Drupal\Core\Config\Entity\ConfigEntityBase->toArray() (line 251 of core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php).

Go to Browse. Font appears here. I enable it.
Add font display.
Get same error:
Drupal\Core\Config\Schema\SchemaIncompleteException: Entity type 'Drupal\Core\Config\Entity\ConfigEntityType' is missing 'config_export' definition in its annotation in Drupal\Core\Config\Entity\ConfigEntityBase->toArray() (line 251 of core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php).

jfeltkamp’s picture

The module looks soooooooo good to me. This is exactly what I need.

But yes, same error, but in a totally differnt place.

Entity type 'Drupal\Core\Config\Entity\ConfigEntityType' is missing 'config_export' definition in its annotation.

There are some annotations to fix in the entity type. (Drupal\fontyourface\Entity\FontDisplay The annotation config on top of the class managing the Font-Display config entity. )


/**
 * Defines the Font display entity.
 *
 * @ConfigEntityType(
 *   id = "font_display",
 *   label = @Translation("Font display"),
 *   handlers = {
 *     "list_builder" = "Drupal\fontyourface\FontDisplayListBuilder",
 *     "form" = {
 *       "add" = "Drupal\fontyourface\Form\FontDisplayForm",
 *       "edit" = "Drupal\fontyourface\Form\FontDisplayForm",
 *       "delete" = "Drupal\fontyourface\Form\FontDisplayDeleteForm"
 *     },
 *     "route_provider" = {
 *       "html" = "Drupal\fontyourface\FontDisplayHtmlRouteProvider",
 *     },
 *   },
 *   config_prefix = "font_display",
 *   admin_permission = "administer font entities",
 *   entity_keys = {
 *     "id" = "id",
 *     "label" = "label",
 *     "uuid" = "uuid",
 *     "font_url" = "font_url",
 *     "style" = "style",
 *     "weight" = "weight",
 *     "fallback" = "fallback",
 *     "selectors" = "selectors",
 *     "theme" = "theme"
 *   },
 *   links = {
 *     "add-form" = "/admin/appearance/font/font_display/add",
 *     "edit-form" = "/admin/appearance/font/font_display/{font_display}/edit",
 *     "delete-form" = "/admin/appearance/font/font_display/{font_display}/delete",
 *     "collection" = "/admin/appearance/font/font_display"
 *   },
 *    config_export = {
 *     "id",
 *     "label",
 *     "description",
 *     "...",
 *   }
 * )
 * )
 */
class FontDisplay extends ConfigEntityBase implements FontDisplayInterface {
...
}

The last part with config_export is missing in the original code

I will have a look at this and try to fix in the next few days.

jfeltkamp’s picture

StatusFileSize
new1.81 KB

I created a patch where I fixed the issues with the missing 'config_export' thing (see above).
Now it is working for me in Drupal 9.

neslee canil pinto’s picture

@JFeltkamp great work. Thanks. I did a test in my local and its working now without any errors.

neslee canil pinto’s picture

Status: Needs review » Fixed

Committed to dev branch. Thanks.

neslee canil pinto’s picture

Version: 8.x-3.3 » 8.x-3.x-dev

Status: Fixed » Closed (fixed)

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