Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #65055, comment 6


Ignore:
Timestamp:
04/14/2026 10:06:02 AM (2 months ago)
Author:
liaison
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #65055, comment 6

    initial v1  
    44> Thanks @liaison! agreed on the alignment with _update_post_term_count(). The updated patch incorporating post_type_exists() filtering looks solid.
    55
    6 Test Report:
    7 
    8 I verified the fix using a zero-dependency test script that loads the core wp-includes/taxonomy.php while mocking the database environment.
     6Test Report
     7Summary:
     8I verified the fix using a zero-dependency test script to confirm the patch logic locally before implementing formal PHPUnit test cases for the GitHub CI suite. This script loads the core wp-includes/taxonomy.php directly while mocking the database and global environment.
    99
    1010Before Patch:
    11 The logic uses direct string interpolation and includes unregistered post types in the query.
     11The logic uses direct string interpolation and includes unregistered/invalid post types in the query.
    1212
    13 Method: get_results
    14 Query: ... AND post_type IN ('post', 'ghost_type') ...
    15 ❌ FAILED: 'ghost_type' present in raw SQL string.
     13Method: wpdb::get_results (Direct string)
     14
     15Captured Query: ... AND post_type IN ('post', 'ghost_type') ...
     16
     17Result: ❌ FAILED: 'ghost_type' (unregistered) is present in the raw SQL string.
     18
    1619After Patch:
    17 The logic now correctly filters post types via post_type_exists() and uses wpdb::prepare() for the final query.
     20The logic now correctly filters post types via post_type_exists() and utilizes wpdb::prepare() for a safer, parameterized query.
    1821
    19 Method: prepare
    20 Arguments: 123, post
    21 ✅ SUCCESS: 'ghost_type' filtered from prepare arguments.
     22Method: wpdb::prepare
    2223
     24Captured Arguments: 123, post
     25
     26Result: ✅ SUCCESS: 'ghost_type' was successfully filtered, and only valid post types are passed to the prepare arguments.
    2327test-65055-sql-filter.php
    2428{{{#!php