Website Comments 1.05 Error - Trying to access array offset on value of type bool

6 posts by 4 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: July 13   (RSS)

By craig_bcd - June 17

Hi -

I started getting this error with website comments 1.05 just out of the clear blue sky (I am sure something happened I just don't know what) 

On the website it shows up like this:

Notice: Trying to access array offset on value of type bool in /home/customer/www/delanceyplace.com/public_html/cmsAdmin/plugins/websiteComments/websiteComments.php on line 279

In the error log it shows up like this: 

 E_NOTICE: Trying to access array offset on value of type bool
/home/customer/www/delanceyplace.com/public_html/cmsAdmin/plugins/websiteComments/websiteComments.php (line 279)
https://delanceyplace.com/view-search-results.php?2509

It looks like the error is in the plugin itself.

We are running:

  • CMS Builder v3.53 (Build 2265)
  • Website comments 1.05
  • PHP v7.4.18

Can you guys help?

Thanks!

Craig

By craig_bcd - June 17

Steve!

You are genius!  I changed the PHP version to 7.3 and the error magically disappeared!  I'll look to upgrade to 3.54.

Thanks!

Craig

By daniel - June 22

Hi Craig,

Steve was generally correct - this is an error that started showing up in PHP 7.4. Newer versions of CMSB have improved compatibility, but this doesn't necessarily extend to plugins. We will work on getting the official plugins updated, but in the meantime, here's a patch for this particular error in Website Comments 1.5:

If you locate this block of code in websiteComments.php (around line 275)

function wsc_thread_isSubscribed($tableOrTag, $recordNum) {
  global $CURRENT_USER;

  $isSubscribed = mysql_count('_wsc_subscribers', array(
    'userNum'    => $CURRENT_USER['num'],
    'tableOrTag' => $tableOrTag,
    'recordNum'  => $recordNum,
  ));

  return (bool) $isSubscribed;
}

And replace it with this:

function wsc_thread_isSubscribed($tableOrTag, $recordNum) {
  global $CURRENT_USER;

  if (!empty( $CURRENT_USER )) {
    $isSubscribed = mysql_count('_wsc_subscribers', array(
      'userNum'    => $CURRENT_USER['num'],
      'tableOrTag' => $tableOrTag,
      'recordNum'  => $recordNum,
    ));
  }
  
  return (bool) $isSubscribed;
}

That should allow you to run the plugin in PHP 7.4.

Let me know if you have any other issues!
Thanks,

Daniel
Technical Lead
interactivetools.com

By degreesnorth - July 8

Hi

I am getting this error as well, after upgrading my client's CMS/PHP.  It appears at the top of the cmsb login screen.  

CMS Builder v3.50 (Build 2215)
PHP v7.4.12

Is there any way of fixing this issue please?

Notice: Trying to access array offset on value of type bool in /home/gege1237/public_html/cmsb/lib/menus/header_functions.php on line 167 Notice: Trying to access array offset on value of type bool in /home/gege1237/public_html/cmsb/lib/menus/header_functions.php on line 167 Notice: Trying to access array offset on value of type bool in /home/gege1237/public_html/cmsb/lib/menus/header_functions.php on line 167

By daniel - July 13

Hi degreesnorth,

This particular issue should be resolved in newer versions of CMSB. You can find the details of the latest release here: https://www.interactivetools.com/forum/forum-posts.php?CMSB-v3.54-Released---October-29-2020-82341

If you're unable to upgrade currently, you can also fix this error with a simple patch. In /cmsb/lib/menus/header_functions.php, replace this line (line 167):

  elseif (@$menu['visibility'] == 'requireAdmin' && $CURRENT_USER['isAdmin'])                           { $userHasMenuAccess = true; } // allow access to admin for admin menus

With this:

  elseif (@$menu['visibility'] == 'requireAdmin' && !empty($CURRENT_USER['isAdmin']))                   { $userHasMenuAccess = true; } // allow access to admin for admin menus

Note that there may be other PHP 7.4 compatibility issues in CMSB 3.50, so I would still recommend upgrading if possible.

Let me know if you have any other questions!

Thanks,

Daniel
Technical Lead
interactivetools.com