This happens on cache clear, or right after install.

Here's the full stacktrace:

Drupal\Core\Entity\EntityType->hasHandlerClass('form') (Line: 240)
panopoly_media_entity_type_alter(Array, NULL, NULL) (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter('entity_type', Array) (Line: 366)
Drupal\Core\Plugin\DefaultPluginManager->alterDefinitions(Array) (Line: 134)
Drupal\Core\Entity\EntityTypeManager->findDefinitions() (Line: 175)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 796)
Drupal\Core\Entity\EntityManager->getDefinitions() (Line: 237)
Drupal\Core\Extension\ModuleInstaller->install(Array, 1) (Line: 83)
Drupal\Core\ProxyClass\Extension\ModuleInstaller->install(Array) (Line: 92)
Drupal\panopoly\Installer\Form\PanopolyDemoInstallerForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 590)
Drupal\Core\Form\FormBuilder->processForm('panopoly_demo_installer_form', Array, Object) (Line: 319)
Drupal\Core\Form\FormBuilder->buildForm('panopoly_demo_installer_form', Object) (Line: 954)
install_get_form('Drupal\panopoly\Installer\Form\PanopolyDemoInstallerForm', Array) (Line: 624)
install_run_task(Array, Array) (Line: 577)
install_run_tasks(Array, NULL) (Line: 118)
install_drupal(Object) (Line: 44)

Comments

dsnopek created an issue. See original summary.

dsnopek’s picture

Issue summary: View changes
kerasai’s picture

@dsnopek, I'm not able to reproduce this using a composer-installed Panopoly at either a658578 (from 6/12/2019) d5032aa (current).

I see in the code where this would be happening, but this case has not occurred with my testing. Is there anything notable about your setup or installation? I've got just a clean install via the UI as well as drush, with the demo content.

Regarding the cause of the error, I suspect there's a module altering the entity types, perhaps with via hook_entity_type_alter, but it's improperly setting the file entity's form handler class to an array instead of a string. The error then culminates in panopoly_media when it attempts to add the delete form on panopoly_media:240.

dsnopek’s picture

So, I just did a fresh composer create-project and I'm still getting this error. :-(

In case it matters, I've got Drupal 8.7.3 with PHP 7.2.

And, also, I think it may actually be possible for handler classes to be arrays. There is this $nested parameter to EntityType::hasHandlerClass() which has something to do with them being array's, but I don't totally understand it.

dsnopek’s picture

Yeah, looking at the code in panopoly_media.module, shouldn't this bit:

$entity_types['file']->hasHandlerClass('form')

... be changed to something like:

$entity_types['file']->hasHandlerClass('form', 'delete')
kerasai’s picture

Status: Active » Needs review
StatusFileSize
new788 bytes

I'm running the same versions, but still have yet to see this error in logs/console or while step debugging. The condition that triggers that warning will only occur if the file entity has form handlers set, which for me it does not.

Anyhow, see attached patch for a fix. This should clear up the problem. It's a bit clunky, because, of course, there is no direct way to obtain the form handlers (will throw same warning) so we have to obtain all of the handlers and deal with it that way.

  • dsnopek committed 598797b on 8.x-2.x authored by kerasai
    Issue #3061339 by kerasai: Warning: class_exists() expects parameter 1...
dsnopek’s picture

Status: Needs review » Fixed

That totally fixes it for me! Committed, thanks :-)

Status: Fixed » Closed (fixed)

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