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

Smarty 3/4 - Fix prepending extension template directories #30148

Merged
merged 1 commit into from
May 8, 2024

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented May 7, 2024

Overview

Fixes civicrm/org.civicrm.contactlayout#143

Before

Extensions would prepend their directories under smarty2, but smarty3 & 4 would append them, breaking template overrides.

After

Smarty 2,3&4 all prepend template directories

Technical Details

It was a bit tough to wrangle the same behavior out of all 3 versions, but resorting to lowest-common-denominator getter/setter functions works well.

Note: I ended up adding a special case for Smarty2 since it doesn't have getter/setter functions (at least not on older versions of Civi, which we still support via mixin shims). So this PR no longer depends on civicrm/civicrm-packages#397

Copy link

civibot bot commented May 7, 2024

🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷

Introduction for new contributors...
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
Quick links for reviewers...

➡️ Online demo of this PR 🔗

@civibot civibot bot added the 5.74 label May 7, 2024
colemanw added a commit to colemanw/civicrm-packages that referenced this pull request May 7, 2024
mixin/smarty-v2@1/mixin.php Outdated Show resolved Hide resolved
Before: Extensions would prepend their directories under smarty2, but smarty3 & 4 would append them, breaking template overrides.

After: Smarty 2,3&4 all prepend template directories

Fixes civicrm/org.civicrm.contactlayout#143
@colemanw colemanw force-pushed the smartyTemplateDir branch from 79554c5 to 2b2dfac Compare May 8, 2024 01:57
@totten
Copy link
Member

totten commented May 8, 2024

Since this is specifically aimed at the various edges of Smarty (2/3/4/5), I ran the mixin test for smarty-v2 with each version of Smarty. All passed. 👍

(There were php82 warnings, esp w/smarty2+3+5, but I believe they're all pre-existing.)

I'll do one more check to with civix using this in a backport...

@totten
Copy link
Member

totten commented May 8, 2024

OK, yup, backport loads fine with civix on an older version of CiviCRM.

@totten totten merged commit af98824 into civicrm:5.74 May 8, 2024
3 checks passed
@totten totten deleted the smartyTemplateDir branch May 8, 2024 04:06
@colemanw colemanw restored the smartyTemplateDir branch May 8, 2024 12:59
eileenmcnaughton pushed a commit to eileenmcnaughton/civicrm-core that referenced this pull request May 8, 2024
Smarty 3/4 - Fix prepending extension template directories
@totten totten deleted the smartyTemplateDir branch May 17, 2024 07:44
@eileenmcnaughton
Copy link
Contributor

Just noting that in our experience getTemplateDir() can be very slow to call - ie we got up to 7 seconds with repeated calling. Not completely sure why it gets slower - but it is on realPath() within that function it slows down. Not too sure the fix as I got such a big improvement from one of the other things on https://lab.civicrm.org/dev/core/-/issues/5243 that this might not matter if we resolve that

@eileenmcnaughton
Copy link
Contributor

I performance tested - if it wasn't for the first line in this table this would be in my sights ... https://lab.civicrm.org/dev/core/-/issues/5243#note_164882

@eileenmcnaughton
Copy link
Contributor

Ok - this does seem to be the culprit for the slow down - but we have been firing up some variants that address it & we can look at the pre-existing issue once Montreal is online

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants