Describe your bug or feature request.

 ------ ---------------------------------------------------------------------- 
  Line   modules/price/src/Element/Price.php                                   
 ------ ---------------------------------------------------------------------- 
  41     \Drupal calls should be avoided in classes, use dependency injection  
         instead                                                               
         🪪  globalDrupalDependencyInjection.useDependencyInjection      

Issue fork commerce-3589151

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

jsacksick created an issue. See original summary.

aayushpathak’s picture

working..

aayushpathak’s picture

Status: Active » Needs work
aayushpathak’s picture

Status: Needs work » Needs review

tbkot made their first commit to this issue’s fork.

jsacksick’s picture

Status: Needs review » Needs work

The right fix is to use the ContainerFactoryPluginInterface, not ignore the error.

tbkot’s picture

Status: Needs work » Needs review

jsacksick’s picture

Status: Needs review » Fixed

Thank you, merged!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

klausi’s picture

Status: Fixed » Needs work

This change is not correct:

Error: Call to undefined method Drupal\Core\Render\Element\FormElementBase::create() in Drupal\commerce_price\Element\Price::create() (line 44 of modules/contrib/commerce/modules/price/src/Element/Price.php).

the parent class FormElementBase has no create() method, so we cannot call parent::create().

Unfortunately PHPStan is only set to level 1 in the commerce module, a higher level would have easily detected this mistake. Funny that a phpstan fix issue introduces a bug that would have been caught by phpstan.

@aayushpathak I assume you vibe-coded this change and never tested the code manually? Please don't do that in the future.

I'll try to make a fix, should be only 1 line change.

klausi’s picture

Status: Needs work » Needs review
jsacksick’s picture

Status: Needs review » Fixed

@klausi: A parent create() exists in D11, within Drupal\Core\Plugin\PluginBase. But it doesn't in D10.
I'll merge your MR, thanks for the fix :).

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • klausi committed 38dc0483 on 3.x
    fix: #3589151 Fix undefined parent create() method error
    
klausi’s picture

Aha, good point about Drupal 11 - I was testing with Drupal 10, sorry for the confusion.

Status: Fixed » Closed (fixed)

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