Problem/Motivation
Issue 1
After upgrading to entity_legal 4.0.0-alpha2, our our user registration form submission becomes broken with this error:
The website encountered an unexpected error. Please try again later.<br><br><em class="placeholder">LogicException</em>: The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution. in <em class="placeholder">Drupal\Core\Database\Connection->__sleep()</em> (line <em class="placeholder">1712</em> of <em class="placeholder">core/lib/Drupal/Core/Database/Connection.php</em>).
<pre class="backtrace">serialize() (Line: 14)
Drupal\Component\Serialization\PhpSerialize::encode() (Line: 111)
Drupal\Core\KeyValueStore\DatabaseStorageExpirable->doSetWithExpire() (Line: 127)
Drupal\Core\KeyValueStore\DatabaseStorageExpirable->setWithExpire() (Line: 193)
Drupal\Core\Form\FormCache->setCache() (Line: 463)
Drupal\Core\Form\FormBuilder->setCache() (Line: 441)
Drupal\Core\Form\FormBuilder->rebuildForm() (Line: 633)
Drupal\Core\Form\FormBuilder->processForm() (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult() (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 53)
Asm89\Stack\Cors->handle() (Line: 270)
Drupal\shield\ShieldMiddleware->bypass() (Line: 137)
Drupal\shield\ShieldMiddleware->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 704)
Drupal\Core\DrupalKernel->handle() (Line: 19)
</pre>
Issue 2
The second issue is that the admin User creation form (same UserRegistrationForm) now shows the inline Entity Legal entity with acceptance checkbox.
Proposed resolution
Issue 1
My debugging reveals that the plugin ProfileFormEmbedded is also serialised in the form cache. The plugin has recently got new services injected in the latest version and it breaks the serialisation.
We should include the DependencySerializationTrait trait in the base plugin to fix the error.
Issue 2
Version 4-alpha2 refactored the EntityLegalPluginBase::getDocumentsForMethod()
. In alpha1, that method returns an empty array for administrators and anonymous users. After being refactored, the method no longer returns so.
In alpha1:
if (\Drupal::currentUser()->hasPermission('administer entity legal')) {
return [];
}
In alpha2:
if ($this->currentUser->hasPermission('administer entity legal')) {
$this->documents = [];
}
I think the refactor incorrectly changed the logic of the method hence the previous behaviour must be restored.
Remaining tasks
User interface changes
API changes
Data model changes