original_string: public static function delete_stale_subscriptions($userid = 0) {
          global $DB;
          // Get the expiry duration, in days.
          $cutofftime = strtotime("-" . self::INACTIVE_SUBSCRIPTION_LIFESPAN_IN_DAYS . " days", time());
  
          if (!empty($userid)) {
              // Remove any stale subscriptions for the desired user only.
              $success = $DB->delete_records_select('tool_monitor_subscriptions',
                                                    'userid = ? AND inactivedate < ? AND inactivedate <> 0',
                                                    array($userid, $cutofftime));
  
          } else {
              // Remove all stale subscriptions.
              $success = $DB->delete_records_select('tool_monitor_subscriptions',
                                                    'inactivedate < ? AND inactivedate <> 0',
                                                    array($cutofftime));
          }
          return $success;
      }
code: public static function delete_stale_subscriptions($userid = 0) {
          global $DB;
          // Get the expiry duration, in days.
          $cutofftime = strtotime("-" . self::INACTIVE_SUBSCRIPTION_LIFESPAN_IN_DAYS . " days", time());
  
          if (!empty($userid)) {
              // Remove any stale subscriptions for the desired user only.
              $success = $DB->delete_records_select('tool_monitor_subscriptions',
                                                    'userid = ? AND inactivedate < ? AND inactivedate <> 0',
                                                    array($userid, $cutofftime));
  
          } else {
              // Remove all stale subscriptions.
              $success = $DB->delete_records_select('tool_monitor_subscriptions',
                                                    'inactivedate < ? AND inactivedate <> 0',
                                                    array($cutofftime));
          }
          return $success;
      }
code_tokens: public static function delete_stale_subscriptions ( $ userid = 0 ) { global $ DB ; // Get the expiry duration, in days. $ cutofftime = strtotime ( "-" . self :: INACTIVE_SUBSCRIPTION_LIFESPAN_IN_DAYS . " days" , time ( ) ) ; if ( ! empty ( $ userid ) ) { // Remove any stale subscriptions for the desired user only. $ success = $ DB -> delete_records_select ( 'tool_monitor_subscriptions' , 'userid = ? AND inactivedate < ? AND inactivedate <> 0' , array ( $ userid , $ cutofftime ) ) ; } else { // Remove all stale subscriptions. $ success = $ DB -> delete_records_select ( 'tool_monitor_subscriptions' , 'inactivedate < ? AND inactivedate <> 0' , array ( $ cutofftime ) ) ; } return $ success ; }
docstring: Deletes subscriptions which have been inactive for a period of time.
  
  @since 3.2.0
  @param int $userid if provided, only this user's stale subscriptions will be deleted.
  @return bool true if the operation was successful, false otherwise.
docstring_tokens: Deletes subscriptions which have been inactive for a period of time .