Title: PHP Notice with WP_HTTP_BLOCK_EXTERNAL enable
Last modified: October 15, 2021

---

# PHP Notice with WP_HTTP_BLOCK_EXTERNAL enable

 *  Resolved [vitoralmeida](https://wordpress.org/support/users/vitoralmeida/)
 * (@vitoralmeida)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/php-notice-with-wp_http_block_external-enable/)
 * Hello all, thanks for this incredible plugin!
    Reviewing server logs, we found
   several php notices about “Trying to access array offset on value of type null”
   on autoptimizeImages class.
 * In our production server we block all external connections and make some exceptions
   and the service used to fetch status ([https://misc.optimizingmatters.com/api/autoptimize_service_availablity.json?from=aomain&ver=](https://misc.optimizingmatters.com/api/autoptimize_service_availablity.json?from=aomain&ver=))
   ins’t in this whitelist (and cant be because infrastructure restrictions)
 * At ./autoptimize/classes/autoptimizeCriticalCSSSettings.php line 255/256 (////
   warn if service is down.) your code tests the condition of autoptimize_service_availablity,
   to prevent invalid array access.
 * It’s possible to do the same thing at this point ./autoptimize/classes/autoptimizeImages.
   php line 204/205 ?
 * see the error reporting at Query Monitor [https://i.imgur.com/WXTV4Ge.jpg](https://i.imgur.com/WXTV4Ge.jpg)
 * [[
 * Thanks in advanced :)`
    -  This topic was modified 4 years, 7 months ago by [vitoralmeida](https://wordpress.org/support/users/vitoralmeida/).

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

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/php-notice-with-wp_http_block_external-enable/#post-14974946)
 * that should be fixed in the beta, feel free to download it from [https://github.com/futtta/autoptimize/archive/refs/heads/beta.zip](https://github.com/futtta/autoptimize/archive/refs/heads/beta.zip)
   and install that instead of 2.9.2 to test/ confirm 🙂
 * frank
 *  Thread Starter [vitoralmeida](https://wordpress.org/support/users/vitoralmeida/)
 * (@vitoralmeida)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/php-notice-with-wp_http_block_external-enable/#post-14975006)
 * Hey Frank!
 * Thanks for your very fast response and solution.
    I tested locally and everything
   going nice now, but i can’t use this code because our project is based on composer
   dependencies (including wp plugins, throuthg [https://packagist.org/](https://packagist.org/)
   and [https://wpackagist.org/](https://wpackagist.org/)), considering that i will
   wait for oficial release.
 * Before open this topic, i did this code, and contrasting to yours i set the status
   to down, because this domains are blocked too. What you think about this difference?
 *     ```
       add_filter('pre_option_autoptimize_service_availablity', function() {
               return [
                   'extra_imgopt' => [
                       'status'           => 'down',
                       'hosts'            => [
                           1 => 'https://cdn.shortpixel.ai/'
                       ],
                       'launch-threshold' => '4096'
                   ],
                   'critcss'      => [
                       'status' => 'down',
                       'hosts'  => [
                           1 => 'https://criticalcss.com/'
                       ]
                   ]
               ];
       });
       ```
   
    -  This reply was modified 4 years, 7 months ago by [vitoralmeida](https://wordpress.org/support/users/vitoralmeida/).
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/php-notice-with-wp_http_block_external-enable/#post-14975582)
 * Although that likely works great for your use case, I can’t assume that others
   that might nave issues getting the service status are not using criticalcss/ 
   image optimization 🙂
 * frank

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

The topic ‘PHP Notice with WP_HTTP_BLOCK_EXTERNAL enable’ is closed to new replies.

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

 * 3 replies
 * 2 participants
 * Last reply from: [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * Last activity: [4 years, 7 months ago](https://wordpress.org/support/topic/php-notice-with-wp_http_block_external-enable/#post-14975582)
 * Status: resolved