Problem/Motivation
Fix fatal error :
Error: Typed property Drupal\s3fs_bucket\Entity\S3Bucket::$bucket_type must not be accessed before initialization in Drupal\s3fs_bucket\Entity\S3Bucket->getPluginId() (line 123 of modules/contrib/s3fs/modules/s3fs_bucket/src/Entity/S3Bucket.php).
Full stack trace:
Error: Typed property Drupal\s3fs_bucket\Entity\S3Bucket::$bucket_type must not be accessed before initialization in Drupal\s3fs_bucket\Entity\S3Bucket->getPluginId() (line 123 of modules/contrib/s3fs/modules/s3fs_bucket/src/Entity/S3Bucket.php).
Drupal\s3fs_bucket\Form\S3BucketForm->buildEntityForm(Array, Object, Object) (Line: 81)
Drupal\s3fs_bucket\Form\S3BucketForm->form(Array, Object) (Line: 107)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('s3fs_bucket_add_form', Object) (Line: 284)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 53)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
- Install module s3fs_bucket
- Browse to
/admin/config/s3/s3fs_bucket/add
- Confirm the page crashes with fatal error.
Proposed resolution
Fix the error, see similar issues with solutions:
Solution: Initialize property $bucket_type.
Comments
Comment #2
dydave commentedComment #4
dydave commentedPHPUnit tests seem to be failing for other reasons...
See failing tests for 4.0.x:
https://git.drupalcode.org/project/s3fs/-/pipelines/220039
Let me know if you'd like this particular error to also get added to tests.
Thanks in advance for your feedback and reviews!
Comment #6
cmlaraThank you for the MR.
Sorry for the delay, I was debating if we wanted this to be an empty string, or to be NULL.
I was thinking NULL as that was what these used before typedef was added, however an empty string will make long term code usage easier and we have hasValidBucketPlugin() to validate if the plugin is actually valid.
String only with empty default seems perfectly reasonable.
Merging without passing tests as those are held up on multiple D10.3 BC breaks.
Comment #7
dydave commentedThanks a lot Conrad (@cmlara) for the prompt feedback, review, merge and additional details!
I'll keep working on more issues and MRs, mostly for D10.3.
Thanks again!