Giter Site home page Giter Site logo

Comments (8)

eiriksm avatar eiriksm commented on June 3, 2024 1

Just to note, this is the case for many other contrib modules. Usually because they somewhat do not follow conventions in the api.php file, but even still. It's a documentation piece of a file, so it's kind of annoying.

Here is just a couple I experienced this morning:

Fatal error: Cannot redeclare elasticsearch_helper_aws_elasticsearch_helper_client_builder_alter() (previously declared in /__w/nymedia_commerce_profile/nymedia_commerce_profile/web/modules/contrib/elasticsearch_helper/elasticsearch_helper_aws/elasticsearch_helper_aws.module:17) in /__w/nymedia_commerce_profile/nymedia_commerce_profile/web/modules/contrib/elasticsearch_helper/elasticsearch_helper.api.php on line 19
Fatal error: Cannot redeclare ckeditor_media_embed_ckeditor_media_embed_object_alter() (previously declared in /__w/store/store/drupal/modules/contrib/ckeditor_media_embed/ckeditor_media_embed.module:136) in /__w/store/store/drupal/modules/contrib/ckeditor_media_embed/ckeditor_media_embed.api.php on line 21

from phpstan-drupal.

eiriksm avatar eiriksm commented on June 3, 2024 1

Added a PR to be able to opt out of loading api.php files here: #641

from phpstan-drupal.

mglaman avatar mglaman commented on June 3, 2024 1

Sorry about this. I didn't think folks had that broken of .api.php files. I like the idea of opting out.

I'm going to rework your PR @eiriksm. I want to establish a bleeding-edge concept like in PHPStan. New rules are added as off by default, but including that file will enable them.

from phpstan-drupal.

eiriksm avatar eiriksm commented on June 3, 2024 1

Wow you are the most kind, knowledgeful maintainer ever ❤️ I have a feeling you more or less posted this just after waking up, so taking the time here to appreciate your work and a new release breaking stuff just highlights the impact of your work. Thank you, Matt!

from phpstan-drupal.

mglaman avatar mglaman commented on June 3, 2024

Huh. The file should be loaded with a catch for even fatal errors.

That module needs to be fixed.

But also see if we can harden the error catching here.

from phpstan-drupal.

peterwcm avatar peterwcm commented on June 3, 2024

Fatal errors cannot be caught as far as I know so I don't think you can work around that easily. While we can 'fix' the contrib module by adding a patch to have that hook commented, it might not make sense to the contrib maintainers.

From my understanding, api.php file is more of a documentation piece for custom hooks or related hook usage that's related to the module. They are just code examples and it's not meant to be included by others so logically it's not an issue from their end. What do you think?

from phpstan-drupal.

eiriksm avatar eiriksm commented on June 3, 2024

To add to this: eiriksm#2 is a PR I created against my own fork, which demonstrates the bug. A redeclaration in an api.php file does not cause any issues in running a drupal site, but it totally crashes phpstan here ✌️

from phpstan-drupal.

eiriksm avatar eiriksm commented on June 3, 2024

Tried a couple of hacks to catch such a fatal error, but came up short. Seems like we should either

  • Revert the commit
  • or make it either opt-in or possible to opt out

from phpstan-drupal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.