[wp-trac] [WordPress Trac] #28517: Logic error in WP_Rewrite flush_rules
WordPress Trac
noreply at wordpress.org
Thu Jun 12 20:42:03 UTC 2014
#28517: Logic error in WP_Rewrite flush_rules
---------------------------+-----------------------------
Reporter: numis | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Rewrite Rules | Version: trunk
Severity: normal | Keywords:
Focuses: |
---------------------------+-----------------------------
The current logic in flush_rules of WP_Rewrite is flawed:
{{{
if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) ) {
return;
}
}}}
Given the four possible scenarios:
$hard has two unique values:
* true (by default)
* false
Casting apply_filters( 'flush_rewrite_rules_hard', true ) to a boolean
also has two unique values:
* true (by default)
* true (a filter returns a value that evaluates to true)
* false (a filter returns a value that evaluates to false)
=============================================
If $hard is true and either no filters are added, or a filter is added
that returns true:
{{{
! true || ! true = false || false = false
}}}
{{{
#!html
<span style="color: red; font-weight: strong;" >UNINTENTIONAL
FAILURE</span>
}}}
=============================================
If $hard is true and a filter is added that returns false:
{{{
! true || ! false = false || true = true
}}}
{{{
#!html
<span style="color: orange; font-weight: strong;" >UNINTENTIONAL
SUCCESS</span>
}}}
=============================================
If $hard is false and either no filters are added, or a filter is added
that returns true:
{{{
! false || ! true = true || false = true
}}}
{{{
#!html
<span style="color: orange; font-weight: strong;" >UNINTENTIONAL
SUCCESS</span>
}}}
=============================================
If $hard is false and a filter is added that returns false:
{{{
! false || ! false = true || true = true
}}}
{{{
#!html
<span style="color: red; font-weight: strong;" >UNINTENTIONAL
FAILURE</span>
}}}
=============================================
As seen above, 50% of the unique scenarios give an unexpected response.
While the other 50% of the scenarios give the expected response, but for
the wrong reason.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28517>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list