Create some sample articles
Create a new instance of mod_articles_category
Set filter for date to relative
Get all articles x days in the past till now
$items returns false and this leads into the follwing error in the frontend:
Warning: Invalid argument supplied for foreach() in /Users/marcorensch/Sites/joomla4b5/components/com_content/src/Model/ArticlesModel.php on line 713
Warning: Invalid argument supplied for foreach() in /Users/marcorensch/Sites/joomla4b5/modules/mod_articles_category/src/Helper/ArticlesCategoryHelper.php on line 257
Joomla 4 Beta 6
MAMP local
PHP 7.4.12
MySQL 5.7.32
I've found this issue while checking the code for a module (because mine worked either) and even if all looks good (and similar to J3 its not working in J4 when doing this in the model:
case 'relative':
$relativeDate = (int) $this->getState('filter.relative_date', 0);
$query->where(
$db->quoteName($dateField) . ' IS NOT NULL AND '
. $db->quoteName($dateField) . ' >= ' . $query->dateAdd($nowDate, -1 * $relativeDate, 'DAY')
);
break;
ArticlesModel.php line 571 and below.
the $nowDate has to be 'quoted' in J4:
It should look like:
case 'relative':
$relativeDate = (int) $this->getState('filter.relative_date', 0);
$query->where(
$db->quoteName($dateField) . ' IS NOT NULL AND '
. $db->quoteName($dateField) . ' >= ' . $query->dateAdd($db->quote($nowDate), -1 * $relativeDate, 'DAY')
);
break;
When i change it its working on my installation.
Did someone else expecting the same error?
Labels |
Added:
?
|
Title |
|
Labels |
Added:
?
?
|
@marcorensch could you create a PR please?
@bembelimen : Sorry i have no clue what to do to create a PR - is there any guide somewhere?
@gostn @bembelimen : Sorry i don't get it - this Tutorial is just to old - I've tried now several times via PHP Storm to setup the environment... I am able to handle my extension updates on github but find no way how to create workspace for Joomla and contribute.
Edit:
I'm not sure but i think i've done something wrong it. took all other commits into my pr too....
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-01-17 08:37:02 |
Closed_By | ⇒ | alikon | |
Labels |
Added:
?
?
Removed: ? ? |
confirmed