Make WordPress Core

Ticket #30430: bug30430.php

File bug30430.php, 534 bytes (added by jamesgol, 10 years ago)

Demo of bug using shortcode

Line 
1<?php
2/*
3Plugin Name: Bug 30430
4Description: Demonstrate caching of arrays in objects and objects in arrays
5Author: James Golovich
6*/
7
8add_shortcode( 'bug30430', 'jmg_show_bug' );
9
10function jmg_show_bug() {
11        $a = array();
12        $a['test'] = new StdClass();
13        $a['test']->test = 'the';
14        $a['test']->test2 = 'the';
15        $a['test']->test3 = 'the';
16
17        wp_cache_set( 'jmg-array-of-obj', $a );
18        $new = wp_cache_get( 'jmg-array-of-obj' );
19        unset( $new["test"]->test2 );
20
21        return "Value of test2 (expected is 'the'): " . $a['test']->test2 . "</br>";
22
23}