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

Throw spaghetti #22070

Merged
merged 2 commits into from
Nov 23, 2021
Merged

Throw spaghetti #22070

merged 2 commits into from
Nov 23, 2021

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Nov 13, 2021

Overview

Enable escape on output for unit tests

Before

Not enabled for unit tests - issets & things that are notices when it is on sneak through

After

Enabled for unit tests - although I suspect only some since I think there would have been more failures otherwise.

Technical Details

Comments

https://github.com/civicrm/civicrm-core/pull/22070/files#diff-b0e39754f5c0209c45b75774d772d429b3f947203d0681794120256f1c4d2c68R412 is the key line

@civibot
Copy link

civibot bot commented Nov 13, 2021

(Standard links)

@totten
Copy link
Member

totten commented Nov 18, 2021

Spaghetti

@eileenmcnaughton
Copy link
Contributor Author

test this please

@eileenmcnaughton
Copy link
Contributor Author

@seamuslee001 the spaghetti stuck!

@colemanw
Copy link
Member

Neat. Can you maybe add a description to this PR @eileenmcnaughton so we know what we're looking at (other than Tim's spaghetti monster illustration)

@eileenmcnaughton
Copy link
Contributor Author

@colemanw doesn't it say it all?

@colemanw colemanw merged commit 0e15238 into civicrm:master Nov 23, 2021
@colemanw colemanw deleted the test_id branch November 23, 2021 20:56
@colemanw
Copy link
Member

Ok, tests are happy and this is a step in the right direction.

@davejenx
Copy link
Contributor

I've hit a side-effect of the addition of 6 lines to CRM/Report/Form.php at line 2500:

       if (!empty($value['no_display'])) {
         unset($this->_columnHeaders[$key]);
       }
+      foreach (['colspan', 'type'] as $expectedKey) {
+        if (!isset($this->_columnHeaders[$key][$expectedKey])) {
+          // Ensure it is set to prevent smarty notices.
+          $this->_columnHeaders[$key][$expectedKey] = FALSE;
+        }
+      }
     }

In a custom report, with the above change in place, no_display on items in $this->_columnHeaders is no longer respected: these columns are displayed. With these 6 lines removed, it works as before: the columns are hidden. Alternatively putting those 6 lines within an else block under the !empty($value['no_display']) condition also works.

The custom report does all its business in postProcess(), with a fixed set of columns defined there with e.g.

    $this->_columnHeaders = array(
      'batch_title' => array('title' => 'Batch'),
      'receive_date' => array('title' => 'Date Received'),
      ...,
      'contact_id' => array('title' => 'Contact ID', 'no_display' => TRUE),

Then constructs a query & runs buildRows(), formatDisplay(), doTemplateAssignment(), endPostProcess(). Worked in 5.35.2. Does this need rejigging to work with current CRM/Report/Form.php or should CRM/Report/Form.php be amended?

@eileenmcnaughton
Copy link
Contributor Author

@davejenx so my reading is that the lines above unset no_display and then they are re-added but the 'ensure fields are set part' - it feels like the easiest would be to reverse the order- so the isset happens last?

@davejenx
Copy link
Contributor

Hi @eileenmcnaughton , thanks for taking a look!

Yes, reversing the order works, so that the 6 added lines (from foreach (['colspan', 'type'] ...)) go above the if (!empty($value['no_display'])) condition instead of below.

Or as I suggested, put those 6 lines within an else block under the !empty($value['no_display']) condition - that way, we don't create extra entries only to delete their parent entry afterwards.

@eileenmcnaughton
Copy link
Contributor Author

@davejenx do you want to put one of those options up as a PR

@davejenx
Copy link
Contributor

Thanks @eileenmcnaughton , done: #23321 .

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.

4 participants