Make a quick vote 🗳 ️How do you refer to SuiteCRM extensions: add-ons or plug-ins? Click here to have your say 👈

Patches needed for cron script

Hi, I had to make a couple of changes to the PHP code to get the cron script to work. My environment:

  • OS: Fedora 35
  • SuiteCRM 8.1.2
  • PHP 8.0.21 (from remi repo, so IMAP support is built in)
  • Database: MariaDB 10.5.16
  • Web server: Apache HTTP Server 2.4.54 with php-fpm 8.0.22

(Note: After I resolve a few questions, I’ll post detailed instructions on how to get SuiteCRM working in the above environment.)

I was able to get my install working, but I had to tweak a couple of PHP files before the cron script (public/legacy/cron.php) would run successfully:

--- AOPInboundEmail.php.orig	2022-07-17 13:25:25.043090455 -0500
+++ AOPInboundEmail.php	2022-07-17 13:25:47.175737818 -0500
@@ -56,7 +56,7 @@
     }
 
 
-    public function handleCreateCase(Email $email, $userId)
+    public function handleCreateCase(/*Email */ $email, $userId)
     {
         global $current_user, $mod_strings, $current_language;
         $mod_strings = return_module_language($current_language, "Emails");

--- InboundEmail.php.orig	2022-07-17 13:20:27.576949658 -0500
+++ InboundEmail.php	2022-07-17 13:21:24.355175739 -0500
@@ -6173,7 +6173,9 @@
             $ret = $this->getImap()->search('UNDELETED UNSEEN');
         }
 
+	if (is_countable($ret)) {
         LoggerManager::getLogger()->debug('-----> getNewMessageIds() got ' . count($ret) . ' new Messages');
+	}
 
         return $ret;
     }

The first change silenced this PHP complaint:

PHP Fatal error:  Declaration of AOPInboundEmail::handleCreateCase(Email $email, $userId) must be compatible with InboundEmail::handleCreateCase($email, $userId)

and the second silenced:

PHP Fatal error:  Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, bool given

My question is, does this indicate any problem in my environment that should be corrected, or are these perhaps beneficial changes?

I’d seen the first problem, it’s a known issue that was aggravated in PHP 8 because it used to be a warning, now it’s FATAL. I would fix it the other way around, though, adding the Email type in the parent InboundEmail class.

The second one is also something to be fixed in PHP 8. Instead of adding the if I would suggest:

         LoggerManager::getLogger()->debug('-----> getNewMessageIds() got ' . (is_countable($ret) ? count($ret) : 'an error when searching ') . ' new Messages');

Can you open issues and PR’s for this on Github? First, please check if they are already there.

Done:

1 Like