• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Form Email Plugin doesn't send mails in PHP8

fstorch

Member
Did another Update including dompdf 2.0 to prepare for PHP8.
This time using a modified master.zip (downloaded today) on the production server but in a test-site.
PDF still worked fine with PHP 8.
But while testing the other forms, I had to find that the Form E-Mail Plugin no longer sends e-mail.
Tried with phpmail and smtp.
Tried with PHP 8.0 and 8.1.
No error returned when the plugin is run (with joomla and fabrik debug).
No error in logfile.
Joomla Test-Mail works fine.

Switched back to 7.4 and mail was sent right away.
Tried older test site on another server with PHP8 which was updated a few weeks ago with wget and composer. Mail wasn't working as well.

Any suggestions how to debug?
Regards ... Franz
 
Looking at
.../plugins/fabrik_form/email/email.php
where would I be able to see those messages:
JDEBUG ? $profiler->mark("email: sendMail start: " . $email) : null;

Not sure if that plugin is called at all, because I don't see any echo's that I inserted.
 
Do you have more than one form plugin? Is it possible one of them is returning a false status which is stopping the form submission and hence not getting to the email plugin?
 
I see this problem and There is a bug in the code that when sending email checks if acymailing is installed It is in:
/../libraries/fabrik/fabrik/Helpers

about line 2400
comment this line

/*if (get_parent_class($ret) === 'Exception')
{
self::log('fabrik.helper.sendmail.error', 'Exception in Send: ' . $ret->getMessage(), false);

$ret = false;
}*/

Regards
 
It is in:
/../libraries/fabrik/fabrik/Helpers
It is in Worker.php at 2400 and the condition is currently;
if (is_bool($ret) === false && get_parent_class($ret) === 'Exception')
Commented out the block, but unfortunately that didn’t help. That would have happened after $mailer->Send anyway.
 
Seems not to be a general problem.
Installed wampserver with Joomla 3.10.11 and Fabrik with the same dompdf modifications.
Created a new site to just test the email form plugin and the mail is sent.
Installed the production site and no mail is sent.
With joomla and fabrik debug active as well as system-debug active there are no errors (despite tons of deprecate messages) in
...\administrator\logs\fabrik.log.php
...\administrator\logs\everything.php
c:\wamp64\logs\php_error.log

No messages like:
JDEBUG ? $profiler->mark("email: start: onAfterProcess") : null;
which should be written by ...\plugins\fabrik_form\email\email.php
Running out ideas.
 
A difference can be seen in Joomla Debug Runtime Profile
Three plugins added: Logs, Email, comment
Good case: 3 found, 3 run:
Application: runPlugins: method_exists: PlgFabrik_FormLogs, usesSession
Application: runPlugins: preflight OK, starting: PlgFabrik_FormLogs, usesSession
Application: runPlugins: method_exists: PlgFabrik_FormEmail, usesSession
Application: runPlugins: preflight OK, starting: PlgFabrik_FormEmail, usesSession

Application: runPlugins: method_exists: PlgFabrik_FormComment, usesSession
Application: runPlugins: preflight OK, starting: PlgFabrik_FormComment, usesSession
Application: runPlugins: end: usesSession

Bad case: 3 found just 2 ran
Application: runPlugins: method_exists: PlgFabrik_FormComment, usesSession
Application: runPlugins: preflight OK, starting: PlgFabrik_FormComment, usesSession
Application: runPlugins: method_exists: PlgFabrik_FormEmail, usesSession
Application: runPlugins: method_exists: PlgFabrik_FormLogs, usesSession
Application: runPlugins: preflight OK, starting: PlgFabrik_FormLogs, usesSession
Application: runPlugins: end: usesSession

so why might preflight for PlgFabrik_FormEmail not be OK?
 
I think I found the culprit, although cannot really explain it.
Problem occurs in ...\components\com_fabrik\models\plugin.php at around line 692 in function canUse.
upload_2022-9-30_12-30-29.png
The email plugin is set to run online in Front and New.
Problem does not occur when it should run in Front and Both.
It looks like ($model->$k) != 0 is returning null in PHP 7:
Application: plugin.php: canUse2a: rowId,
and 1 in PHP 8:
Application: plugin.php: canUse2a: rowId, 1
which leads to canUse to return 0 and such not executing it.
Does not happen for the other plugins which are set to BOTH.
PHP8
upload_2022-9-30_12-41-25.png

PHP7
upload_2022-9-30_12-43-37.png

Not sure if rowid should be returning something in a New Event?
 

Attachments

  • upload_2022-9-30_12-40-43.png
    upload_2022-9-30_12-40-43.png
    48.5 KB · Views: 27
Since ($model->$k) is an empty string, the problem is caused by an incompatibility change in PHP8:
Backward Incompatible Changes
Non-strict comparisons between numbers and non-numeric strings now work by casting the number to string and comparing the strings. Comparisons between numbers and numeric strings continue to work as before. Notably, this means that 0 == "not-a-number" is considered false now.


Comparison
Before(7) After(8)
...
0 == "" true false
I guess, that's one of reasons, why a migration to PHP8 is such a tedious job.
 
For now I only changed that one instance which made the plug-in do its job again. But I could imagine that similar occurrences might be found all around Fabrik. Not just in that file.
They are pretty hard to identify though, since they don’t result in errors, but in incorrect output.
 
Note: Instead of using strlen I used empty as the value of the property could be numeric, null, or a boolean. Strlen will fail on boolean or null, and at some point php will probably fail it on a numeric value if not cast to a string. Empty covers all of these conditions.
 
Hi I can confirm the issue with In Both On Both with the php form plugin on J!3.10.11 and php8.1. My code only gets executed onAfterProcess when the plugin is set to Both / Both.
Is the fix the same for this plugin?
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top