General: Replace older-style PHP type conversion functions with type casts.
This improves performance, readability, and consistency throughout core. * `intval()` → `(int)` * `strval()` → `(string)` * `floatval()` → `(float)` Props ayeshrajans. Fixes #42918. Built from https://develop.svn.wordpress.org/trunk@49108 git-svn-id: http://core.svn.wordpress.org/trunk@48870 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -763,7 +763,7 @@ class WP_Query {
|
||||
$qv['p'] = 0;
|
||||
$qv['error'] = '404';
|
||||
} else {
|
||||
$qv['p'] = intval( $qv['p'] );
|
||||
$qv['p'] = (int) $qv['p'];
|
||||
}
|
||||
|
||||
$qv['page_id'] = absint( $qv['page_id'] );
|
||||
@@ -942,7 +942,7 @@ class WP_Query {
|
||||
$this->is_trackback = true;
|
||||
}
|
||||
|
||||
if ( '' != $qv['paged'] && ( intval( $qv['paged'] ) > 1 ) ) {
|
||||
if ( '' != $qv['paged'] && ( (int) $qv['paged'] > 1 ) ) {
|
||||
$this->is_paged = true;
|
||||
}
|
||||
|
||||
@@ -1604,7 +1604,7 @@ class WP_Query {
|
||||
// If RAND() contains a seed value, sanitize and add to allowed keys.
|
||||
$rand_with_seed = false;
|
||||
if ( preg_match( '/RAND\(([0-9]+)\)/i', $orderby, $matches ) ) {
|
||||
$orderby = sprintf( 'RAND(%s)', intval( $matches[1] ) );
|
||||
$orderby = sprintf( 'RAND(%s)', (int) $matches[1] );
|
||||
$allowed_keys[] = $orderby;
|
||||
$rand_with_seed = true;
|
||||
}
|
||||
@@ -2263,7 +2263,7 @@ class WP_Query {
|
||||
// Numeric comment count is converted to array format.
|
||||
if ( is_numeric( $q['comment_count'] ) ) {
|
||||
$q['comment_count'] = array(
|
||||
'value' => intval( $q['comment_count'] ),
|
||||
'value' => (int) $q['comment_count'],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user