Skip to content

pr: [Nightly Fix] - Null Safety - Guard Missing Duplicate Source#10

Open
jewel-claw wants to merge 1 commit intomasterfrom
nightly-fix/duplicate-missing-table-guard
Open

pr: [Nightly Fix] - Null Safety - Guard Missing Duplicate Source#10
jewel-claw wants to merge 1 commit intomasterfrom
nightly-fix/duplicate-missing-table-guard

Conversation

@jewel-claw
Copy link

What

  • guard the duplicate-table endpoint when the requested source table no longer exists or is not a Ninja Tables post

Why

  • the duplicate action only checked that the ID was non-zero before dereferencing the post object
  • requests targeting deleted or invalid IDs could call post properties on null and crash the handler instead of returning a clean error

Fix

  • validate the loaded post before duplicating it
  • return a 404 response when the source table is missing or invalid

Confidence

  • linted app/Http/Controllers/TablesController.php with php -l

@greptile-apps
Copy link

greptile-apps bot commented Mar 19, 2026

PR author is not in the allowed authors list.

@kilo-code-bot
Copy link

kilo-code-bot bot commented Mar 19, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 0

Analysis

The code change adds proper null safety validation to the duplicate method in TablesController.php. The fix:

  • Checks if the post exists before accessing its properties
  • Validates the post type matches the expected CPT name ($this->cptName)
  • Returns a 404 response with a user-friendly message when validation fails

This prevents potential null pointer exceptions when duplicating tables that have been deleted or when invalid IDs are passed. The implementation follows the existing codebase patterns and uses proper WordPress conventions.

Files Reviewed (1 file)
  • app/Http/Controllers/TablesController.php - No issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant