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

3 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: February 2   (RSS)

By glennp - February 1

In response to: https://www.interactivetools.com/forum/forum-posts.php?postNum=2245569#post2245569

Hello,

I resolved the error described in the above thread by following the instructions below however I have a new error.

New error: Warning: Undefined variable $isSubscribed in .../cmsb/plugins/websiteComments/websiteComments.php on line 286

CMSB 3.64, PHP 8.2.15

Thanks!

Glenn

From last thread:

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;
}

By Dave - February 2

Hi Glenn, 

Try adding this line: $isSubscribed = false; // ADD THIS LINE

function wsc_thread_isSubscribed($tableOrTag, $recordNum) {
  global $CURRENT_USER;
  $isSubscribed = false; // ADD THIS LINE

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

Let me know if that works for you.

Dave Edis - Senior Developer
interactivetools.com