Problem/Motivation
This one was tough. Everything worked fine on my dev machine, but the live instances throwed the error
TypeError: Drupal\restui\Form\RestUIForm::__construct(): Argument #2 ($module_handler) must be of type Drupal\Core\Extension\ModuleHandler, Drupal\hook_event_dispatcher\HookEventDispatcherModuleHandler given, called in /var/www/m2b/modules/contrib/restui/src/Form/RestUIForm.php on line 97 in Drupal\restui\Form\RestUIForm->__construct() (line 83 of modules/contrib/restui/src/Form/RestUIForm.php).
at me. The thing is both composer.lock contained this here:
{
"name": "drupal/restui",
"version": "1.21.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/restui.git",
"reference": "8.x-1.21"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/restui-8.x-1.21.zip",
"reference": "8.x-1.21",
"shasum": "2a67dc2c1953dced0bddaff25e5c60784ee0178c"
},
"require": {
"drupal/core": "^8.7.7 || ^9 || ^10"
},
but for some reason on my localhost the RestUIForm.php contained:
public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, AuthenticationCollectorInterface $authentication_collector, array $formats, ResourcePluginManager $resourcePluginManager, EntityStorageInterface $resource_config_storage, MessengerInterface $messenger) {
parent::__construct($config_factory);
$this->moduleHandler = $module_handler;
$this->authenticationCollector = $authentication_collector;
$this->formats = $formats;
$this->resourcePluginManager = $resourcePluginManager;
$this->resourceConfigStorage = $resource_config_storage;
$this->messenger = $messenger;
}
and the live instance contained
public function __construct(ConfigFactoryInterface $config_factory, ModuleHandler $module_handler, AuthenticationCollectorInterface $authentication_collector, array $formats, ResourcePluginManager $resourcePluginManager, EntityStorageInterface $resource_config_storage, MessengerInterface $messenger) {
parent::__construct($config_factory);
$this->moduleHandler = $module_handler;
$this->authenticationCollector = $authentication_collector;
$this->formats = $formats;
$this->resourcePluginManager = $resourcePluginManager;
$this->resourceConfigStorage = $resource_config_storage;
$this->messenger = $messenger;
}
Notice the #2 Parameter.
It took me a while, BUT the composer.lock contains a link to that https://ftp.drupal.org/files/projects/restui-8.x-1.21.zip download location and when I extract it, it contains the wrong #2 parameter. The 8.x-1.x-dev / https://ftp.drupal.org/files/projects/restui-8.x-1.x-dev.zip seems to have fixed it already.
What is strange to me is, that my composer contained a like like this: "drupal/restui": "^1.20"
and all instances had the 1.21.0 installed.
A fix seems to be to use composer require 'drupal/restui:1.x-dev@dev'
until 1.22 is released with a correct #2 paramater.