Problem Fabrik: scheduled tasks

Hi,
I'm having a problem with Fabrik 4 Zeta and Joomla 4.4.0 so if I try to call the scheduler with a link with a secret or id query it doesn't work, even though it also notifies me of the call by email. The scheduler works perfectly if run through the run button in the backend.
Frequency schedule is 1 minute
 
Last edited:
To explain better, the scheduler starts correctly only if I select it and press the Run button, differently with the link, both with secret query and with scheduler id the php code is not executed even if the log email arrives correctly. before including it among the Fabrik 4 bugs I was trying to understand if I was doing something wrong.
In the log Fabrik: 16384,Since joomla/event 2.0.0: Not passing an event object to Joomla\Event\Dispatcher::dispatch() is deprecated, as of 3.0 the $event argument will be required.,/web/htdocs/www.xxxxxx.it/home/CCM/libraries/vendor/symfony/deprecation-contracts/function.php,25
 
Last edited:
Which cron plugin are you running?
Did you enable the System - Fabrik Scheduled Tasks plugin?
 
Last edited:
  • Yes, the System - Fabrik Scheduled Tasks plugin is enabled
  • I tested both concronjob.org and with the new joomla schedulers, I also tested by going to the fabrik cron link both enabling and disabling query secret and also with the curl command. Nothing. it works exclusively by selecting cron and starting the run button. The curl result is OK, it sends the notification email but nothing happens. But the error I indicated appears in the Fabrik log
 
The log is only a deprecated message (i.e. warning for upcoming versions).

Which cron plugin are you running? What should happen?

It's working as expected on my J!4.4.0/F4-Zeta/php8.2 site, tested with the email plugin.

You can test without any server cronjob, it needs only some frontend activity, so just reload your frontend site.
If you have "Require query string" enabled append fabrik_cron=1 resp. fabrik_cron=your-secret-string to the URL.
 
Right now I have php 8.1.23, but I can upgrade it. the plugin is php. It is correct to use this line for database connection $db = Joomla\CMS\Factory::getContainer()->get('DatabaseDriver'); ? I think so otherwise it wouldn't have worked for me with the Run button
 
I updated to php 8.2. I cleaned the php code from comments. I'm trying to check the php code for any other anomalies, but as mentioned before by clicking on the run button everything works correctly, while if I start via link, nothing happens except for sending the email
 
Maybe I discovered something. The php code contains a require_once JPATH_SITE. '/Gcalendar/icalendar.php'; which was at the beginning of the script. I moved it to see if it had done what I said before and it worked. Therefore he is unable to make this call. But why does it work correctly when I run it with the run button?
 
With the Run button you are running as (super)admin from inside Joomla.

With a link (or frontend activity) you are running as guest.

So a different behaviour may be related to access rights or to something like Admintools or general .htaccess preventing calling php files from "outside".
 
Thanks Troester,
At the moment I haven't found the definitive solution yet, even if your instructions were useful. I still have to figure out where to correctly allocate the php file, containing the function to be called. I tried to put it in a folder with .htaccess with full access, but at the same time I still encounter the same problem.
 
Do you have your php code in the code field or do you call a script file (located in plugins\fabrik_cron\php\scripts)?
 
I inserted the script in the indicated folder and called it using "require_once JPATH_SITE . '/plugins/fabrik_cron/php/scripts/icalendar.php';" but unfortunately everything is as before if I run the code as administrator everything is ok, instead calling it with the querystring doesn't recall it
 
I also created entire script in the script folder and continues to execute correctly only if executed via run button and not query string. It still executes what was done before the require command (so it truncates the table but does not repopulate it).

I'll post the code if it can be useful for a suggestion. Thank you:

defined('_JEXEC') or die();

use Joomla\CMS\Factory;


$db = Joomla\CMS\Factory::getContainer()->get('DatabaseDriver');
$strsql1 = "TRUNCATE TABLE a_events_ccm";

$db->setQuery($strsql1);
$db->execute();

require_once JPATH_ROOT . '/plugins/fabrik_cron/php/scripts/icalendar.php';

error_reporting(E_ALL);
ini_set('display_errors', 1);


if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$filename = JPATH_ROOT . '/Gcalendar/basic.ics';

if (file_exists($filename)) {
$ical = new iCalendar();
$ical->parse($filename);
$ical_data = $ical->get_all_data();

$timezone = "{$ical_data['VCALENDAR']['X-WR-TIMEZONE']}";
if (function_exists('date_default_timezone_set')) {
date_default_timezone_set($timezone);
}


$db = Joomla\CMS\Factory::getContainer()->get('DatabaseDriver');

$strsql1 = "INSERT INTO a_events_ccm (StartDate, StartTime, EndDate, EndTime, Title, Location, Description) VALUES ";

if (!empty($ical_data['VEVENT'])) {
foreach ($ical_data['VEVENT'] as $key => $data) {

$start_dttimearr = explode('T', $data['DTSTART']);
$StartDate = $start_dttimearr[0];
$StartTime = $start_dttimearr[1];


$end_dttimearr = explode('T', $data['DTEND']);
$EndDate = $end_dttimearr[0];
$EndTime = $end_dttimearr[1];

$strsql1 .= "('" . $StartDate . "','" . $StartTime . "','" . $EndDate . "','" . $EndTime . "','" . $db->escape($data['SUMMARY']) . "','" . $db->escape($data['LOCATION']) . "','" . $db->escape($data['DESCRIPTION']) . "')";
$strsql1 .= ",";
}
$strsql1 = rtrim($strsql1, ',');

$db->setQuery($strsql1);
$db->execute();
}


header('Location: index.php');
exit;
} else {

}
}


if ($_GET['stage'] == "empty") {

$db = Joomla\CMS\Factory::getContainer()->get('DatabaseDriver');

$strsql1 = "TRUNCATE TABLE a_events_ccm";

$db->setQuery($strsql1);
$db->execute();

header('Location: index.php');
exit;
}
 
Here are the error logs that are reported on the fabrik log

16384,Joomla\CMS\Factory::getDbo() is deprecated. Load the database from the dependency injection container.,/web/htdocs/www.domain.it/home/CCM/libraries/src/Factory.php,453

16384,Since joomla/event 2.0.0: Not passing an event object to Joomla\Event\Dispatcher::dispatch() is deprecated, as of 3.0 the $event argument will be required.,/web/htdocs/www.domain.it/home/CCM/libraries/vendor/symfony/deprecation-contracts/function.php,25
I have the same issue as @bonghetti .
 
These are only deprecated messages which shouldn't hurt.
What exactly is not working?
Cron is working fine.
However the Fabrik Log is full of these messages. Only way to stop flooding the Fabrik Log is to unpublish the cron scheduled tasks.
 
Last edited:
I just changed a bunch of Factory::getDbo to getContainer. Have to test a bit to make sure there's no typo.
 
Back
Top