Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions projects/plugins/crm/changelog/fix-crm-error-in-local-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Fixed issue with list rendering in local dev.
42 changes: 18 additions & 24 deletions projects/plugins/crm/includes/ZeroBSCRM.List.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
$sort = sanitize_text_field( $_GET['sort'] );
}
$sortOrder = false;
if ( isset( $_GET['sortdirection'] ) && ( $_GET['sortdirection'] == 'asc' || $_GET['sortdirection'] == 'desc' ) ) {
if ( isset( $_GET['sortdirection'] ) && ( $_GET['sortdirection'] === 'asc' || $_GET['sortdirection'] === 'desc' ) ) {

Check warning on line 169 in projects/plugins/crm/includes/ZeroBSCRM.List.php

View workflow job for this annotation

GitHub Actions / PHP Code Sniffer (changes to excluded files only)

Processing form data without nonce verification. (WordPress.Security.NonceVerification.Recommended)

Check warning on line 169 in projects/plugins/crm/includes/ZeroBSCRM.List.php

View workflow job for this annotation

GitHub Actions / PHP Code Sniffer (changes to excluded files only)

Processing form data without nonce verification. (WordPress.Security.NonceVerification.Recommended)

Check warning on line 169 in projects/plugins/crm/includes/ZeroBSCRM.List.php

View workflow job for this annotation

GitHub Actions / PHP Code Sniffer (changes to excluded files only)

Processing form data without nonce verification. (WordPress.Security.NonceVerification.Recommended)
$sortOrder = sanitize_text_field( $_GET['sortdirection'] );
}

Expand All @@ -188,7 +188,7 @@
if ( isset( $customViews ) && isset( $customViews[ $this->objType ] ) ) {
$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.
$currentColumns = $defaultColumns;
}

Expand Down Expand Up @@ -270,7 +270,7 @@
if ( ! array_key_exists( $colKey, $currentColumns ) ) {

// split em up
if ( isset( $col[2] ) && $col[2] == 'basefield' ) {
if ( isset( $col[2] ) && $col[2] === 'basefield' ) {
$allColumnsSorted['basefields'][ $colKey ] = $col;
$hasMultiColumnGroups = true;
} else {
Expand Down Expand Up @@ -334,7 +334,7 @@
}

// if NONE output, we need to always have smt to drop to, so put empty:
if ( $colGroupCount == 0 ) {
if ( $colGroupCount === 0 ) {
echo '<div class="zbs-column-manager-connected">';
echo '</div>';
}
Expand Down Expand Up @@ -426,7 +426,7 @@

<?php

$allowinlineedits = ( zeroBSCRM_getSetting( 'allowinlineedits' ) == '1' );
$allowinlineedits = ( zeroBSCRM_getSetting( 'allowinlineedits' ) === '1' );
$inlineEditStr = array();
$columns = array();

Expand All @@ -440,7 +440,7 @@
// overrides

// Invoicing: Ref
if ( $this->objType == 'invoice' && $colKey == 'ref' ) {
if ( $this->objType === 'invoice' && $colKey === 'ref' ) {
$column_title = $zbs->settings->get( 'reflabel' );
}

Expand Down Expand Up @@ -542,14 +542,8 @@
var zbsDrawListViewColUpdateBlocker = false;
var zbsDrawListViewColUpdateAJAXBlocker = false;

var zbsObjectEmailLinkPrefix = '
<?php

// this assumes is contact for now, just sends to prefill - perhaps later add mailto: optional (wh wants lol)
echo jpcrm_esc_link( 'email', -1, 'zerobs_customer', true );

?>
';
// 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 ); ?>';
Comment on lines +545 to +546
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.

var zbsObjectViewLinkPrefixCustomer = '<?php echo jpcrm_esc_link( 'view', -1, 'zerobs_customer', true ); ?>';
var zbsObjectViewLinkPrefixCompany = '<?php echo jpcrm_esc_link( 'view', -1, 'zerobs_company', true ); ?>';
var zbsObjectViewLinkPrefixQuote = '<?php echo jpcrm_esc_link( 'edit', -1, 'zerobs_quote', true ); ?>';
Expand Down Expand Up @@ -639,12 +633,12 @@
// make simplified
$simple_tags = array();
if ( is_array( $tags ) && count( $tags ) > 0 ) {
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'],
);
Comment on lines +636 to +641
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.
}
}

Expand All @@ -664,9 +658,9 @@
// phpcs:disable WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
global $zbsCustomerFields;
if ( is_array( $zbsCustomerFields['status'][3] ) ) {
echo wp_json_encode( $zbsCustomerFields['status'][3] );
echo wp_json_encode( $zbsCustomerFields['status'][3] );
} else {
echo '[]';
echo '[]';
}
Comment on lines 660 to 664
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.
// phpcs:enable WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
?>
Expand All @@ -678,9 +672,9 @@
// hardcoded customer perms atm
$possible_owners = zeroBS_getPossibleOwners( array( 'zerobs_admin', 'zerobs_customermgr' ), true );
if ( ! is_array( $possible_owners ) ) {
echo wp_json_encode( array() );
echo wp_json_encode( array() );
} else {
echo wp_json_encode( $possible_owners );
echo wp_json_encode( $possible_owners );
}

?>
Expand Down
Loading