-
-
Notifications
You must be signed in to change notification settings - Fork 812
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
dev/core#2748 Remove unused token assigns #21059
dev/core#2748 Remove unused token assigns #21059
Conversation
(Standard links)
|
7451f1e
to
6cebcf6
Compare
I did a clean build on 5.40 then edited the corresponding
Then made a snapshot and ran the upgrade using CLI and web UI: This upgrade seems to create all the empty The message about |
oh - @totten the intent with the message is that it is generated AFTER the upgrade in case any were missed - I guess I misunderstood the order of events? |
$upgradeMessage[] = $templateUpgrader->getMessageTemplateWarning('contribution_invoice_receipt', '$first_name', 'contact.first_name'); | ||
$upgradeMessage[] = $templateUpgrader->getMessageTemplateWarning('contribution_invoice_receipt', '$last_name', 'contact.last_name'); | ||
$upgradeMessage[] = $templateUpgrader->getMessageTemplateWarning('contribution_invoice_receipt', '$displayName', 'contact.display_name'); | ||
if (!empty($upgradeMessage)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@totten so if I just remove this bit is it right ? (Message wise - the face it is checking before rather than after is a separate & maybe not that solvable issue)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that emptiness check doesn't seem right. Arrays like [NULL,NULL,NULL]
and ['','','']
are not empty()
, but they are devoid of meaningful content. Maybe something like this...
$upgradeMessage = array_filter($upgradeMessage, function($v) { return !empty($v); });
... would trim the array down to only show meaningful content.
Yeah, I find that confusing too. Pulled it up in a debugger and also ran it in verbose mode ( So I think what happens is that it runs
|
0e11866
to
bbb7e15
Compare
@totten I've ripped out the html (I possibly went too far but it took @demeritcowboy about 4 commits to get tit right last time :-) & made the message a bit more accurate. I also added a version check. But to go the extra step & only provide the message if it might apply seems like a bigger challenge? |
or rather - only display the message if it might STILL apply after the upgrade has run |
52ca08f
to
01b5d01
Compare
@totten I've updated this - I an on the fence about adding a conditional warning to check the status page - or just relying on it (that could be a follow up) - I copied the 'name' pattern from Dr when & I suspect that I'd need to revist to be able to call the check usefully from the upgrade script I'm inclined to leave it for these tokens as it's been quite a while since they were used |
01b5d01
to
50db89c
Compare
@totten I think we can merge this now? It is now using the status check mechanism to warn. These variables have not been used in core templates for a long time so as a minor cleanup we should be good on this one. (now that we have a mapping between smarty & tplparams we have another tool for this stuff - but this is a complex bit of code so I think it's stil worth doing this cleanup - especially since it is so long since we shipped templatest that used these) |
This has conflicts now. |
50db89c
to
d8fa0f8
Compare
@demeritcowboy thanks - the upgrade script not surprisingly - fixed now |
CRM/Utils/Token.php
Outdated
@@ -1952,6 +1952,12 @@ public static function getTokenDeprecations(): array { | |||
'contribution_invoice_receipt' => [ | |||
'$display_name' => 'contact.display_name', | |||
], | |||
'contribution_online_receipt' => [ | |||
'$contributionMode' => 'no longer available / relevant', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be $contributeMode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah thanks - fixed!
Since this went through some iterations, just to confirm:
|
d8fa0f8
to
1f7cb15
Compare
@demeritcowboy that is correct - ideally no action is required but if there were some more complex smarty stuff going on it might be |
Ok I think that makes sense here - it can't really replace arbitrary smarty like |
thanks @demeritcowboy - nice to get rid of that |
Per civicrm#21059 its a really long time since this was in the stock templates
Overview
Per https://lab.civicrm.org/dev/core/-/issues/2748 - this removes some no-longer-used token assigns & adds an upgrade message in case people have templates still referring to them
Before
We assign $first_name, $last_name, $displayName $contributeMode to the template but they have not been in the shipped templates for a long time - there is a preferred alternative (token) for the first 3
After
Assigns removed, system checks will warn
Technical Details
These variables are coming from the dreaded
loadRelatedObjects
function and in turn fromloadRelatedEntitiesByID
- which we hope to decommissionComments