cedaro / simple-image-widget

A simple WordPress image widget.
32 stars 19 forks source link

I get a warning with the latest upgrade to 4.2.0 #10

Closed simoami closed 9 years ago

simoami commented 9 years ago
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/user/public_html/wp-content/plugins/simple-image-widget/includes/class-simple-image-widget.php on line 560
bradyvercher commented 9 years ago

Hi @simoami. Thanks for the report. I'm not able to reproduce this -- can you let me know when you're seeing that notice and what PHP version you're running?

simoami commented 9 years ago

v5.2.8

simoami commented 9 years ago

The array_merge function prior to 5.3.0 only supports integers. See changelog. So I used a custom function instead.

        protected function my_array_reduce($array, $callback, $initial=null) {
                $acc = $initial;
                foreach($array as $a)
                        $acc = $callback($acc, $a);
                return $acc;
        }

        protected function siw_get_cache_key() {
                $data = self::my_array_reduce( func_get_args(), 'array_merge', array());
                ksort( $data );
                return 'siw_' . md5( json_encode( $data ) );
        }
bradyvercher commented 9 years ago

Thanks for helping identify that so quickly, @simoami! When I get a chance, I'll likely just replace the array_reduce call with a loop. In the meantime, I may need to locate a machine with PHP 5.2 on it!

simoami commented 9 years ago

sounds good. Thanks for looking into it!

bradyvercher commented 9 years ago

No problem. I forgot this was still open. The last release (4.2.1) should have fixed it, but let me know if you're still having any issues.