WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#37369 closed defect (bug) (invalid)

registered_meta_key_exists() must return only Boolean, not WP_error as it is used by unregister_meta_key() and get_registered_metadata() which alredy return WP_error

Reported by: vishalkakadiya Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.6
Component: Options, Meta APIs Keywords: has-patch
Focuses: Cc:

Description

registered_meta_key_exists() must return only Boolean, not WP_error as it is used by unregister_meta_key() and get_registered_metadata() which has<br />

<?php
if ( ! registered_meta_key_exists( $object_type, $object_subtype, $meta_key ) ) {
                        return new WP_Error( 'invalid_meta_key', __( 'Invalid meta key. Not registered.' ) );
                }

this type of condition and if the WP_error is return then it will not throw error, but it goes further.

Attachments (2)

meta.patch (1.1 KB) - added by vishalkakadiya 6 years ago.
37369.patch (520 bytes) - added by vishalkakadiya 6 years ago.
Refresh this patch added comment and removed if conditions from unregister_meta_key() as it is already checked in registered_meta_key_exists()

Download all attachments as: .zip

Change History (6)

@vishalkakadiya
6 years ago

#1 @vishalkakadiya
6 years ago

  • Keywords has-patch added

@vishalkakadiya
6 years ago

Refresh this patch added comment and removed if conditions from unregister_meta_key() as it is already checked in registered_meta_key_exists()

#2 @SergeyBiryukov
6 years ago

  • Milestone changed from Awaiting Review to 4.6

#3 @jeremyfelt
6 years ago

Thanks for the ticket and patch @vishalkakadiya. I've incorporated the boolean return type in the latest patch on #35658.

#4 @jeremyfelt
6 years ago

  • Milestone 4.6 deleted
  • Resolution set to invalid
  • Status changed from new to closed

wp_object_type_exists() has been removed via [38095].

Note: See TracTickets for help on using tickets.