Title: Version 2.5.2 breaks WP-CLI
Last modified: November 15, 2022

---

# Version 2.5.2 breaks WP-CLI

 *  [giladehven](https://wordpress.org/support/users/giladehven/)
 * (@giladehven)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/version-2-5-2-breaks-wp-cli/)
 * Upon running any WP-CLI command:
 * `Warning: Trying to access array offset on value of type null in /.../plugins/
   svg-support/functions/mime-types.php on line 22`
 * And:
 * `Fatal error: Uncaught TypeError: array_intersect(): Argument #1 ($array) must
   be of type array, null given in /.../plugins/svg-support/functions/mime-types.
   php:28`
 * Adding something like `if ( is_array( $allowed_roles_array ) )` to the offending
   line “fixes” the issue (albeit only until the next update, of course). Unfortunately,
   I didn’t have a chance to look into whether there is fallout elsewhere (I only
   went this hack route to avoid deactivating and reactivating the plugin every 
   time I need to do something with WP-CLI while we wait for a real fix).
 * Wonderful plugin, BTW!

Viewing 15 replies - 1 through 15 (of 15 total)

 *  [bezzo](https://wordpress.org/support/users/bezzo/)
 * (@bezzo)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/version-2-5-2-breaks-wp-cli/#post-16204291)
 * I can confirm the issue. While the plugin is activated running any `wp-cli` command
   causes to throw an error.
 *     ```
       $ wp plugin list
   
       In mime-types.php line 22:
       Trying to access array offset on value of type null`
       ```
   
 *  [mabioneto](https://wordpress.org/support/users/mabioneto/)
 * (@mabioneto)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/version-2-5-2-breaks-wp-cli/#post-16205702)
 * The error is being raised because no user is logged in. Before it would raise
   just a warning, but now is a fatal error and it breaks wp-cli, among other things.
 * To fix until the developer patches on the next upcoming upgrade, just add the
   following 3 lines right after line 24 (on the file svg-support/functions/mime-
   types.php):
    //returns if user is not logged in if ($user->ID==0) { return $mimes;}
 *  [plumbweb](https://wordpress.org/support/users/plumbweb/)
 * (@plumbweb)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/version-2-5-2-breaks-wp-cli/#post-16209162)
 * I can confirm this is happening still and on 2.5.3 as well.
 *  Thread Starter [giladehven](https://wordpress.org/support/users/giladehven/)
 * (@giladehven)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/version-2-5-2-breaks-wp-cli/#post-16209604)
 * Any idea when a lasting fix is expected?
 * Our process depends upon atomic deployments (we ship the entire code base at 
   every release), and we deploy very frequently. This means that temporary fixes
   of the type I described above (or the more complete approach that [@mabioneto](https://wordpress.org/support/users/mabioneto/)
   posted) really aren’t supportable.
 *  [Tim Nolte](https://wordpress.org/support/users/tnolte/)
 * (@tnolte)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/version-2-5-2-breaks-wp-cli/#post-16209857)
 * FYI, I can confirm that this issue is PHp 8.x related. We didn’t have a problem
   with this version of the plugin when some infrastructure was running PHP 7.4,
   after upgrading that infrastructure to PHP 8.0 this error occurred.
 *  [pkostadinov](https://wordpress.org/support/users/pkostadinov/)
 * (@pkostadinov)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/version-2-5-2-breaks-wp-cli/#post-16210938)
 * I also experienced the issue.
 * The problem is that you define a global variable, but don’t actually define it
   as global (aka missing global keyword).
 * File: svg-support/svg-support.php
    On Line 25 add this code: `global $bodhi_svgs_options;`
 * Right after the comment:
 *     ```
       /**
        * Global variables
        */
       ```
   
 * —-
 * On the separate note – other users are correct:
 * [@tnolte](https://wordpress.org/support/users/tnolte/) comment points to that
   the php.ini for the CLI version of PHP must have errors display disabled for 
   any production environment. You may have different php.ini files for the CLI 
   version, and this is totally normal, you need all of them to be setup correctly
   for production. This should be the default setup for any server, but the plugin
   creators can remind people about it, in the plugin documentation.
 * [@giladehven](https://wordpress.org/support/users/giladehven/) mentiones proper
   escaping. Just in that 1 function in file mime-types.php, there are 2 missing
   data validations:
    – Line 21: `if ( empty( $bodhi_svgs_options['restrict'] ) ){
   return $mimes; }` – Line 25: `if ( ! $user ) { return $mimes; }` ( if you don’t
   have user with ID 0, and you are not logged in which would be the case during
   the WP-CLI request, you need to just skip the remaining lines in this file)
    -  This reply was modified 3 years, 6 months ago by [pkostadinov](https://wordpress.org/support/users/pkostadinov/).
    -  This reply was modified 3 years, 6 months ago by [pkostadinov](https://wordpress.org/support/users/pkostadinov/).
 *  Thread Starter [giladehven](https://wordpress.org/support/users/giladehven/)
 * (@giladehven)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/version-2-5-2-breaks-wp-cli/#post-16211096)
 * Update: Version 2.5.4 _appears_ to resolve the issue (it’s working as expected
   in our environments).
    -  This reply was modified 3 years, 6 months ago by [giladehven](https://wordpress.org/support/users/giladehven/).
 *  [plumbweb](https://wordpress.org/support/users/plumbweb/)
 * (@plumbweb)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/version-2-5-2-breaks-wp-cli/#post-16212489)
 * Awesome, same with us! Thank you to the developer!
 *  [pkostadinov](https://wordpress.org/support/users/pkostadinov/)
 * (@pkostadinov)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/version-2-5-2-breaks-wp-cli/#post-16212516)
 * Still not fully resolved, there are PHP Warnings remaining during any WP Cli 
   commands:
 * `PHP Warning: Trying to access array offset on value of type null in /wp-content/
   plugins/svg-support/functions/mime-types.php on line 22`
 * My original suggestion for adding `global $bodhi_svgs_options;` at the beginning
   of plugin file sitll resolves the problem.
 * On the plus side – at least now there are no fatal errors…
    -  This reply was modified 3 years, 6 months ago by [pkostadinov](https://wordpress.org/support/users/pkostadinov/).
 *  Thread Starter [giladehven](https://wordpress.org/support/users/giladehven/)
 * (@giladehven)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/version-2-5-2-breaks-wp-cli/#post-16232876)
 * I’m still getting the same warning:
 * `Warning: Trying to access array offset on value of type null in ... /plugins/
   svg-support/functions/mime-types.php on line 22`
 * Is there an ETA on the fix?
    -  This reply was modified 3 years, 6 months ago by [giladehven](https://wordpress.org/support/users/giladehven/).
 *  [David Kryzaniak](https://wordpress.org/support/users/davidkryzaniak/)
 * (@davidkryzaniak)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/version-2-5-2-breaks-wp-cli/#post-16257936)
 * PHP: 7.4.33
    WP: 6.1.1 (multisite) SVG Support: 2.5.4
 * Same issue with cli. `Notice: Trying to access array offset on value of type 
   null in /home/wildone2/public_html/wp-content/plugins/svg-support/functions/mime-
   types.php on line 22`.
    -  This reply was modified 3 years, 5 months ago by [David Kryzaniak](https://wordpress.org/support/users/davidkryzaniak/).
 *  [leowp037](https://wordpress.org/support/users/leowp037/)
 * (@leowp037)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/version-2-5-2-breaks-wp-cli/#post-16273257)
 * I’m running PHP 8.1 and I also get the warning:
 * `PHP Warning: Trying to access array offset on value of type null in /wp-content/
   plugins/svg-support/functions/mime-types.php on line 22`
 *  [abitofmind](https://wordpress.org/support/users/abitofmind/)
 * (@abitofmind)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/version-2-5-2-breaks-wp-cli/#post-16275908)
 * I can confirm this bug too:
    • WP 6.1.1 • svg-support 2.5.4 • wp-cli: 2.7.1 •
   PHP version: 8.0.22
 * I even had falsely reported the bug at the [wp-cli issue tracker](https://github.com/wp-cli/extension-command/issues/346)
   until I later realized the cause must be in the svg-plugin itself.
    -  This reply was modified 3 years, 5 months ago by [abitofmind](https://wordpress.org/support/users/abitofmind/).
    -  This reply was modified 3 years, 5 months ago by [abitofmind](https://wordpress.org/support/users/abitofmind/).
 *  Thread Starter [giladehven](https://wordpress.org/support/users/giladehven/)
 * (@giladehven)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/version-2-5-2-breaks-wp-cli/#post-16276160)
 * The plugin itself appears to be working, and we no longer have fatal errors, 
   so this is now more of an irritation than a serious problem.
 * That said, since we have multiple projects using this plugin, and since all of
   them make frequent use of WP-CLI for management and reporting, and since all 
   our deployments are atomic (making hacky fixes impractical), this irritation 
   is actually interfering with daily work.
 * I don’t want to come across as ungrateful, this is a great plugin, but we do 
   need to get past this problem to skip the constant clean up and I really don’t
   want to move to a different plugin…
 * Can we have an ETA on a lasting fix?
 *  [abitofmind](https://wordpress.org/support/users/abitofmind/)
 * (@abitofmind)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/version-2-5-2-breaks-wp-cli/page/2/#post-16284797)
 * [@all](https://wordpress.org/support/users/all/): On my WP 6.1.1 the plugin svg-
   support today received an update from 2.5.4 to 2.5.5 and its error messages when
   invoking wp-cli are now gone.
 * The changelog for 2.5.5 says nothing specific, just “More error fixes and general
   clean up.”, buton my installation the problem is gone now.
 * As I interpret [@giladehven](https://wordpress.org/support/users/giladehven/)‘
   s comment this seems to be a recurring bug. I hope for the best… Will report 
   should I get this wp-cli error again.
    -  This reply was modified 3 years, 5 months ago by [abitofmind](https://wordpress.org/support/users/abitofmind/).
    -  This reply was modified 3 years, 5 months ago by [abitofmind](https://wordpress.org/support/users/abitofmind/).

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Version 2.5.2 breaks WP-CLI’ is closed to new replies.

 * ![](https://ps.w.org/svg-support/assets/icon.svg?rev=1417738)
 * [SVG Support](https://wordpress.org/plugins/svg-support/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/svg-support/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/svg-support/)
 * [Active Topics](https://wordpress.org/support/plugin/svg-support/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/svg-support/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/svg-support/reviews/)

 * 17 replies
 * 9 participants
 * Last reply from: [abitofmind](https://wordpress.org/support/users/abitofmind/)
 * Last activity: [3 years, 5 months ago](https://wordpress.org/support/topic/version-2-5-2-breaks-wp-cli/page/2/#post-16284797)
 * Status: not resolved