FixSometime Some deprecated messages on J!5.1.1

EricWebsite

Member
Hi,

I came across some messages:

1) in the backend
on all lists
- Deprecated: Creation of dynamic property Joomla\CMS\Form\Form::$model is deprecated in ..../administrator/components/com_fabrik/models/list.php on line 127
on list plugins tab: same, on line 158
after adding a plugin: same on line 45, 288, 353

2) in the frontend
similar warnings
calc element
: if I put the following in:
Code:
use Joomla\CMS\Factory;
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
I get an error in a red box :
"An error has occurred with a eval'd field - please inform the web-site owner. Debug: Eval exception : location_calc (id 178): reFormatFormJoins() : use Joomla\CMS\Factory;$db = Factory::getContainer()->get('DatabaseDriver');$query = $db->getQuery(true); : Since joomla/database 2.2.0: The parameter $new is deprecated and will be removed in 4.0, use Joomla\Database\DatabaseDriver::createQuery() instead."
But the page is still loaded.

If I try the suggested code:
Code:
$query = Joomla\Database\DatabaseDriver::createQuery();
I get a real error:
"Non-static method Joomla\Database\DatabaseDriver::createQuery() cannot be called statically"

System details:
Fabrik 4.1 git date 06-04
PHP 8.2.20
Joomla 5.1.1
Debug enabled
 
Deprecated is only notices.

I assume it should be (didn't test)
$query = $db->createQuery();
 
$query = $db->createQuery(); works.
But strangely enough, the error message is the same:
"An error has occurred with a eval'd field - please inform the web-site owner. Debug: Eval exception : location_calc (id 178) ::reFormatFormJoins() : use Joomla\CMS\Factory;$db = Factory::getContainer()->get('DatabaseDriver');$query = $db->createQuery();$user = '2096';$query = "select first_name from researcher where joomla_id = '" . $user . "'";$db->setQuery($query);$naam = $db-> loadResult();return $naam; : Since joomla/database 2.2.0: The parameter $new is deprecated and will be removed in 4.0, use Joomla\Database\DatabaseDriver::createQuery() instead."
 
I suspect this notice is coming from somewhere else, but being reported as part of the eval. Fabrik uses getQuery everywhere. What is the complete code in your calc, I am curious what you are returning from it.
 
Eric, can you update your site (take a backup first of course) from the repo using the createquery branch and see if the issue is resolved. This branch replaces all getQuery calls with createQuery.

Let us know what you find.
 
Hi Alex,
I suspect this notice is coming from somewhere else, but being reported as part of the eval. Fabrik uses getQuery everywhere. What is the complete code in your calc, I am curious what you are returning from it.
what I was trying to do is to create a workaround for this issue: https://fabrikar.com/forums/index.p...t-displays-json-string-in-details-view.54571/
So I intended to pick up the values from the databasejoin myself and display them always as a list, also in details forms view. But as I saw the uggly red errors, with a simple test query, I stopped:
Code:
use Joomla\CMS\Factory;
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->createQuery();
$user = '2096';
$query = "select first_name from researcher where joomla_id = '" . $user . "'";
$db->setQuery($query);
$naam = $db-> loadResult();
return $naam;

I will test your createquery branch and revert soonest.
 
Unfortunately, with the createquery branch the error did not go away.
For each line in the list (3 lines in the test) the error is still the same. The query works and the 3 first names are shown.
The query was:

Code:
use Joomla\CMS\Factory;
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->createQuery();
$user = '{researcher___joomla_id}';
$query = "select first_name from researcher where joomla_id = '" . $user . "'";
$db->setQuery($query);
$naam = $db-> loadResult();
return $naam;
 

Attachments

  • calc_with_query.jpg
    calc_with_query.jpg
    193.2 KB · Views: 134
The WIKI is still J!3/F3 resp. partly J!4/F4, not updated for J!5 (please feel free to add).

The "error" is only a deprecated notice, so "old" code is still working.
Is it really related to your calc element (i.e. gone if you disable the element)?
 
There are several "deprecated" J! sites, e.g.
and hints for developpers etc (@henk had some for setting up a totally new 'clean' Fabrik5)
but I think it's not easy to find all place.
 
The issue causing the deprecation notice is that the current implementation of createQuery simply calls getQuery and it is the getQuery isNew parameter that is deprecated and the deprecation notice is firing. Presumably in some version of J!5 this will get removed and the deprecation notice will go away.

For now, if you can, you should start using createQuery so you won't have to replace your getQuerie(s) somewhere down the road. Also set error reporting to simple so you do not get the deprecation notice. Only elevate it when you are troubleshooting an issue.

I am going to merge the createQuery branch into master so we don't need to deal with this later.
 
It turned out that $db->createQuery(); is not supported in J!4 and is still throwing deprecated messages in J!5 because of J!5 itself, so we'll keep db->getQuery(true) in F4 for now.

In custom code on J!5 you may use $db->createQuery(); so you won't have to change it later.
 
Back
Top