WordPress.org

Make WordPress Core

Changeset 48214


Ignore:
Timestamp:
06/29/2020 09:20:11 PM (15 months ago)
Author:
SergeyBiryukov
Message:

Docs: Improve documentation for the $prev_value parameter and return result of various metadata update functions.

Props stevenlinx.
Fixes #50502. See #49572.

Location:
trunk/src/wp-includes
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r48208 r48214  
    518518 * @param mixed  $meta_value Metadata value. Must be serializable if non-scalar.
    519519 * @param mixed  $prev_value Optional. Previous value to check before updating.
    520  *                           Default empty.
     520 *                           If specified, only update existing metadata entries with
     521 *                           this value. Otherwise, update all entries. Default empty.
    521522 * @return int|bool Meta ID if the key didn't exist, true on successful update,
    522  *                  false on failure.
     523 *                  false on failure or if the value passed to the function
     524 *                  is the same as the one that is already in the database.
    523525 */
    524526function update_comment_meta( $comment_id, $meta_key, $meta_value, $prev_value = '' ) {
  • trunk/src/wp-includes/meta.php

    r48192 r48214  
    149149 * @param string $meta_key   Metadata key.
    150150 * @param mixed  $meta_value Metadata value. Must be serializable if non-scalar.
    151  * @param mixed  $prev_value Optional. If specified, only update existing metadata entries
    152  *                           with this value. Otherwise, update all entries. Default empty.
    153  * @return int|bool The new meta field ID if a field with the given key didn't exist and was
    154  *                  therefore added, true on successful update, false on failure.
     151 * @param mixed  $prev_value Optional. Previous value to check before updating.
     152 *                           If specified, only update existing metadata entries with
     153 *                           this value. Otherwise, update all entries. Default empty.
     154 * @return int|bool The new meta field ID if a field with the given key didn't exist
     155 *                  and was therefore added, true on successful update,
     156 *                  false on failure or if the value passed to the function
     157 *                  is the same as the one that is already in the database.
     158
    155159 */
    156160function update_metadata( $meta_type, $object_id, $meta_key, $meta_value, $prev_value = '' ) {
     
    196200     * @param string    $meta_key   Metadata key.
    197201     * @param mixed     $meta_value Metadata value. Must be serializable if non-scalar.
    198      * @param mixed     $prev_value Optional. If specified, only update existing metadata entries
    199      *                              with this value. Otherwise, update all entries.
     202     * @param mixed     $prev_value Optional. Previous value to check before updating.
     203     *                              If specified, only update existing metadata entries with
     204     *                              this value. Otherwise, update all entries.
    200205     */
    201206    $check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value );
  • trunk/src/wp-includes/ms-site.php

    r48167 r48214  
    11081108 * @param mixed  $meta_value Metadata value. Must be serializable if non-scalar.
    11091109 * @param mixed  $prev_value Optional. Previous value to check before updating.
    1110  *                           Default empty.
     1110 *                           If specified, only update existing metadata entries with
     1111 *                           this value. Otherwise, update all entries. Default empty.
    11111112 * @return int|bool Meta ID if the key didn't exist, true on successful update,
    1112  *                  false on failure.
     1113 *                  false on failure or if the value passed to the function
     1114 *                  is the same as the one that is already in the database.
    11131115 */
    11141116function update_site_meta( $site_id, $meta_key, $meta_value, $prev_value = '' ) {
  • trunk/src/wp-includes/post.php

    r48212 r48214  
    21412141 * @param mixed  $meta_value Metadata value. Must be serializable if non-scalar.
    21422142 * @param mixed  $prev_value Optional. Previous value to check before updating.
    2143  *                           Default empty.
     2143 *                           If specified, only update existing metadata entries with
     2144 *                           this value. Otherwise, update all entries. Default empty.
    21442145 * @return int|bool Meta ID if the key didn't exist, true on successful update,
    2145  *                  false on failure.
     2146 *                  false on failure or if the value passed to the function
     2147 *                  is the same as the one that is already in the database.
    21462148 */
    21472149function update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) {
  • trunk/src/wp-includes/taxonomy.php

    r48197 r48214  
    12751275 * @param mixed  $meta_value Metadata value. Must be serializable if non-scalar.
    12761276 * @param mixed  $prev_value Optional. Previous value to check before updating.
    1277  *                           Default empty.
     1277 *                           If specified, only update existing metadata entries with
     1278 *                           this value. Otherwise, update all entries. Default empty.
    12781279 * @return int|bool|WP_Error Meta ID if the key didn't exist. true on successful update,
    1279  *                           false on failure. WP_Error when term_id is ambiguous
    1280  *                           between taxonomies.
     1280 *                           false on failure or if the value passed to the function
     1281 *                           is the same as the one that is already in the database.
     1282 *                           WP_Error when term_id is ambiguous between taxonomies.
    12811283 */
    12821284function update_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' ) {
  • trunk/src/wp-includes/user.php

    r48185 r48214  
    854854 * @param mixed  $meta_value Metadata value. Must be serializable if non-scalar.
    855855 * @param mixed  $prev_value Optional. Previous value to check before updating.
    856  *                           Default empty.
     856 *                           If specified, only update existing metadata entries with
     857 *                           this value. Otherwise, update all entries. Default empty.
    857858 * @return int|bool Meta ID if the key didn't exist, true on successful update,
    858  *                  false on failure.
     859 *                  false on failure or if the value passed to the function
     860 *                  is the same as the one that is already in the database.
    859861 */
    860862function update_user_meta( $user_id, $meta_key, $meta_value, $prev_value = '' ) {
Note: See TracChangeset for help on using the changeset viewer.