Fix residual bug#503
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to fix a residual bug in the submit/edit listing flow by normalizing how listing_id is read from the request and by adding an early authorization/validity check before processing the submit form.
Changes:
- Reads
listing_idviawpbdp_get_var()withabsintsanitization instead of directly using$_REQUEST. - Adds early returns for missing
listing_idin edit mode and for disallowed listing loads. - Introduces a
can_load_existing_listing()helper to centralize pre-validation logic.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@includes/controllers/pages/class-submit-listing.php`:
- Around line 536-557: The PHPDoc for the private method
can_load_existing_listing in class-submit-listing.php still has the placeholder
"@since x.x"; replace that placeholder with the actual release version used by
the project (e.g., "@since 1.6.0" or whatever the current plugin release/version
is) so generated docs are accurate—update the `@since` tag in the docblock
immediately above the can_load_existing_listing method.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 29ad545d-0a3e-4ced-860a-3f9af18029ae
📒 Files selected for processing (1)
includes/controllers/pages/class-submit-listing.php
can_load_existing_listing() returned true for non-WPBDP_POST_TYPE posts, allowing them past the security gate. This could cause a fatal error when find_or_create_listing() loads a non-listing post via wpbdp_get_listing() and later code calls methods on the null result. Split the null/wrong-type check: non-existent IDs still pass through (form creates a new listing), but existing posts of the wrong type are now rejected. Made-with: Cursor
When editing, a listing_id pointing to a deleted or nonexistent post passed can_load_existing_listing() (returns true for null posts) and reached find_or_create_listing() which silently created a new auto-draft instead of showing an error. Add explicit existence check before the ownership gate so edit mode returns a clear error for invalid listing IDs. Made-with: Cursor
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.
Fixes residual bug related to https://github.com/Strategy11/business-directory-premium/issues/353