Skip to content

Commit

Permalink
Bugfix for Name-Shadowing Issues with the Schema Namespace (#608)
Browse files Browse the repository at this point in the history
* Added custom Account class (name shadowing), updated all references to 'Account' to instead use 'Schema.Account'

* Added custom AuthSession class (name shadowing), updated all references to 'AuthSession' to instead use 'Schema.AuthSession'

* Added custom LoginHistory class (name shadowing), updated all references to 'LoginHistory' to instead use 'Schema.LoginHistory'

* Added custom Organization class (name shadowing), updated all references to 'Organization' to instead use 'Schema.Organization'

* Added custom Profile class (name shadowing), updated all references to 'Profile' to instead use 'Schema.Profile'

* Added custom Topic and TopicAssignment classes (name shadowing), updated all references to 'Topic' and 'TopicAssignment' to instead use 'Schema.Topic' and 'Schema.TopicAssignment'

* Added custom User class (name shadowing), updated all references to 'User' to instead use 'Schema.User'

* Updated some inconsistent uses of 'Network' to instead use 'Schema.Network'

* Moved name shadowing classes to a dedicated name-shadowing subdirectory

* Regenerated ApexDocs so the fully qualified class names (e.g., Schema.Organization) are used in the docs
  • Loading branch information
jongpie authored Jan 21, 2024
1 parent 2735d4e commit 579286d
Show file tree
Hide file tree
Showing 120 changed files with 686 additions and 533 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

The most robust logger for Salesforce. Works with Apex, Lightning Components, Flow, Process Builder & Integrations. Designed for Salesforce admins, developers & architects.

## Unlocked Package - v4.12.4
## Unlocked Package - v4.12.5

[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001Mk5KQAS)
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001Mk5KQAS)
[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001Mk5PQAS)
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001Mk5PQAS)
[![View Documentation](./images/btn-view-documentation.png)](https://jongpie.github.io/NebulaLogger/)

`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y000001Mk5KQAS`
`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y000001Mk5PQAS`

`sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y000001Mk5KQAS`
`sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y000001Mk5PQAS`

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class MicrobatchSelfRegController {
String profileId = null; //to be filled by customer
String UUID;

User u = new User();
Schema.User u = new Schema.User();
u.Username = userName;
u.Email = email;
u.FirstName = firstName;
Expand All @@ -35,9 +35,9 @@ public class MicrobatchSelfRegController {
u.LanguageLocaleKey = 'en_US';
u.EmailEncodingKey = 'UTF-8';

Account acc = new Account();
Schema.Account acc = new Schema.Account();
acc.Name = 'Account for ' + lastName;
Contact c = new Contact();
Schema.Contact c = new Schema.Contact();
c.lastName = lastName;

try {
Expand Down
4 changes: 2 additions & 2 deletions config/experience-cloud/classes/MyProfilePageController.cls
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
Guest users are never able to access this page.
*/
public with sharing class MyProfilePageController {
private User user;
private Schema.User user;
private boolean isEdit = false;

public User getUser() {
public Schema.User getUser() {
return user;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ public with sharing class MyProfilePageControllerTest {
@IsTest(SeeAllData=true)
static void testSave() {
// Modify the test to query for a portal user that exists in your org
List<User> existingPortalUsers = [SELECT id, profileId, userRoleId FROM User WHERE UserRoleId != NULL AND UserType = 'CustomerSuccess'];
List<Schema.User> existingPortalUsers = [SELECT id, profileId, userRoleId FROM User WHERE UserRoleId != NULL AND UserType = 'CustomerSuccess'];

if (existingPortalUsers.isEmpty()) {
User currentUser = [
Schema.User currentUser = [
SELECT id, title, firstname, lastname, email, phone, mobilephone, fax, street, city, state, postalcode, country
FROM User
WHERE id = :System.UserInfo.getUserId()
Expand All @@ -33,7 +33,7 @@ public with sharing class MyProfilePageControllerTest {
currentUser = [SELECT id, fax FROM User WHERE id = :currentUser.Id];
// System.Assert.isTrue(currentUser.fax == randFax);
} else {
User existingPortalUser = existingPortalUsers[0];
Schema.User existingPortalUser = existingPortalUsers[0];
String randFax = Math.rint(Math.random() * 1000) + '5551234';

System.runAs(existingPortalUser) {
Expand Down
2 changes: 1 addition & 1 deletion config/experience-cloud/classes/SiteRegisterController.cls
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public with sharing class SiteRegisterController {
ApexPages.addMessage(msg);
return null;
}
User u = new User();
Schema.User u = new Schema.User();
u.Username = username;
u.Email = email;
u.CommunityNickname = communityNickname;
Expand Down
18 changes: 9 additions & 9 deletions docs/apex/Configuration/LoggerParameter.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,43 +52,43 @@ Controls if Nebula Logger queries `ApexClass` data. When set to `false`, any `Ap

#### `QUERY_AUTH_SESSION_DATA``Boolean`

Controls if Nebula Logger queries `AuthSession` data. When set to `false`, any `AuthSession` fields on `LogEntryEvent__e` and `Log__c` will not be populated Controlled by the custom metadata record `LoggerParameter.QueryAuthSessionData`, or `true` as the default
Controls if Nebula Logger queries `Schema.AuthSession` data. When set to `false`, any `Schema.AuthSession` fields on `LogEntryEvent__e` and `Log__c` will not be populated Controlled by the custom metadata record `LoggerParameter.QueryAuthSessionData`, or `true` as the default

#### `QUERY_AUTH_SESSION_DATA_SYNCHRONOUSLY``Boolean`

Controls if Nebula Logger queries `AuthSession` data synchronously &amp; populated on `LogEntryEvent__e` records. When set to `false`, any `AuthSession` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried asynchronously and populated on any resulting `Log__c` records. Controlled by the custom metadata record `LoggerParameter.QueryAuthSessionDataSynchronously`, or `true` as the default
Controls if Nebula Logger queries `Schema.AuthSession` data synchronously &amp; populated on `LogEntryEvent__e` records. When set to `false`, any `Schema.AuthSession` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried asynchronously and populated on any resulting `Log__c` records. Controlled by the custom metadata record `LoggerParameter.QueryAuthSessionDataSynchronously`, or `true` as the default

#### `QUERY_FLOW_DEFINITION_VIEW_DATA``Boolean`

Controls if Nebula Logger queries `FlowDefinitionView` data. When set to `false`, any `FlowDefinitionView` fields on `LogEntryEvent__e` and `Log__c` will not be populated Controlled by the custom metadata record `LoggerParameter.QueryFlowDefinitionViewData`, or `true` as the default

#### `QUERY_NETWORK_DATA``Boolean`

Controls if Nebula Logger queries `Network` data. When set to `false`, any `Network` fields on `LogEntryEvent__e` and `Log__c` will not be populated Controlled by the custom metadata record `LoggerParameter.QueryNetworkData`, or `true` as the default
Controls if Nebula Logger queries `Schema.Network` data. When set to `false`, any `Schema.Network` fields on `LogEntryEvent__e` and `Log__c` will not be populated Controlled by the custom metadata record `LoggerParameter.QueryNetworkData`, or `true` as the default

#### `QUERY_NETWORK_DATA_SYNCHRONOUSLY``Boolean`

Controls if Nebula Logger queries `Network` data is queried synchronously &amp; populated on `LogEntryEvent__e` records. When set to `false`, any `Network` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried asynchronously and populated on any resulting `Log__c` records. Controlled by the custom metadata record `LoggerParameter.QueryNetworkDataSynchronously`, or `true` as the default
Controls if Nebula Logger queries `Schema.Network` data is queried synchronously &amp; populated on `LogEntryEvent__e` records. When set to `false`, any `Schema.Network` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried asynchronously and populated on any resulting `Log__c` records. Controlled by the custom metadata record `LoggerParameter.QueryNetworkDataSynchronously`, or `true` as the default

#### `QUERY_ORGANIZATION_DATA``Boolean`

Controls if Nebula Logger queries `Organization` data. When set to `false`, any `Organization` fields on `LogEntryEvent__e` and `Log__c` will not be populated Controlled by the custom metadata record `LoggerParameter.QueryOrganizationData`, or `true` as the default
Controls if Nebula Logger queries `Schema.Organization` data. When set to `false`, any `Schema.Organization` fields on `LogEntryEvent__e` and `Log__c` will not be populated Controlled by the custom metadata record `LoggerParameter.QueryOrganizationData`, or `true` as the default

#### `QUERY_ORGANIZATION_DATA_SYNCHRONOUSLY``Boolean`

Indicates if Nebula Logger queries `Organization` data is queried synchronously &amp; populated on `LogEntryEvent__e` records. When set to `false`, any `Organization` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried asynchronously and populated on any resulting `Log__c` records. Controlled by the custom metadata record `LoggerParameter.QueryOrganizationDataSynchronously`, or `true` as the default
Indicates if Nebula Logger queries `Schema.Organization` data is queried synchronously &amp; populated on `LogEntryEvent__e` records. When set to `false`, any `Schema.Organization` fields on `LogEntryEvent__e` will not be populated - the data will instead be queried asynchronously and populated on any resulting `Log__c` records. Controlled by the custom metadata record `LoggerParameter.QueryOrganizationDataSynchronously`, or `true` as the default

#### `QUERY_RELATED_RECORD_DATA``Boolean`

Controls if Nebula Logger queries data for records synthetically related to a `LogEntry__c` via `LogEntry__c.RecordId__c`. When set to `false`, any fields on `LogEntry__c` related to `LogEntry__c.RecordId__c` not be populated Controlled by the custom metadata record `LoggerParameter.QueryRelatedRecordData`, or `true` as the default

#### `QUERY_USER_DATA``Boolean`

Controls if Nebula Logger queries `User` data. When set to `false`, any `User` fields on `LogEntryEvent__e` and `Log__c` will not be populated Controlled by the custom metadata record `LoggerParameter.QueryUserData`, or `true` as the default
Controls if Nebula Logger queries `Schema.User` data. When set to `false`, any `Schema.User` fields on `LogEntryEvent__e` and `Log__c` will not be populated Controlled by the custom metadata record `LoggerParameter.QueryUserData`, or `true` as the default

#### `QUERY_USER_DATA_SYNCHRONOUSLY``Boolean`

Indicates if Nebula Logger queries `User` data is queried synchronously &amp; populated on `LogEntryEvent__e` records. When set to `false`, any `User` fields on `LogEntryEvent__e` that rely on querying will not be populated - the data will instead be queried asynchronously and populated on any resulting `Log__c` records. Controlled by the custom metadata record `LoggerParameter.QueryUserDataSynchronously`, or `true` as the default
Indicates if Nebula Logger queries `Schema.User` data is queried synchronously &amp; populated on `LogEntryEvent__e` records. When set to `false`, any `Schema.User` fields on `LogEntryEvent__e` that rely on querying will not be populated - the data will instead be queried asynchronously and populated on any resulting `Log__c` records. Controlled by the custom metadata record `LoggerParameter.QueryUserDataSynchronously`, or `true` as the default

#### `SEND_ERROR_EMAIL_NOTIFICATIONS``Boolean`

Expand All @@ -112,7 +112,7 @@ Indicates if Platform Cache is used to cache organization &amp; session data in

#### `USE_TOPICS_FOR_TAGS``Boolean`

Indicates if Logger&apos;s tagging will use `Topic` and `TopicAssignment` for storing tags (when `true`), or uses Nebula Logger&apos;s custom objects `LoggerTag__c` and `LogEntryTag__c` (when `false`) Controlled by the custom metadata record `LoggerParameter.UseTopicsForTags`, or `false` as the default
Indicates if Logger&apos;s tagging will use `Schema.Topic` and `Schema.TopicAssignment` for storing tags (when `true`), or uses Nebula Logger&apos;s custom objects `LoggerTag__c` and `LogEntryTag__c` (when `false`) Controlled by the custom metadata record `LoggerParameter.UseTopicsForTags`, or `false` as the default

---

Expand Down
80 changes: 40 additions & 40 deletions docs/apex/Log-Management/LogManagementDataSelector.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,49 +337,49 @@ List&lt;Log\_\_c&gt;

The list of matching `Log__c` records

#### `getProfilesById(List<Id> profileIds)``List<Profile>`
#### `getProfilesById(List<Id> profileIds)``List<Schema.Profile>`

Returns a `List&lt;Profile&gt;` of records with the specified profile IDs
Returns a `List&lt;Schema.Profile&gt;` of records with the specified profile IDs

##### Parameters

| Param | Description |
| ------------ | -------------------------------------------------- |
| `profileIds` | The list of `ID` of the `Profile` records to query |
| Param | Description |
| ------------ | --------------------------------------------------------- |
| `profileIds` | The list of `ID` of the `Schema.Profile` records to query |

##### Return

**Type**

List&lt;Profile&gt;
List&lt;Schema.Profile&gt;

**Description**

The list of matching `Profile` records
The list of matching `Schema.Profile` records

#### `getProfilesByNameSearch(String searchTerm)``List<Profile>`
#### `getProfilesByNameSearch(String searchTerm)``List<Schema.Profile>`

Returns a `List&lt;Profile&gt;` of records where the profile&apos;s names partially matches the specified search term
Returns a `List&lt;Schema.Profile&gt;` of records where the profile&apos;s names partially matches the specified search term

##### Parameters

| Param | Description |
| ------------ | --------------------------------------------------------------- |
| `searchTerm` | The `String` search term to use for searching `Profile` records |
| Param | Description |
| ------------ | ---------------------------------------------------------------------- |
| `searchTerm` | The `String` search term to use for searching `Schema.Profile` records |

##### Return

**Type**

List&lt;Profile&gt;
List&lt;Schema.Profile&gt;

**Description**

The list of matching `Profile` records
The list of matching `Schema.Profile` records

#### `getQueuesByDeveloperName(List<String> queueDeveloperNames)``List<Group>`
#### `getQueuesByDeveloperName(List<String> queueDeveloperNames)``List<Schema.Group>`

Returns a `List&lt;Group&gt;` of records with the specified developer names and type == &apos;Queue&apos;
Returns a `List&lt;Schema.Group&gt;` of records with the specified developer names and type == &apos;Queue&apos;

##### Parameters

Expand All @@ -391,11 +391,11 @@ Returns a `List&lt;Group&gt;` of records with the specified developer names and

**Type**

List&lt;Group&gt;
List&lt;Schema.Group&gt;

**Description**

The list of matching `Group` records
The list of matching `Schema.Group` records

#### `getRecordLogEntries(Id recordId, String fieldsClause, String orderByClause, Integer rowLimit)``List<LogEntry__c>`

Expand Down Expand Up @@ -440,9 +440,9 @@ List&lt;LoggerTag\_\_c&gt;

The list of matching `LoggerTag__c` records

#### `getTopicsByName(Set<String> topicNames)``List<Topic>`
#### `getTopicsByName(Set<String> topicNames)``List<Schema.Topic>`

Returns a list of `Topic` records with one of the specified topic names
Returns a list of `Schema.Topic` records with one of the specified topic names

##### Parameters

Expand All @@ -454,55 +454,55 @@ Returns a list of `Topic` records with one of the specified topic names

**Type**

List&lt;Topic&gt;
List&lt;Schema.Topic&gt;

**Description**

The list of matching `Topic` records
The list of matching `Schema.Topic` records

#### `getUsersById(List<Id> userIds)``List<User>`
#### `getUsersById(List<Id> userIds)``List<Schema.User>`

Returns a `List&lt;User&gt;` of records with the specified user IDs
Returns a `List&lt;Schema.User&gt;` of records with the specified user IDs

##### Parameters

| Param | Description |
| --------- | ----------------------------------------------- |
| `userIds` | The list of `ID` of the `User` records to query |
| Param | Description |
| --------- | ------------------------------------------------------ |
| `userIds` | The list of `ID` of the `Schema.User` records to query |

##### Return

**Type**

List&lt;User&gt;
List&lt;Schema.User&gt;

**Description**

The list of matching `User` records
The list of matching `Schema.User` records

#### `getUsersByNameSearch(String searchTerm)``List<User>`
#### `getUsersByNameSearch(String searchTerm)``List<Schema.User>`

Returns a `List&lt;User&gt;` of records where the User&apos;s names or username partially matches the specified search term
Returns a `List&lt;Schema.User&gt;` of records where the User&apos;s names or username partially matches the specified search term

##### Parameters

| Param | Description |
| ------------ | ------------------------------------------------------------ |
| `searchTerm` | The `String` search term to use for searching `User` records |
| Param | Description |
| ------------ | ------------------------------------------------------------------- |
| `searchTerm` | The `String` search term to use for searching `Schema.User` records |

##### Return

**Type**

List&lt;User&gt;
List&lt;Schema.User&gt;

**Description**

The list of matching `User` records
The list of matching `Schema.User` records

#### `getUsersByUsername(List<String> usernames)``List<User>`
#### `getUsersByUsername(List<String> usernames)``List<Schema.User>`

Returns a `List&lt;User&gt;` of records with the specified usernames (`Schema.User.Username`)
Returns a `List&lt;Schema.User&gt;` of records with the specified usernames (`Schema.User.Username`)

##### Parameters

Expand All @@ -514,10 +514,10 @@ Returns a `List&lt;User&gt;` of records with the specified usernames (`Schema.Us

**Type**

List&lt;User&gt;
List&lt;Schema.User&gt;

**Description**

Tje list of matching `User` records
Tje list of matching `Schema.User` records

---
18 changes: 9 additions & 9 deletions docs/apex/Log-Management/LoggerSettingsController.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ Deletes the specified `LoggerSettings__c` record
| ---------------- | -------------------- |
| `settingsRecord` | The record to delete |

#### `getOrganization()``Organization`
#### `getOrganization()``Schema.Organization`

Returns the `Organization` record for the current environment
Returns the `Schema.Organization` record for the current environment

##### Return

**Type**

Organization
Schema.Organization

**Description**

The current environment&apos;s `Organization` record
The current environment&apos;s `Schema.Organization` record

#### `getPicklistOptions()``LoggerSettingsPicklistOptions`

Expand Down Expand Up @@ -106,10 +106,10 @@ searchForSetupOwner description

##### Parameters

| Param | Description |
| ---------------- | --------------------------------------------- |
| `setupOwnerType` | The object to search (`Profile` or `User`) |
| `searchTerm` | The search term to use when searching records |
| Param | Description |
| ---------------- | -------------------------------------------------------- |
| `setupOwnerType` | The object to search (`Schema.Profile` or `Schema.User`) |
| `searchTerm` | The search term to use when searching records |

##### Return

Expand Down Expand Up @@ -207,7 +207,7 @@ The sorting result

#### LoggerSettingsController.SetupOwnerSearchResult class

Inner class used for returning search results for `Profile` and `User` records
Inner class used for returning search results for `Schema.Profile` and `Schema.User` records

---

Expand Down
2 changes: 1 addition & 1 deletion docs/apex/Logger-Engine/Logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -3634,7 +3634,7 @@ LoggerSettings\_\_c

LoggerSettings\_\_c - The current user&apos;s instance of the custom settings

#### `getUserSettings(User loggingUser)``LoggerSettings__c`
#### `getUserSettings(Schema.User loggingUser)``LoggerSettings__c`

**This is only intended to be used internally by Nebula Logger, and is subject to change.** Returns the specified user&apos;s instance of `LoggerSettings__c`

Expand Down
Loading

0 comments on commit 579286d

Please sign in to comment.