fix(controller): remove unreachable || true / && false guards - #148
Open
faisalahammad wants to merge 1 commit into
Open
fix(controller): remove unreachable || true / && false guards#148faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
Two debug-disable hacks in PostmanAdminPointer made the constructor and the pointer registration block unreachable: - constructor's WP < 3.3 guard used '|| true' to force an early return regardless of WP version - wptuts_register_pointer_testing() admin guard used '&& false' to skip the pointer array build Dropped both hacks and replaced the lexicographic string version compare with version_compare() so the guard stays correct on future WP releases (e.g. '10.x' < '3.3' would silently flip the earlier check). The class is still loaded but not instantiated elsewhere, so runtime behaviour is unchanged. Fixes wpexpertsio#111
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.
Summary
Two debug-disable hacks in
Postman/Postman-Controller/PostmanAdminPointer.phpmade the constructor's hook registrations and the pointer array build unreachable. Both are now removed. The WP version compare is also upgraded from a lexicographic string<toversion_compare()so the guard stays correct on future WP releases.Behaviour is unchanged at runtime because the class is loaded but never instantiated elsewhere.
Fixes #111
Changes
Postman/Postman-Controller/PostmanAdminPointer.phpConstructor guard — Before:
Constructor guard — After:
Why:
|| trueforced an early return regardless of WP version, making theadd_actionandadd_filtercalls immediately below it unreachable. The lexicographic string compare was also broken: with'10.x'the expression'10.0' < '3.3'becomes true and the guard would fire on newer WP.version_compare()fixes both.Pointer registration guard — Before:
Pointer registration guard — After:
Why:
&& falseshort-circuited the role check and skipped the pointer registration.PostmanUtils::isAdmin()is the actual intent.Testing
Test 1: Syntax lint
php -l Postman/Postman-Controller/PostmanAdminPointer.phpNo syntax errors detected. Confirmed in the fix branch.Test 2: Runtime smoke on a WP 5.6+ site
old/devbecause the class is still loaded but not instantiated.Test 3: Inline diff review
Postman/Postman-Controller/PostmanAdminPointer.php.Notes
Two adjacent issues were observed during investigation and are intentionally not addressed in this PR so the diff stays surgical:
Postman/Postman-Email-Log/PostmanEmailLogService.php:285has the same|| truedebug-disable flavor. Worth a separate cleanup.script/postman-admin-pointer.jsreferenced atPostmanAdminPointer.php:89does not exist in the repo and the matchingwp_enqueue_scriptblock is commented out. So even if the class is later instantiated, the pointer will not render until the JS is added.Happy to follow up on either in a separate issue if useful.