• Resolved drbroad

    (@drbroad)


    Using the latest version (3.0.9) and installing the ACF Blocks plugin (https://www.ads-software.com/plugins/acf-blocks/) Im getting PHP errors:

    Cannot access offset of type string on string at line 59 of cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/traits/trait-params.php:59

    $new[ $key ] = $value;

    From the stack trace:

    
    TypeError:
    Cannot access offset of type string on string
    
      at /Users/mb/Desktop/www/test/site/web/app/mu-plugins/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/traits/trait-params.php:59
      at Cloudinary\Settings->set_param_array(array(), '', '')
         (/Users/mb/Desktop/www/test/site/web/app/mu-plugins/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/traits/trait-params.php:48)
      at Cloudinary\Settings->set_param_array(array('acf-blocks'), '', '')
         (/Users/mb/Desktop/www/test/site/web/app/mu-plugins/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/traits/trait-params.php:48)
      at Cloudinary\Settings->set_param_array(array('paths', 'acf-blocks'), array('enabled' => 'off', 'paths' => ''), '')
         (/Users/mb/Desktop/www/test/site/web/app/mu-plugins/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/traits/trait-params.php:48)
      at Cloudinary\Settings->set_param_array(array('plugins', 'paths', 'acf-blocks'), array('plugins' => array('enabled' => 'off', 'paths' => ''), 'themes' => array('enabled' => 'off', 'paths' => array('fir-blocks' => 'off')), 'wordpress' => array('enabled' => 'off', 'paths' => array('wp_admin' => 'on', 'wp_includes' => 'off')), 'content' => array('enabled' => 'off', 'paths' => array('wp_content' => 'off'))), '')
         (/Users/mb/Desktop/www/test/site/web/app/mu-plugins/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/traits/trait-params.php:48)
      at Cloudinary\Settings->set_param_array(array('assets', 'plugins', 'paths', 'acf-blocks'), array('enable' => 'off', 'cld_purge_all' => '', 'assets' => array('plugins' => array('enabled' => 'off', 'paths' => ''), 'themes' => array('enabled' => 'off', 'paths' => array('fir-blocks' => 'off')), 'wordpress' => array('enabled' => 'off', 'paths' => array('wp_admin' => 'on', 'wp_includes' => 'off')), 'content' => array('enabled' => 'off', 'paths' => array('wp_content' => 'off')))), '')

    `

    Not sure whats going on.

    • This topic was modified 2 years ago by drbroad.
Viewing 5 replies - 1 through 5 (of 5 total)
  • tamaracloudinary

    (@tamaracloudinary)

    Hi there,

    Thanks for your message.

    Based on the error stack trace, the error is originating from line 59 here:
    https://github.com/cloudinary/cloudinary_wordpress/blob/master/php/traits/trait-params.php#L59

    It appears the issue is that in your case $new is a string rather than an array and then the $new[ $key ] syntax gets interpreted as trying to access a char index of the string while the index ($key) is also a string hence the error.

    To debug this further, may I please ask you to edit that file and edit line 43 to add a line to print/log the value of $parts, $param and $value and then try to install the plugin again?
    https://github.com/cloudinary/cloudinary_wordpress/blob/master/php/traits/trait-params.php#L43

    From the stack trace, we can see the initial call to that method passes set_param_array(Array, Array, '')and the last call isset_param_array(Array, ‘on’, ”)` but we don’t know the contents of the initial 2 arrays.

    Best,
    Tamara

    Thread Starter drbroad

    (@drbroad)

    Yes, I understand what is happening. I don’t understand why it isn’t being type checked before attempting to access it.

    You should know that dumping out those three arguments is going to cause the browser to crash due to the sheer amount of data being output.
    You only want to see the data if it is malformed so I added this into the code:

    
    if ( '' === $key ) {
    			$new[] = $value;
    		} else {
    			if(!is_array($new)){
    				echo "--------------- <br>";
    				echo "Parts: <br>";
    				var_dump ($parts);
    
    				echo "<br><br>Param: <br>";
    				var_dump ($param);
    
    				echo "<br><br>Value: <br>";
    				var_dump ($value);
    				die();
    			}
    			
    			$new[ $key ] = $value;
    		}
    
    

    And the output is:

    
    ---------------
    Parts:
    array(0) { }
    
    Param:
    string(0) ""
    
    Value:
    string(0) ""

    `

    So why not just add something like this on like 55:
    if(!is_array($new)) return $new;

    Given that this is an issue with your plugin argument handling, I’m curious why you are asking me to debug your code rather than your developers?

    • This reply was modified 2 years ago by drbroad.
    • This reply was modified 2 years ago by drbroad.
    Plugin Support Victor @ Cloudinary

    (@victorcloudinary)

    Hi there,

    Thanks for the update. We’re passing this information along to the plugin dev team and will let you know once we have updates to share.

    Regards,
    Victor

    Plugin Support loic @ cloudinary

    (@loiccloudinary)

    Hi @drbroad,

    Would you mind opening a ticket to [email protected] and sharing with us a system report as explained here If you can also add some assets to the system report (cf 2nd video) that would also be helpful.

    Can you confirm it is also happening only with the last version of ACF Blocks?

    Thanks,
    Loic

    Plugin Support Victor @ Cloudinary

    (@victorcloudinary)

    Hi @drbroad,

    Just wanted to follow up and ask if you’ve had a chance to review Loic’s latest message? Please let us know if there are updates and we’d be happy to help.

    Regards,
    Victor

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Throws an error when activating ACF Blocks plugin’ is closed to new replies.