ZAK-266 Fix - Normalize paths before comparison to avoid invalid survey asset URL - #1
Open
iamprazol wants to merge 1 commit into
Open
ZAK-266 Fix - Normalize paths before comparison to avoid invalid survey asset URL#1iamprazol wants to merge 1 commit into
iamprazol wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
On Windows, AbstractModule::get_sdk_uri() generates an invalid URL for the survey dependency script (and potentially other assets resolved through this method), producing a 500 error on every load of the Zakra Dashboard:

Fix
Normalize both sides with wp_normalize_path() before the strpos() comparison, so the check is reliable regardless of platform-specific path-separator quirks. Also swapped the . '/themegrill-sdk/' suffix trick for . '/load.php' — same effect (both rely on plugins_url()'s internal dirname() dropping the trailing segment to land back at the SDK's own directory), but anchored to a real, known file instead of a string that only worked by coincidence.
Testing
Verified with a standalone script simulating the exact scenario from the bug report (the theme's own SDK copy winning the "max version" race):
Before: strpos() on the raw paths → false → wrongly takes the plugins_url() branch.
After: strpos() on the normalized paths → 0 → correctly takes the get_template_directory_uri() branch.
No effect on non-Windows environments, where paths are already forward-slash-only (normalization is a no-op there).
Fixes ZAK-266.