redux-framework icon indicating copy to clipboard operation
redux-framework copied to clipboard

Reset All = Uninitialized string offset: 0 - PHP v5.2

Open Jim-E opened this issue 11 years ago • 8 comments

Redux as Plugin: v3.4.1 WordPress: v4.1 PHP v5.2.17 'dev_mode' => false, 'WP_DEBUG', true

Not sure you even want to fix this as it looks like a PHP 5.2 issue, switch to 5.3, 5.4 or 5.5 and it goes away.

When Reset All I get:

Notice: Uninitialized string offset: 0 in /home/otcom/public_html/dev/wp-content/plugins/redux-framework/ReduxCore/framework.php on line 2165

This is the field that causes it.

                    array(
                        'id'          => 'opt-slides',
                        'type'        => 'slides',
                        'title'       => __( 'Slides Options', 'redux-framework-demo' ),
                        'subtitle'    => __( 'Unlimited slides with drag and drop sortings.', 'redux-framework-demo' ),
                        'desc'        => __( 'This field will store all slides values into a multidimensional array to use into a foreach loop.', 'redux-framework-demo' ),
                        'placeholder' => array(
                            'title'       => __( 'This is a title', 'redux-framework-demo' ),
                            'description' => __( 'Description Here', 'redux-framework-demo' ),
                            'url'         => __( 'Give us a link!', 'redux-framework-demo' ),
                        ),
                    ),

Jim-E avatar Jan 31 '15 03:01 Jim-E

You may just want to upgrade to something newer. We're giving serious consideration to making Redux 5.3 minimum.

For posterity tho, what does line 2156 say in your framework.php. I want to make sure it's the same as mine.

kprovance avatar Jan 31 '15 04:01 kprovance

I test on a host that has a PHP version switcher, so I'm just testing on PHP 5.2. Just thought I would put it out there.

My line 2156 is just 150;

                            if ( $field['type'] == "background" ) {
                                if ( isset( $this->options[ $field['id'] ]['media']['id'] ) && isset( $this->options[ $field['id'] ]['background-image'] ) && ! empty( $this->options[ $field['id'] ]['background-image'] ) && strpos( $this->options[ $field['id'] ]['background-image'], str_replace( 'http://', '', WP_CONTENT_URL ) ) === false ) {
                                    $data = wp_get_attachment_url( $this->options[ $field['id'] ]['media']['id'] );

                                    if ( isset( $data ) && ! empty( $data ) ) {
                                        $this->options[ $field['id'] ]['background-image']   = $data;
                                        $data                                                = wp_get_attachment_image_src( $this->options[ $field['id'] ]['media']['id'], array(
                                            150,
     // Line 2156                    150
                                        ) );
                                        $this->options[ $field['id'] ]['media']['thumbnail'] = $data[0];
                                        $doUpdate                                            = true;
                                    }
                                }
                            }

Jim-E avatar Jan 31 '15 04:01 Jim-E

Ugh, I mean 2165, the line number from the error. Sorry, mistyped. :)

kprovance avatar Jan 31 '15 04:01 kprovance

Haha, I missed that one too.

                            if ( $field['type'] == "slides" ) {
 // Line 2165                               if ( isset( $this->options[ $field['id'] ][0]['attachment_id'] ) && isset( $this->options[ $field['id'] ][0]['image'] ) && ! empty( $this->options[ $field['id'] ][0]['image'] ) && strpos( $this->options[ $field['id'] ][0]['image'], str_replace( 'http://', '', WP_CONTENT_URL ) ) === false ) {
                                    foreach ( $this->options[ $field['id'] ] as $key => $val ) {
                                        $data = wp_get_attachment_url( $val['attachment_id'] );

                                        if ( isset( $data ) && ! empty( $data ) ) {
                                            $this->options[ $field['id'] ][ $key ]['image'] = $data;
                                            $data                                         = wp_get_attachment_image_src( $val['attachment_id'], array(
                                                150,
                                                150
                                            ) );
                                            $this->options[ $field['id'] ][ $key ]['thumb'] = $data[0];
                                            $doUpdate                                     = true;
                                        }
                                    }
                                }
                            }

Jim-E avatar Jan 31 '15 04:01 Jim-E

tagging in @dovy, since he has a 5.2 install. I don't. Stupid xampp. ;-)

kprovance avatar Jan 31 '15 04:01 kprovance

I'm xampp too, MAMP Pro (Mac only) is about the only local that I found that has Multi PHP down to 5.2, but I'm on Windows, so I use siteground.com for testing, lots of caching stuff too, now I see why filemtime on compiled css files, haha.

Jim-E avatar Jan 31 '15 04:01 Jim-E

@Jim-E Figured I was in here and have 5.2 available. Looks like maybe just adding is_array( $this->options[ $field['id'] ] ) fixes that issue.

So line 2165 becomes the below in framework.php file

if ( is_array( $this->options[ $field['id'] ] ) && isset( $this->options[ $field['id'] ][0]['attachment_id'] ) && isset( $this->options[ $field['id'] ][0]['image'] ) && ! empty( $this->options[ $field['id'] ][0]['image'] ) && strpos( $this->options[ $field['id'] ][0]['image'], str_replace( 'http://', '', WP_CONTENT_URL ) ) === false ) {

:)

Webcreations907 avatar Feb 05 '15 00:02 Webcreations907

Fix added and push to v3.4.2.3. Thanks a ton, @Webcreations907! :)

kprovance avatar Feb 05 '15 05:02 kprovance