You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Safeguard correct handling of namespaced function calls.
522
+
* Safeguard correct handling of all types of namespaced calls to the WPDB::prepare() method.
523
+
*
524
+
* Note that calling wpdb::prepare() statically will result in an error. Still, the tests are included here since the
525
+
* sniff handles those calls.
523
526
*/
524
-
//$sql = MyNamespace\WPDB::prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s" );
525
-
//$sql = \MyNamespace\WPDB::prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s" );
526
-
//$sql = namespace\WPDB::prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s" ); // The sniff should start flagging this once it can resolve relative namespaces.
$sql = \WPDB::prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s" );
528
+
$sql = MyNamespace\WPDB::prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s" );
529
+
$sql = \MyNamespace\WPDB::prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s" );
530
+
$sql = namespace\WPDB::prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s" ); // The sniff should start flagging this once it can resolve relative namespaces.
531
+
532
+
/*
533
+
* Safeguard correct handling of all types of namespaced calls to sprintf() except fully qualified calls to the
534
+
* global sprintf() function, which is already handled above.
namespace\implode( ',', array_fill( 0, count($post_types), '%s' ) ) // This should be flagged in the future once the sniff is able to resolve relative namespaces.
580
+
),
581
+
$post_types
582
+
);
583
+
584
+
/*
585
+
* Safeguard correct handling of all types of namespaced calls to array_fill() except fully qualified calls to the
586
+
* global array_fill() function, which is already handled above.
implode( ',', namespace\array_fill( 0, count($post_types), '%s' ) ) // This should be flagged in the future once the sniff is able to resolve relative namespaces.
606
+
),
607
+
$post_types
608
+
);
609
+
610
+
/*
611
+
* Safeguard correct handling of namespaced implode() calls detected in the main loop (preceded by IN ()).
612
+
* These test the implode detection at line 269 in the sniff.
613
+
*/
614
+
$where = $wpdb->prepare(
615
+
"SELECT * FROM {$wpdb->posts} WHERE post_status = %s AND post_type IN (" . MyNamespace\implode( ',', array_fill( 0, count($post_types), '%s' ) ) . ")",
616
+
'publish'
617
+
);
618
+
$where = $wpdb->prepare(
619
+
"SELECT * FROM {$wpdb->posts} WHERE post_status = %s AND post_type IN (" . \MyNamespace\implode( ',', array_fill( 0, count($post_types), '%s' ) ) . ")",
620
+
'publish'
621
+
);
622
+
$where = $wpdb->prepare(
623
+
"SELECT * FROM {$wpdb->posts} WHERE post_status = %s AND post_type IN (" . namespace\implode( ',', array_fill( 0, count($post_types), '%s' ) ) . ")",
624
+
'publish'
625
+
);
626
+
627
+
/*
628
+
* Safeguard correct handling of namespaced array_fill() calls detected via main loop implode detection.
629
+
* These test the array_fill detection at line 739 called from main loop's implode at line 269.
630
+
*/
631
+
$where = $wpdb->prepare(
632
+
"SELECT * FROM {$wpdb->posts} WHERE post_status = %s AND post_type IN (" . implode( ',', MyNamespace\array_fill( 0, count($post_types), '%s' ) ) . ")",
633
+
'publish'
634
+
);
635
+
$where = $wpdb->prepare(
636
+
"SELECT * FROM {$wpdb->posts} WHERE post_status = %s AND post_type IN (" . implode( ',', \MyNamespace\array_fill( 0, count($post_types), '%s' ) ) . ")",
637
+
'publish'
638
+
);
639
+
$where = $wpdb->prepare(
640
+
"SELECT * FROM {$wpdb->posts} WHERE post_status = %s AND post_type IN (" . implode( ',', namespace\array_fill( 0, count($post_types), '%s' ) ) . ")",
0 commit comments