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

  1. Install module s3fs_bucket
  2. Browse to /admin/config/s3/s3fs_bucket/add
  3. Confirm the page crashes with fatal error.

Proposed resolution

Fix the error, see similar issues with solutions:

Solution: Initialize property $bucket_type.

Issue fork s3fs-3460900

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

DYdave created an issue. See original summary.

dydave’s picture

Title: Typed property must not be accessed before initialisation on D10.3 » Typed property must not be accessed before initialization on D10.3
Issue summary: View changes

dydave’s picture

Status: Active » Needs review

PHPUnit 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!

  • cmlara committed 49485c3e on 4.0.x authored by DYdave
    Issue #3460900 by DYdave: Typed property must not be accessed before...
cmlara’s picture

Status: Needs review » Fixed

Thank 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.

dydave’s picture

Thanks 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!

Status: Fixed » Closed (fixed)

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