Skip to content

CRM: Fix Contact List Rendering in Local Dev Environment#47437

Closed
bobmatyas wants to merge 2 commits intotrunkfrom
fix/crm-errors-in-studio
Closed

CRM: Fix Contact List Rendering in Local Dev Environment#47437
bobmatyas wants to merge 2 commits intotrunkfrom
fix/crm-errors-in-studio

Conversation

@bobmatyas
Copy link
Copy Markdown
Contributor

Fixes JETCRM-1405 on Linear

Proposed changes:

It fixes a broken string by consolidating it into a single line to prevent JS errors that prevent Contacts, Transactions, and Invoices from being properly listed.

The linter also changed some stuff with the formatting in the file.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

To test, build CRM and run locally from Studio by symlinking, i.e.:

ln -s /jetpack/projects/plugins/crm zero-bs-crm

Activate Jetpack CRM and go to the contact list. Observe that it doesn't render properly:

image

Apply the PR and see that the list renders properly:

image
  • Go to '..'

Changelog

  • Generate changelog entries for this PR (using AI).

Copilot AI review requested due to automatic review settings March 3, 2026 21:40
@github-actions github-actions Bot added the [Plugin] CRM Issues about the Jetpack CRM plugin label Mar 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 3, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • 🔴 Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Mar 3, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a JavaScript syntax error in Jetpack CRM list view output that breaks rendering in local dev (Studio/symlinked setups), ensuring Contacts/Transactions/Invoices lists can load correctly.

Changes:

  • Consolidates a PHP-generated JS string (zbsObjectEmailLinkPrefix) into a single-line assignment to avoid invalid JS.
  • Applies stricter comparisons (===) in several conditionals (mostly formatting/lint-driven).
  • Adds a CRM changelog entry for the patch fix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
projects/plugins/crm/includes/ZeroBSCRM.List.php Fixes the broken JS string output and includes several lint/formatting updates in list view rendering logic.
projects/plugins/crm/changelog/fix-crm-error-in-local-dev Adds a patch-level changelog note describing the list rendering fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

$currentColumns = $customViews[ $this->objType ];
}
if ( $currentColumns == false ) {
if ( $currentColumns === false ) {
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

Switching this fallback check to a strict === false changes behavior when $customViews[$this->objType] is an empty array. The AJAX column-save paths can persist an empty array when the user saves with no columns selected, and with this change the list view would keep [] instead of falling back to $defaultColumns, potentially rendering an empty/broken table. Consider treating an empty array the same as false here (e.g., fall back when empty($currentColumns) or when it’s not a non-empty array).

Suggested change
if ( $currentColumns === false ) {
// Fall back to default columns when no valid, non-empty column configuration is available.
if ( ! is_array( $currentColumns ) || empty( $currentColumns ) ) {

Copilot uses AI. Check for mistakes.
Comment on lines +637 to +642
foreach ( $tags as $t ) {
$simple_tags[] = array(
'id' => $t['id'],
'name' => $t['name'],
'slug' => $t['slug'],
);
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

The indentation in this if ( is_array( $tags ) ... ) block looks off (the foreach and its body aren’t indented under the if). Even though it still parses, it makes the PHP/JS mixed block harder to read and increases the risk of misreading brace scope during future edits. Please re-indent this block to reflect the actual nesting.

Suggested change
foreach ( $tags as $t ) {
$simple_tags[] = array(
'id' => $t['id'],
'name' => $t['name'],
'slug' => $t['slug'],
);
foreach ( $tags as $t ) {
$simple_tags[] = array(
'id' => $t['id'],
'name' => $t['name'],
'slug' => $t['slug'],
);

Copilot uses AI. Check for mistakes.
Comment on lines 661 to 665
if ( is_array( $zbsCustomerFields['status'][3] ) ) {
echo wp_json_encode( $zbsCustomerFields['status'][3] );
echo wp_json_encode( $zbsCustomerFields['status'][3] );
} else {
echo '[]';
echo '[]';
}
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

These echo statements inside the if/else are no longer indented under their control flow, which makes it easy to miss which branch they belong to in this mixed PHP/JS section. Please re-indent the echo wp_json_encode(...) / echo '[]' lines to match the surrounding block structure.

Copilot uses AI. Check for mistakes.
Comment thread projects/plugins/crm/includes/ZeroBSCRM.List.php Outdated
@jp-launch-control
Copy link
Copy Markdown

jp-launch-control Bot commented Mar 3, 2026

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/plugins/crm/includes/ZeroBSCRM.List.php 0/444 (0.00%) 0.00% -2 💚

Full summary · PHP report

@bobmatyas bobmatyas self-assigned this Mar 3, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 3, 2026 21:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tbradsha
Copy link
Copy Markdown
Contributor

Thanks! I ran into this as well and it looks like it was caused by #46809.

@tbradsha tbradsha self-requested a review March 10, 2026 07:21
Copy link
Copy Markdown
Contributor

@tbradsha tbradsha left a comment

Choose a reason for hiding this comment

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

Looks like the LLM went haywire; I'd recommend removing all edits but the actual fix (highlighted inline).

Comment on lines +545 to +546
// this assumes is contact for now, just sends to prefill - perhaps later add mailto: optional (wh wants lol)
var zbsObjectEmailLinkPrefix = '<?php echo jpcrm_esc_link( 'email', -1, 'zerobs_customer', true ); ?>';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is the actual fix.

@tbradsha
Copy link
Copy Markdown
Contributor

It seems @haqadn already fixed this in #47519.

@tbradsha tbradsha closed this Mar 13, 2026
@github-actions github-actions Bot removed the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Plugin] CRM Issues about the Jetpack CRM plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants