Bug in "jr_saoe_get_post_metadata" function
-
I’ve found the following bug in “Shortcode Anywhere and Everywhere”
includes/public.php
line 71return jr_saoe_maybe_array( maybe_unserialize( $meta_cache[$meta_key][0] ) );
It should be as follows:
return array( jr_saoe_maybe_array( maybe_unserialize( $meta_cache[$meta_key][0] ) ) );
This issues breaks the use of arrays in post meta data site wide.
The following PHP Notice is produced:
Notice: Undefined offset: 0 in /wp-includes/meta.php on line 489
You can test the issue with the following, put it in your functions PHP and then navigate to “/testing-page/”
// turn on debug if ( ! defined( 'WP_DEBUG' ) ) { define( 'WP_DEBUG', true ); } add_action( 'init', 'my_init' ); function my_init() { // create a test page so as to set meta data (page created only once) $page = get_page_by_title( 'Testing Page' ); if ( isset( $page->ID ) ) { $page_id = $page->ID; } else { $page_id = wp_insert_post( array ( 'post_content' => 'Testing, delete when finished', 'post_title' => 'Testing Page', 'post_type' => 'page', 'post_status' => 'publish', ) ); } // THIS DOESN'T WORK // create some meta data, the issue is with array values add_post_meta( $page_id, 'my_sample_arr', array( 'foo' => 'bar', 'baz' => 'zap' ), true ); // get the meta data, this should produce NULL even though the data is set correctly $meta = get_post_meta( $page_id, 'my_sample_arr', true ); echo '<pre style="padding-left:300px;"> page meta arr value is: '; var_dump( $meta ); echo '</pre>'; // THIS WORKS // create some meta data, non array data add_post_meta( $page_id, 'my_sample_str', 'foobar', true ); // get the meta data, this should produce NULL even though the data is set correctly $meta = get_post_meta( $page_id, 'my_sample_str', true ); echo '<pre style="padding-left:300px;"> page meta str value is: '; var_dump( $meta ); echo '</pre>'; }
https://www.ads-software.com/plugins/jonradio-shortcodes-anywhere-or-everywhere/
- The topic ‘Bug in "jr_saoe_get_post_metadata" function’ is closed to new replies.