Skip to content

Commit

Permalink
v1.5.67 - RollupRelationshipFieldFinder bugfix (#446)
Browse files Browse the repository at this point in the history
* Fixes #445 by properly protecting against improper field access in RollupRelationshipFieldFinder

* Bumping package version from Github Action

---------

Co-authored-by: GitHub Action Bot <action@github.com>
  • Loading branch information
jamessimone and actions-user authored May 19, 2023
1 parent b0ca121 commit dac8467
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 28 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ As well, don't miss [the Wiki](../../wiki), which includes even more info for co

## Deployment & Setup

<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008SneHAAS">
<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008SneWAAS">
<img alt="Deploy to Salesforce"
src="./media/deploy-package-to-prod.png">
</a>

<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008SneHAAS">
<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008SneWAAS">
<img alt="Deploy to Salesforce Sandbox"
src="./media/deploy-package-to-sandbox.png">
</a>
Expand Down
24 changes: 24 additions & 0 deletions extra-tests/classes/RollupRelationshipFieldFinderTests.cls
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,30 @@ private class RollupRelationshipFieldFinderTests {
System.assertEquals(true, traversal.getIsFinished());
}

@IsTest
static void fullRecalcDoesNotBlowUpOnParentFields() {
Account acc = [SELECT Id, OwnerId, Owner.Name FROM Account];

Contact con = new Contact(AccountId = acc.Id, LastName = 'Child con');
insert con;
con = [SELECT Id FROM Contact WHERE Id = :con.Id];

RollupRelationshipFieldFinder finder = new RollupRelationshipFieldFinder(
control,
new Rollup__mdt(GrandparentRelationshipFieldPath__c = 'Account.Owner.Name'),
uniqueFieldNames,
uniqueFieldNames,
User.SObjectType,
new Map<Id, SObject>()
);
finder.setIsFullRecalc(true);
RollupRelationshipFieldFinder.Traversal traversal = finder.getParents(new List<Contact>{ con });

System.assertEquals(true, traversal.getParentLookupToRecords().containsKey(acc.OwnerId));
System.assertEquals(acc.Owner.Name, traversal.retrieveParents(con.Id)[0].get('Name'));
System.assertEquals(true, traversal.getIsFinished());
}

@IsTest
static void shouldNotReportFalsePositiveIfUltimateParentStaysTheSame() {
Account intermediateOne = new Account(Name = 'Intermediate 1');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apex-rollup",
"version": "1.5.66",
"version": "1.5.67",
"description": "Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions rollup-namespaced/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ For more info, see the base `README`.

## Deployment & Setup

<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008SneMAAS">
<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008SnebAAC">
<img alt="Deploy to Salesforce"
src="./media/deploy-package-to-prod.png">
</a>

<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008SneMAAS">
<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008SnebAAC">
<img alt="Deploy to Salesforce Sandbox"
src="./media/deploy-package-to-sandbox.png">
</a>
5 changes: 3 additions & 2 deletions rollup-namespaced/sfdx-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"package": "apex-rollup-namespaced",
"path": "rollup-namespaced/source/rollup",
"versionName": "Slight cleanup on RollupOrderBy__mdt transformations",
"versionNumber": "1.0.39.0",
"versionNumber": "1.0.40.0",
"versionDescription": "Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.",
"releaseNotesUrl": "https://github.com/jamessimone/apex-rollup/releases/latest",
"unpackagedMetadata": {
Expand Down Expand Up @@ -33,6 +33,7 @@
"apex-rollup-namespaced@1.0.36-0": "04t6g000008o0DfAAI",
"apex-rollup-namespaced@1.0.37-0": "04t6g000008SnX5AAK",
"apex-rollup-namespaced@1.0.38-0": "04t6g000008SnXtAAK",
"apex-rollup-namespaced@1.0.39-0": "04t6g000008SneMAAS"
"apex-rollup-namespaced@1.0.39-0": "04t6g000008SneMAAS",
"apex-rollup-namespaced@1.0.40-0": "04t6g000008SnebAAC"
}
}
2 changes: 1 addition & 1 deletion rollup/core/classes/RollupLogger.cls
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
global without sharing virtual class RollupLogger implements ILogger {
@TestVisible
// this gets updated via the pipeline as the version number gets incremented
private static final String CURRENT_VERSION_NUMBER = 'v1.5.66';
private static final String CURRENT_VERSION_NUMBER = 'v1.5.67';
private static final LoggingLevel FALLBACK_LOGGING_LEVEL = LoggingLevel.DEBUG;
private static final RollupPlugin PLUGIN = new RollupPlugin();

Expand Down
20 changes: 10 additions & 10 deletions rollup/core/classes/RollupRelationshipFieldFinder.cls
Original file line number Diff line number Diff line change
Expand Up @@ -748,20 +748,20 @@ public without sharing class RollupRelationshipFieldFinder {
Boolean isAlreadySet = false;
List<String> copiedRelationshipNames = new List<String>(splitRelationshipNames);
SObject ref = firstChild;
while (copiedRelationshipNames.isEmpty() == false) {
ref = ref.getSObject(copiedRelationshipNames.remove(0));
isAlreadySet = ref != null;
if (isAlreadySet == false) {
break;
try {
while (copiedRelationshipNames.isEmpty() == false) {
ref = ref.getSObject(copiedRelationshipNames.remove(0));
isAlreadySet = ref != null;
if (isAlreadySet == false) {
break;
}
}
}
if (ref?.getSObjectType() == this.ultimateParent) {
try {
if (ref?.getSObjectType() == this.ultimateParent) {
ref?.get(this.metadata.GrandparentRelationshipFieldPath__c.substringAfterLast('.'));
isAlreadySet = true;
} catch (Exception ex) {
isAlreadySet = false;
}
} catch (Exception ex) {
isAlreadySet = false;
}
return isAlreadySet;
}
Expand Down
13 changes: 3 additions & 10 deletions sfdx-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"package": "apex-rollup",
"path": "rollup",
"versionName": "Slight cleanup on RollupOrderBy__mdt transformations",
"versionNumber": "1.5.66.0",
"versionNumber": "1.5.67.0",
"versionDescription": "Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.",
"releaseNotesUrl": "https://github.com/jamessimone/apex-rollup/releases/latest",
"unpackagedMetadata": {
Expand Down Expand Up @@ -100,17 +100,10 @@
"Apex Rollup - Rollup Callback@0.0.3-0": "04t6g000008Sis0AAC",
"Nebula Logger - Core@4.8.0-NEXT-ignore-origin-method": "04t5Y0000015lslQAA",
"apex-rollup": "0Ho6g000000TNcOCAW",
"apex-rollup@1.5.55-0": "04t6g000008fjiwAAA",
"apex-rollup@1.5.56-0": "04t6g000008fjnnAAA",
"apex-rollup@1.5.57-0": "04t6g000008fjoMAAQ",
"apex-rollup@1.5.58-0": "04t6g000008nzupAAA",
"apex-rollup@1.5.59-0": "04t6g000008nzwCAAQ",
"apex-rollup@1.5.60-0": "04t6g000008o01XAAQ",
"apex-rollup@1.5.61-0": "04t6g000008o01wAAA",
"apex-rollup@1.5.62-0": "04t6g000008o0DQAAY",
"apex-rollup@1.5.63-0": "04t6g000008o0DaAAI",
"apex-rollup@1.5.64-0": "04t6g000008SnX0AAK",
"apex-rollup@1.5.65-0": "04t6g000008SnXoAAK",
"apex-rollup@1.5.66-0": "04t6g000008SneHAAS"
"apex-rollup@1.5.66-0": "04t6g000008SneHAAS",
"apex-rollup@1.5.67-0": "04t6g000008SneWAAS"
}
}

0 comments on commit dac8467

Please sign in to comment.