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

Avoid e-notices on pages with tabs #22892

Merged

Conversation

braders
Copy link
Contributor

@braders braders commented Mar 5, 2022

Overview

Avoid e-notices on pages with tabs, by ensuring tabHeader items contain the necessary keys.

Before

On pages with tabs (manage event, campaign conduce survey, etc) e-notices were frequently triggered from within TabHeader.tpl. These resulted from TabHeader.tpl trying to read tabHeader keys from each top-level array item.

After

The tabHeader array is re-assigned in CRM_Core_Form and CRM_Core_Page just before the template is rendered, with all keys defined for each tabHeader tab array.

Technical Details

This could have been resolved by changing the arrays assigned to tabHeader within induvidual pages. However, this centralises the logic incase new array keys are added in future, and will ensure notices are not caused by any extensions using TabHeader.tpl.

@civibot
Copy link

civibot bot commented Mar 5, 2022

(Standard links)

@civibot civibot bot added the master label Mar 5, 2022
@@ -199,6 +199,8 @@ public function run() {
$pageTemplateFile = $this->getHookedTemplateFileName();
self::$_template->assign('tplFile', $pageTemplateFile);

self::$_template->addExpectedTabHeaderKeys();
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if just to keep things together if this should be up at line 162? It seems to get rid of the notices either way. Was there a reason to put it here? I don't have a strong opinion either way since I'm not aware of any situation where it would make a difference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@demeritcowboy This is intentional. Line 162 (i.e. where ensureVariablesAreAssigned is called) is within the constructor. That is fine for ensureVariablesAreAssigned, which is just setting default values to be overridden later.

That's not what we're doing in addExpectedTabHeaderKeys - here we're modifying assigned variables just before rendering, and so the page's run() function has to have run. Therefore running addExpectedTabHeaderKeys in the constructor would be too early.

There is probably an argument to moving ensureVariablesAreAssigned to line ~200, just before the new call to addExpectedTabHeaderKeys, but I have not looked closely to see if there would be side-effects to that change.

@demeritcowboy demeritcowboy merged commit 0868278 into civicrm:master Mar 6, 2022
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.

2 participants