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

PCHR-4346: CiviCRM Upgrade #2899

Merged
merged 9 commits into from
Dec 14, 2018

Conversation

davialexandre
Copy link
Member

@davialexandre davialexandre commented Oct 23, 2018

Overview

This PR updates CiviHR to work with CiviCRM 5.7.0.

Technical Details

Syncing overridden files

As usual, overridden files have been synced with core. Here is the list of them with a link to a diff comparing them to the respective file in core. Note that not all the overridden files required updates, as some their originals in core have not been touched since CiviCRM 5.3.1:

  • CRM/Hrjobcontract/Dedupe/Merger.php: diff
  • templates/CRM/Hrjobcontract/Form/Merge.tpl: diff
  • hrjobcontracts/CRM/Export/BAO/Export.php: diff

The hrui/templates/CRM/Contact/Page/View/Summary.tpl overridden file has been replaced with the hrui/templates/CRM/Contact/Page/Inline/Basic.tpl file. The reason for this is this PR where part of the template code was extracted to another file. Our customized code was exactly in the part that was extracted, so now we override the new extracted file instead. Here is a diff showing the customizations: https://www.diffchecker.com/tDtrMUUa

Besides that, I've taken the chance to optimize the customized code in that file by removing some duplication and unecessary variables. You can see the difference by comparing the previous diff with the one for the Summary.tpl file from the previous CiviCRM upgrade: https://www.diffchecker.com/c0rENpFo

The hrui/CRM/Core/BAO/Navigation.php overridden file has been deleted. This file has been overridden for multiple different reasons in the past, but today, it was holding only one customization to fix a bug in CiviCRM core. So, instead of syncing the file, I decided to submit a PR fixing this in core. It will be only included in CiviCRM 5.8, so I've added it to your patches branch.

Undefined index error in the HRJobContract.getFullDetails API

After the upgrade, the tests for this API started failing. This was caused by a new property added to the DAO class in CiviCRM. Check the commit message of b728232 for more details

…FullDetails API

This API call is an optimized way to fetch all the information for a Job Contract,
which is stored in multiple different database tables. It does that by running
a single SQL query, joining all the tables and the necessary fields.

In the resultset, in order to differentiate which field belongs to which entity,
each field is prefixed with the entity name (examplei: details__<field_name>). After
the data is fetched from the database, the `HRJobContractRevision::normalizeFullDetailsResult()`
was used to loop through all the fields in the resultset, detect to which entity they
belong to and organize the data in a proper way.

Besides the fields returned by the query, the resultset object also contains some internal
fields. In the past, all of these fields were prefixed with an underscore, but on
civicrm/civicrm-core#12276 a new `resultCopies` field was added,
and since it does not start with an underscore, the logic to filter out the internal
fields stopped working. To fix that, instead of looping through all of the fields from
the resultset, we call the `toArray()` method which will return a list of fields and
values containing only those returned by the SQL query.
In civicrm/civicrm-core@4aced66, the Summary.tpl
file has been refactored in core and part of it was extracted to the
Basic.tpl template.

Our customization was located exactly in the piece of code that has been
extracted, so the sync was done by:

- Overridding the Basic.tpl template in hrui
- Moving the custom code from the Summary.tpl file to the new Basic.tpl one
- Deleting the old Summary.tpl file, as it didn't contain any custom code anymore

As part of this, I also did some small refactoring in the custom code,
removing some unecessary ifs and custom variables to make it less different
from the original file as possible
The only reason we needed the overridden file was to fix an
error in CiviCRM Core. Since this has been now fixed in core,
we don't need to file anymore.

References: civicrm/civicrm-core#13031
compucorp/civicrm-core#28
@davialexandre davialexandre force-pushed the PCHR-4346-civicrm-upgrade branch from d87a2af to 0232ce4 Compare November 6, 2018 17:29
@davialexandre davialexandre changed the title [WIP] PCHR-4346: CiviCRM Upgrade PCHR-4346: CiviCRM Upgrade Nov 7, 2018
@davialexandre davialexandre changed the base branch from master to PCHR-4321-php7-upgrade December 14, 2018 09:49
Now that the final version has been released, we don't
need to use the branch version anymore
@davialexandre davialexandre merged commit dea5146 into PCHR-4321-php7-upgrade Dec 14, 2018
@davialexandre davialexandre deleted the PCHR-4346-civicrm-upgrade branch December 14, 2018 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants