Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP Fatal error: Cannot declare class modTemplateVarInputRenderText #16410

Merged
merged 1 commit into from Oct 3, 2023

Conversation

JoshuaLuckers
Copy link
Contributor

What does it do?

It prevents the fallback render method/class to be loaded twice by registering it to the array cache to prevent double loading of the class.

Why is it needed?

To fix a PHP Fatal error: Cannot declare class modTemplateVarInputRenderText.

How to test

  • Make sure you have a Template without TV's assigned to it.
  • First create a TV with a valid Input type and assign it to the template.
  • Create a second TV with Input Typ text and assign it to the template.
  • Create a new resource with this Template
  • Editing it works like expected
  • Now adjust the first Template Variable via the database and give it an invalid input type.
  • Edit the resource again

Related issue(s)/PR(s)

Resolves #16402

Prevent the fallback render method/class to be loaded twice.
@cla-bot cla-bot bot added the cla-signed CLA confirmed for contributors to this PR. label Mar 21, 2023
@codecov
Copy link

codecov bot commented Mar 21, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.01 ⚠️

Comparison is base (31ad611) 21.75% compared to head (a26ccb9) 21.75%.

Additional details and impacted files
@@             Coverage Diff              @@
##                3.x   #16410      +/-   ##
============================================
- Coverage     21.75%   21.75%   -0.01%     
  Complexity    10478    10478              
============================================
  Files           561      561              
  Lines         31587    31588       +1     
============================================
  Hits           6872     6872              
- Misses        24715    24716       +1     
Impacted Files Coverage Δ
core/src/Revolution/modTemplateVar.php 25.97% <0.00%> (-0.05%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@smg6511 smg6511 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to others who may test this: If running php 8.2, you may find you're unable to force the fatal error to be thrown (I saw no warnings or notices for that matter). I found that I only see the issue when running php <= 8.1.13. Perhaps something changed in 8.2 regarding the redeclaration of classes?

@JoshuaLuckers
Copy link
Contributor Author

Note to others who may test this: If running php 8.2, you may find you're unable to force the fatal error to be thrown (I saw no warnings or notices for that matter). I found that I only see the issue when running php <= 8.1.13. Perhaps something changed in 8.2 regarding the redeclaration of classes?

Or maybe a bug in PHP 8.2 😝

@JoshuaLuckers JoshuaLuckers added the pr/review-needed Pull request requires review and testing. label May 9, 2023
@JoshuaLuckers JoshuaLuckers added this to the v3.0.4 milestone May 9, 2023
@modxcommunity
Copy link
Collaborator

This pull request has been mentioned on MODX Community. There might be relevant details there:

https://community.modx.com/t/custom-tv-cannot-declare-class-modtemplatevarinputrendertext/6942/6

@rthrash rthrash added the bug The issue in the code or project, which should be addressed. label Sep 29, 2023
@opengeek opengeek merged commit 6a2e0b1 into modxcms:3.x Oct 3, 2023
opengeek pushed a commit that referenced this pull request Oct 3, 2023
…xt (#16410)

Prevent the fallback render method/class to be loaded twice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue in the code or project, which should be addressed. cla-signed CLA confirmed for contributors to this PR. pr/review-needed Pull request requires review and testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MODX3 PHP Fatal error: Cannot declare class modTemplateVarInputRenderText
5 participants