fix(email-log): correct default values for get_all_logs and save methods - #145
Open
faisalahammad wants to merge 1 commit into
Open
fix(email-log): correct default values for get_all_logs and save methods#145faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
- PostmanEmailQueryLog::get_all_logs: default $ids as array(-1) instead of empty array. Empty array collapsed to '' after implode, so the == -1'' guard never matched and the query produced invalid WHERE id IN ()''. - PostmanEmailLogs::save: default $id as 0 instead of '' so the parameter type matches update(), which expects an int. Fixes wpexpertsio#102
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
Fixed two incorrect default parameter values caught by PHPStan. Both are small type-safe adjustments that prevent potential SQL issues and type mismatches.
Fixes #102
Changes
PostmanEmailQueryLog::get_all_logs()
Before:
After:
Why: Empty array default produced `` after implode, so the
$ids == -1guard never matched. SQL query would generate invalid `WHERE id IN ()` when no logs selected for export.PostmanEmailLogs::save()
Before:
After:
Why:
$iddefault was a string butupdate()expects an integer. The!empty()check works with both, but the type should match.Testing
Test 1: Export CSV with no log items selected
Test 2: Save log entry (new)
Test 3: Save log entry (update)