*

onessa

  • *
  • 2 posts
PHP 7.2 Warning for /minify/functions.php lines 213 and 220
« on: January 19, 2019, 07:02:23 PM »
Thanks for the amazing plugin. It works pretty great. Just noticed an error looks like due to PHP 7.2 differences.

Environment
Osclass 3.8.0
PHP 7.2

Noticed these errors in the error log
Code: [Select]
[19-Jan-2019 11:18:51 America/New_York] PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /oc-content/plugins/minify/functions.php on line 213
[19-Jan-2019 11:18:51 America/New_York] PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /oc-content/plugins/minify/functions.php on line 220

Line 213 is
Code: [Select]
      if(count($r['dependencies']) == 1) {
Line 220 is
Code: [Select]
      if(count($r['dependencies']) > 1) {
Relevant code block

Line 211-222
Code: [Select]
    // one dependency
    foreach($registered as $r) {
      if(count($r['dependencies']) == 1) {
        $resolved[$r['key']] = $r['url'];
      }
    }

    // more dependencies
    foreach($registered as $r) {
      if(count($r['dependencies']) > 1) {
        $resolved[$r['key']] = $r['url'];
      }

Looks like this is related to this the count() function see link below.
https://secure.php.net/manual/en/migration72.incompatible.php
https://php.net/manual/en/function.count.php

Figured i'd shared so this can be updated in future to ensure maximum compatibility for those using PHP 7.2.x

*

MB Themes

Re: PHP 7.2 Warning for /minify/functions.php lines 213 and 220
« Reply #1 on: January 19, 2019, 08:51:52 PM »
@onessa
Thanks for feedback, you can put @ sign before count to disable notices for this function.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots