Skip to content

CRM: CSV import path separator#46684

Merged
haqadn merged 2 commits intotrunkfrom
cursor/JETCRM-64-csv-import-path-separator-c311
Jan 26, 2026
Merged

CRM: CSV import path separator#46684
haqadn merged 2 commits intotrunkfrom
cursor/JETCRM-64-csv-import-path-separator-c311

Conversation

@haqadn
Copy link
Copy Markdown
Contributor

@haqadn haqadn commented Jan 20, 2026

CSV Importer: Fix path separator issue causing import failures on Windows servers

Fixes JETCRM-64

Proposed changes:

  • Replaced a hardcoded forward slash (/) with DIRECTORY_SEPARATOR when constructing the temporary directory path in ZeroBSCRM.CSVImporter.php. This resolves an issue where realpath() on Windows returns backslashes, causing a path mismatch and failure in a security check (str_starts_with()).

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

None

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

No

Testing instructions:

  • Set up a WordPress environment on a Windows server.
  • Install and activate Jetpack CRM.
  • Go to Jetpack CRM → Contacts -> Import.
  • Upload a valid CSV file.
  • Attempt to import the CSV using either Importer Pro or the core importer.
  • Expected Result: The import process should start, and the dashboard should load the import progress.
  • Actual Result (before fix): The import fails immediately with the message: “There was an error processing your CSV file. Please try again.”

Replace hardcoded forward slash '/' with DIRECTORY_SEPARATOR constant on line 155.

On Windows, realpath() returns paths with backslashes (e.g., C:\Windows\Temp),
but the hardcoded '/' created a mixed path (C:\Windows\Temp/). This caused
str_starts_with() check on line 247 to fail, preventing CSV imports.

Co-authored-by: adnan007.id <adnan007.id@gmail.com>
@cursor
Copy link
Copy Markdown

cursor Bot commented Jan 20, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@github-actions github-actions Bot added [Plugin] CRM Issues about the Jetpack CRM plugin [Status] In Progress labels Jan 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 20, 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 Jan 20, 2026
@haqadn haqadn added Bug When a feature is broken and / or not performing as intended [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jan 20, 2026
@haqadn haqadn requested review from a team and mikestottuk January 20, 2026 16:52
@haqadn haqadn marked this pull request as ready for review January 20, 2026 16:53
Copilot AI review requested due to automatic review settings January 20, 2026 16:53
@haqadn haqadn self-assigned this Jan 20, 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

This PR fixes a critical bug in the CSV importer that prevented imports from working on Windows servers. The issue occurred because a hardcoded forward slash (/) was used in path construction, while Windows realpath() returns backslashes, causing a security check to fail.

Changes:

  • Updated path separator in CSV importer to use DIRECTORY_SEPARATOR instead of hardcoded / for cross-platform compatibility
  • Added changelog entry documenting the fix

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
projects/plugins/crm/includes/ZeroBSCRM.CSVImporter.php Replaced hardcoded forward slash with DIRECTORY_SEPARATOR when constructing temp directory path to fix Windows compatibility
projects/plugins/crm/changelog/fix-csv-import-path-separator-windows Added changelog entry for the path separator fix

Significance: patch
Type: fixed

CSV Importer: fix path separator issue causing import failures on Windows servers.
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The changelog entry should start with a capital letter. Change "fix" to "Fix" to follow the project's changelog guidelines.

Copilot generated this review using guidance from repository custom instructions.
Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 20, 2026

@haqadn I've opened a new pull request, #46685, to work on those changes. Once the pull request is ready, I'll request review from you.

@jp-launch-control
Copy link
Copy Markdown

jp-launch-control Bot commented Jan 20, 2026

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report

Copilot AI review requested due to automatic review settings January 20, 2026 16:57
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.

@haqadn haqadn changed the title CSV import path separator CRM: CSV import path separator Jan 20, 2026
Copy link
Copy Markdown
Contributor

@grzegorz-cp grzegorz-cp left a comment

Choose a reason for hiding this comment

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

Good replacement.

@grzegorz-cp
Copy link
Copy Markdown
Contributor

I'm not sure how to test this on a Windows server but the code makes sense and it's a small change so I approved it.

@haqadn haqadn merged commit 332d546 into trunk Jan 26, 2026
74 checks passed
@haqadn haqadn deleted the cursor/JETCRM-64-csv-import-path-separator-c311 branch January 26, 2026 12:35
@github-actions github-actions Bot removed [Status] In Progress [Status] Needs Review This PR is ready for review. labels Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug When a feature is broken and / or not performing as intended [Plugin] CRM Issues about the Jetpack CRM plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants