Commit 0d26e4a967 for wordpress.org
commit 0d26e4a967780a02e42c6d9edecc21c4c03dccd5
Author: westonruter <westonruter@git.wordpress.org>
Date: Wed Nov 4 23:10:01 2026 +0000
Docs: Allow numeric strings for date parts and meta IDs.
The `wp_checkdate()` and `*_metadata_by_mid()` functions already validate their numeric arguments with `is_numeric()` and cast them to integers, and core callers pass strings: date parts cut from a date string, and meta IDs read with `$wpdb->get_col()`. Their docblocks still documented `int` only, which caused 17 PHPStan `argument.type` errors. The arguments are now documented as `int|string`, with PHPStan narrowing them to `int|numeric-string`. The `checkdate()` ranges are deliberately not applied to `wp_checkdate()`, since the function's purpose is to validate input that may be out of range.
Developed in https://github.com/WordPress/wordpress-develop/pull/15472.
Follow-up to r18494, r20435, r38699, r61172.
Props pwtyler, westonruter.
See #65817.
Built from https://develop.svn.wordpress.org/trunk@65269
git-svn-id: http://core.svn.wordpress.org/trunk@64418 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index f215d81f73..eac938b2c4 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -7631,11 +7631,15 @@ function wp_is_stream( $path ) {
*
* @link https://www.php.net/manual/en/function.checkdate.php
*
- * @param int $month Month number.
- * @param int $day Day number.
- * @param int $year Year number.
- * @param string $source_date The date to filter.
+ * @param int|string $month Month number.
+ * @param int|string $day Day number.
+ * @param int|string $year Year number.
+ * @param string $source_date The date to filter.
* @return bool True if valid date, false if not valid date.
+ *
+ * @phpstan-param int|numeric-string $month
+ * @phpstan-param int|numeric-string $day
+ * @phpstan-param int|numeric-string $year
*/
function wp_checkdate( $month, $day, $year, $source_date ) {
$checkdate = false;
diff --git a/wp-includes/meta.php b/wp-includes/meta.php
index 765ce96e58..e67429e44a 100644
--- a/wp-includes/meta.php
+++ b/wp-includes/meta.php
@@ -840,9 +840,9 @@ function metadata_exists( $meta_type, $object_id, $meta_key ) {
*
* @global wpdb $wpdb WordPress database abstraction object.
*
- * @param string $meta_type Type of object metadata is for. Accepts 'blog', 'post', 'comment', 'term',
- * 'user', or any other object type with an associated meta table.
- * @param int $meta_id ID for a specific meta row.
+ * @param string $meta_type Type of object metadata is for. Accepts 'blog', 'post', 'comment', 'term',
+ * 'user', or any other object type with an associated meta table.
+ * @param int|string $meta_id ID for a specific meta row.
* @return stdClass|false {
* Metadata object, or boolean `false` if the metadata doesn't exist.
*
@@ -856,6 +856,8 @@ function metadata_exists( $meta_type, $object_id, $meta_key ) {
* @type string $term_id Optional. The object ID when the meta type is 'term'.
* @type string $user_id Optional. The object ID when the meta type is 'user'.
* }
+ *
+ * @phpstan-param int|numeric-string $meta_id
*/
function get_metadata_by_mid( $meta_type, $meta_id ) {
global $wpdb;
@@ -923,10 +925,12 @@ function get_metadata_by_mid( $meta_type, $meta_id ) {
*
* @param string $meta_type Type of object metadata is for. Accepts 'blog', 'post', 'comment', 'term',
* 'user', or any other object type with an associated meta table.
- * @param int $meta_id ID for a specific meta row.
+ * @param int|string $meta_id ID for a specific meta row.
* @param string $meta_value Metadata value. Must be serializable if non-scalar.
* @param string|false $meta_key Optional. You can provide a meta key to update it. Default false.
* @return bool True on successful update, false on failure.
+ *
+ * @phpstan-param int|numeric-string $meta_id
*/
function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key = false ) {
global $wpdb;
@@ -1048,10 +1052,12 @@ function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key =
*
* @global wpdb $wpdb WordPress database abstraction object.
*
- * @param string $meta_type Type of object metadata is for. Accepts 'blog', 'post', 'comment', 'term',
- * 'user', or any other object type with an associated meta table.
- * @param int $meta_id ID for a specific meta row.
+ * @param string $meta_type Type of object metadata is for. Accepts 'blog', 'post', 'comment', 'term',
+ * 'user', or any other object type with an associated meta table.
+ * @param int|string $meta_id ID for a specific meta row.
* @return bool True on successful delete, false on failure.
+ *
+ * @phpstan-param int|numeric-string $meta_id
*/
function delete_metadata_by_mid( $meta_type, $meta_id ) {
global $wpdb;
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 32fefc9b23..3e6c1f061b 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-beta4-65268';
+$wp_version = '7.2-beta4-65269';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.