Skip to content

Fix residual bug#503

Merged
sorinmarta merged 3 commits into
masterfrom
fix-residual-bug
May 5, 2026
Merged

Fix residual bug#503
sorinmarta merged 3 commits into
masterfrom
fix-residual-bug

Conversation

@sorinmarta
Copy link
Copy Markdown
Contributor

@sorinmarta sorinmarta requested a review from Copilot April 30, 2026 11:53
@sorinmarta sorinmarta added the run analysis Runs phpcs and phpunit label Apr 30, 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 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_id via wpbdp_get_var() with absint sanitization instead of directly using $_REQUEST.
  • Adds early returns for missing listing_id in 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.

Comment thread includes/controllers/pages/class-submit-listing.php
Comment thread includes/controllers/pages/class-submit-listing.php
Comment thread includes/controllers/pages/class-submit-listing.php
Comment thread includes/controllers/pages/class-submit-listing.php
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 576ee46 and e9437b3.

📒 Files selected for processing (1)
  • includes/controllers/pages/class-submit-listing.php

Comment thread 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
@Strategy11 Strategy11 deleted a comment from coderabbitai Bot Apr 30, 2026
@sorinmarta sorinmarta merged commit 2bc3ca7 into master May 5, 2026
7 checks passed
@sorinmarta sorinmarta deleted the fix-residual-bug branch May 5, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run analysis Runs phpcs and phpunit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants