mirror of
git://develop.git.wordpress.org/
synced 2025-01-17 04:48:25 +01:00
Options/Meta APIs: Document type juggling of meta data.
Some checks are pending
Coding Standards / PHP coding standards (push) Waiting to run
Coding Standards / JavaScript coding standards (push) Waiting to run
Coding Standards / Slack Notifications (push) Blocked by required conditions
Coding Standards / Failed workflow tasks (push) Blocked by required conditions
End-to-end Tests / Test with SCRIPT_DEBUG disabled (push) Waiting to run
End-to-end Tests / Test with SCRIPT_DEBUG enabled (push) Waiting to run
End-to-end Tests / Slack Notifications (push) Blocked by required conditions
End-to-end Tests / Failed workflow tasks (push) Blocked by required conditions
JavaScript Tests / QUnit Tests (push) Waiting to run
JavaScript Tests / Slack Notifications (push) Blocked by required conditions
JavaScript Tests / Failed workflow tasks (push) Blocked by required conditions
Local Docker Environment / Build Test Matrix (push) Waiting to run
Local Docker Environment / PHP ${{ matrix.php }} (push) Blocked by required conditions
Local Docker Environment / Slack Notifications (push) Blocked by required conditions
Local Docker Environment / Failed workflow tasks (push) Blocked by required conditions
Performance Tests / Single site (push) Waiting to run
Performance Tests / Multisite (push) Waiting to run
Performance Tests / Slack Notifications (push) Blocked by required conditions
Performance Tests / Failed workflow tasks (push) Blocked by required conditions
PHP Compatibility / Check PHP compatibility (push) Waiting to run
PHP Compatibility / Slack Notifications (push) Blocked by required conditions
PHP Compatibility / Failed workflow tasks (push) Blocked by required conditions
PHPUnit Tests / PHP 7.2 (push) Waiting to run
PHPUnit Tests / PHP 7.3 (push) Waiting to run
PHPUnit Tests / PHP 7.4 (push) Waiting to run
PHPUnit Tests / PHP 8.0 (push) Waiting to run
PHPUnit Tests / PHP 8.1 (push) Waiting to run
PHPUnit Tests / PHP 8.2 (push) Waiting to run
PHPUnit Tests / PHP 8.3 (push) Waiting to run
PHPUnit Tests / PHP 8.4 (push) Waiting to run
PHPUnit Tests / html-api-html5lib-tests (push) Waiting to run
PHPUnit Tests / Slack Notifications (push) Blocked by required conditions
PHPUnit Tests / Failed workflow tasks (push) Blocked by required conditions
Test Build Processes / Core running from build (push) Waiting to run
Test Build Processes / Core running from src (push) Waiting to run
Test Build Processes / Gutenberg running from build (push) Waiting to run
Test Build Processes / Gutenberg running from src (push) Waiting to run
Test Build Processes / Slack Notifications (push) Blocked by required conditions
Test Build Processes / Failed workflow tasks (push) Blocked by required conditions
Some checks are pending
Coding Standards / PHP coding standards (push) Waiting to run
Coding Standards / JavaScript coding standards (push) Waiting to run
Coding Standards / Slack Notifications (push) Blocked by required conditions
Coding Standards / Failed workflow tasks (push) Blocked by required conditions
End-to-end Tests / Test with SCRIPT_DEBUG disabled (push) Waiting to run
End-to-end Tests / Test with SCRIPT_DEBUG enabled (push) Waiting to run
End-to-end Tests / Slack Notifications (push) Blocked by required conditions
End-to-end Tests / Failed workflow tasks (push) Blocked by required conditions
JavaScript Tests / QUnit Tests (push) Waiting to run
JavaScript Tests / Slack Notifications (push) Blocked by required conditions
JavaScript Tests / Failed workflow tasks (push) Blocked by required conditions
Local Docker Environment / Build Test Matrix (push) Waiting to run
Local Docker Environment / PHP ${{ matrix.php }} (push) Blocked by required conditions
Local Docker Environment / Slack Notifications (push) Blocked by required conditions
Local Docker Environment / Failed workflow tasks (push) Blocked by required conditions
Performance Tests / Single site (push) Waiting to run
Performance Tests / Multisite (push) Waiting to run
Performance Tests / Slack Notifications (push) Blocked by required conditions
Performance Tests / Failed workflow tasks (push) Blocked by required conditions
PHP Compatibility / Check PHP compatibility (push) Waiting to run
PHP Compatibility / Slack Notifications (push) Blocked by required conditions
PHP Compatibility / Failed workflow tasks (push) Blocked by required conditions
PHPUnit Tests / PHP 7.2 (push) Waiting to run
PHPUnit Tests / PHP 7.3 (push) Waiting to run
PHPUnit Tests / PHP 7.4 (push) Waiting to run
PHPUnit Tests / PHP 8.0 (push) Waiting to run
PHPUnit Tests / PHP 8.1 (push) Waiting to run
PHPUnit Tests / PHP 8.2 (push) Waiting to run
PHPUnit Tests / PHP 8.3 (push) Waiting to run
PHPUnit Tests / PHP 8.4 (push) Waiting to run
PHPUnit Tests / html-api-html5lib-tests (push) Waiting to run
PHPUnit Tests / Slack Notifications (push) Blocked by required conditions
PHPUnit Tests / Failed workflow tasks (push) Blocked by required conditions
Test Build Processes / Core running from build (push) Waiting to run
Test Build Processes / Core running from src (push) Waiting to run
Test Build Processes / Gutenberg running from build (push) Waiting to run
Test Build Processes / Gutenberg running from src (push) Waiting to run
Test Build Processes / Slack Notifications (push) Blocked by required conditions
Test Build Processes / Failed workflow tasks (push) Blocked by required conditions
Document that unserialised data types are stored as strings in the database and returned as such by the meta data functions. For example, setting meta data to the integer value `1` will be returned as `"1"` when subsequently queried via `get_metadata()` and the related functions. Props sukhendu2002, azaozz, jrf, rodrigosprimo. Fixes ticket:61950. git-svn-id: https://develop.svn.wordpress.org/trunk@59657 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ab4b4eb55d
commit
bc3fdb4648
@ -432,7 +432,13 @@ function get_comment_count( $post_id = 0 ) {
|
||||
*
|
||||
* @param int $comment_id Comment ID.
|
||||
* @param string $meta_key Metadata name.
|
||||
* @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
|
||||
* @param mixed $meta_value Metadata value. Arrays and objects are stored as serialized data and
|
||||
* will be returned as the same type when retrieved. Other data types will
|
||||
* be stored as strings in the database:
|
||||
* - false is stored and retrieved as an empty string ('')
|
||||
* - true is stored and retrieved as '1'
|
||||
* - numbers (both integer and float) are stored and retrieved as strings
|
||||
* Must be serializable if non-scalar.
|
||||
* @param bool $unique Optional. Whether the same key should not be added.
|
||||
* Default false.
|
||||
* @return int|false Meta ID on success, false on failure.
|
||||
@ -481,6 +487,11 @@ function delete_comment_meta( $comment_id, $meta_key, $meta_value = '' ) {
|
||||
* False for an invalid `$comment_id` (non-numeric, zero, or negative value).
|
||||
* An empty array if a valid but non-existing comment ID is passed and `$single` is false.
|
||||
* An empty string if a valid but non-existing comment ID is passed and `$single` is true.
|
||||
* Note: Non-serialized values are returned as strings:
|
||||
* - false values are returned as empty strings ('')
|
||||
* - true values are returned as '1'
|
||||
* - numbers are returned as strings
|
||||
* Arrays and objects retain their original type.
|
||||
*/
|
||||
function get_comment_meta( $comment_id, $key = '', $single = false ) {
|
||||
return get_metadata( 'comment', $comment_id, $key, $single );
|
||||
|
@ -23,7 +23,13 @@ require ABSPATH . WPINC . '/class-wp-metadata-lazyloader.php';
|
||||
* or any other object type with an associated meta table.
|
||||
* @param int $object_id ID of the object metadata is for.
|
||||
* @param string $meta_key Metadata key.
|
||||
* @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
|
||||
* @param mixed $meta_value Metadata value. Arrays and objects are stored as serialized data and
|
||||
* will be returned as the same type when retrieved. Other data types will
|
||||
* be stored as strings in the database:
|
||||
* - false is stored and retrieved as an empty string ('')
|
||||
* - true is stored and retrieved as '1'
|
||||
* - numbers (both integer and float) are stored and retrieved as strings
|
||||
* Must be serializable if non-scalar.
|
||||
* @param bool $unique Optional. Whether the specified metadata key should be unique for the object.
|
||||
* If true, and the object already has a value for the specified metadata key,
|
||||
* no change will be made. Default false.
|
||||
@ -570,6 +576,11 @@ function delete_metadata( $meta_type, $object_id, $meta_key, $meta_value = '', $
|
||||
* or if `$meta_type` is not specified.
|
||||
* An empty array if a valid but non-existing object ID is passed and `$single` is false.
|
||||
* An empty string if a valid but non-existing object ID is passed and `$single` is true.
|
||||
* Note: Non-serialized values are returned as strings:
|
||||
* - false values are returned as empty strings ('')
|
||||
* - true values are returned as '1'
|
||||
* - numbers (both integer and float) are returned as strings
|
||||
* Arrays and objects retain their original type.
|
||||
*/
|
||||
function get_metadata( $meta_type, $object_id, $meta_key = '', $single = false ) {
|
||||
$value = get_metadata_raw( $meta_type, $object_id, $meta_key, $single );
|
||||
|
@ -1026,7 +1026,13 @@ function clean_blog_cache( $blog ) {
|
||||
*
|
||||
* @param int $site_id Site ID.
|
||||
* @param string $meta_key Metadata name.
|
||||
* @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
|
||||
* @param mixed $meta_value Metadata value. Arrays and objects are stored as serialized data and
|
||||
* will be returned as the same type when retrieved. Other data types will
|
||||
* be stored as strings in the database:
|
||||
* - false is stored and retrieved as an empty string ('')
|
||||
* - true is stored and retrieved as '1'
|
||||
* - numbers (both integer and float) are stored and retrieved as strings
|
||||
* Must be serializable if non-scalar.
|
||||
* @param bool $unique Optional. Whether the same key should not be added.
|
||||
* Default false.
|
||||
* @return int|false Meta ID on success, false on failure.
|
||||
@ -1071,6 +1077,11 @@ function delete_site_meta( $site_id, $meta_key, $meta_value = '' ) {
|
||||
* False for an invalid `$site_id` (non-numeric, zero, or negative value).
|
||||
* An empty array if a valid but non-existing site ID is passed and `$single` is false.
|
||||
* An empty string if a valid but non-existing site ID is passed and `$single` is true.
|
||||
* Note: Non-serialized values are returned as strings:
|
||||
* - false values are returned as empty strings ('')
|
||||
* - true values are returned as '1'
|
||||
* - numbers (both integer and float) are returned as strings
|
||||
* Arrays and objects retain their original type.
|
||||
*/
|
||||
function get_site_meta( $site_id, $key = '', $single = false ) {
|
||||
return get_metadata( 'blog', $site_id, $key, $single );
|
||||
|
@ -2558,7 +2558,13 @@ function get_posts( $args = null ) {
|
||||
*
|
||||
* @param int $post_id Post ID.
|
||||
* @param string $meta_key Metadata name.
|
||||
* @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
|
||||
* @param mixed $meta_value Metadata value. Arrays and objects are stored as serialized data and
|
||||
* will be returned as the same type when retrieved. Other data types will
|
||||
* be stored as strings in the database:
|
||||
* - false is stored and retrieved as an empty string ('')
|
||||
* - true is stored and retrieved as '1'
|
||||
* - numbers (both integer and float) are stored and retrieved as strings
|
||||
* Must be serializable if non-scalar.
|
||||
* @param bool $unique Optional. Whether the same key should not be added.
|
||||
* Default false.
|
||||
* @return int|false Meta ID on success, false on failure.
|
||||
@ -2615,6 +2621,11 @@ function delete_post_meta( $post_id, $meta_key, $meta_value = '' ) {
|
||||
* False for an invalid `$post_id` (non-numeric, zero, or negative value).
|
||||
* An empty array if a valid but non-existing post ID is passed and `$single` is false.
|
||||
* An empty string if a valid but non-existing post ID is passed and `$single` is true.
|
||||
* Note: Non-serialized values are returned as strings:
|
||||
* - false values are returned as empty strings ('')
|
||||
* - true values are returned as '1'
|
||||
* - numbers (both integer and float) are returned as strings
|
||||
* Arrays and objects retain their original type.
|
||||
*/
|
||||
function get_post_meta( $post_id, $key = '', $single = false ) {
|
||||
return get_metadata( 'post', $post_id, $key, $single );
|
||||
|
@ -1386,7 +1386,13 @@ function get_terms( $args = array(), $deprecated = '' ) {
|
||||
*
|
||||
* @param int $term_id Term ID.
|
||||
* @param string $meta_key Metadata name.
|
||||
* @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
|
||||
* @param mixed $meta_value Metadata value. Arrays and objects are stored as serialized data and
|
||||
* will be returned as the same type when retrieved. Other data types will
|
||||
* be stored as strings in the database:
|
||||
* - false is stored and retrieved as an empty string ('')
|
||||
* - true is stored and retrieved as '1'
|
||||
* - numbers (both integer and float) are stored and retrieved as strings
|
||||
* Must be serializable if non-scalar.
|
||||
* @param bool $unique Optional. Whether the same key should not be added.
|
||||
* Default false.
|
||||
* @return int|false|WP_Error Meta ID on success, false on failure.
|
||||
@ -1432,6 +1438,11 @@ function delete_term_meta( $term_id, $meta_key, $meta_value = '' ) {
|
||||
* False for an invalid `$term_id` (non-numeric, zero, or negative value).
|
||||
* An empty array if a valid but non-existing term ID is passed and `$single` is false.
|
||||
* An empty string if a valid but non-existing term ID is passed and `$single` is true.
|
||||
* Note: Non-serialized values are returned as strings:
|
||||
* - false values are returned as empty strings ('')
|
||||
* - true values are returned as '1'
|
||||
* - numbers are returned as strings
|
||||
* Arrays and objects retain their original type.
|
||||
*/
|
||||
function get_term_meta( $term_id, $key = '', $single = false ) {
|
||||
return get_metadata( 'term', $term_id, $key, $single );
|
||||
|
@ -1151,7 +1151,13 @@ function is_user_member_of_blog( $user_id = 0, $blog_id = 0 ) {
|
||||
*
|
||||
* @param int $user_id User ID.
|
||||
* @param string $meta_key Metadata name.
|
||||
* @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
|
||||
* @param mixed $meta_value Metadata value. Arrays and objects are stored as serialized data and
|
||||
* will be returned as the same type when retrieved. Other data types will
|
||||
* be stored as strings in the database:
|
||||
* - false is stored and retrieved as an empty string ('')
|
||||
* - true is stored and retrieved as '1'
|
||||
* - numbers (both integer and float) are stored and retrieved as strings
|
||||
* Must be serializable if non-scalar.
|
||||
* @param bool $unique Optional. Whether the same key should not be added.
|
||||
* Default false.
|
||||
* @return int|false Meta ID on success, false on failure.
|
||||
@ -1200,6 +1206,11 @@ function delete_user_meta( $user_id, $meta_key, $meta_value = '' ) {
|
||||
* False for an invalid `$user_id` (non-numeric, zero, or negative value).
|
||||
* An empty array if a valid but non-existing user ID is passed and `$single` is false.
|
||||
* An empty string if a valid but non-existing user ID is passed and `$single` is true.
|
||||
* Note: Non-serialized values are returned as strings:
|
||||
* - false values are returned as empty strings ('')
|
||||
* - true values are returned as '1'
|
||||
* - numbers (both integer and float) are returned as strings
|
||||
* Arrays and objects retain their original type.
|
||||
*/
|
||||
function get_user_meta( $user_id, $key = '', $single = false ) {
|
||||
return get_metadata( 'user', $user_id, $key, $single );
|
||||
|
Loading…
x
Reference in New Issue
Block a user