Skip to content

Commit 568b9db

Browse files
authored
Merge branch '5.4-dev' into 5.4/ci/add-php8.5
2 parents 70fa22d + bb8d2c0 commit 568b9db

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

components/com_content/src/Model/CategoryModel.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Joomla\CMS\Language\Multilanguage;
1717
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
1818
use Joomla\CMS\MVC\Model\ListModel;
19+
use Joomla\CMS\Pagination\Pagination;
1920
use Joomla\CMS\Table\Table;
2021
use Joomla\Component\Content\Site\Helper\QueryHelper;
2122
use Joomla\Utilities\ArrayHelper;
@@ -233,6 +234,17 @@ public function getItems()
233234
$limit = $this->getState('list.limit');
234235

235236
if ($this->_articles === null && $category = $this->getCategory()) {
237+
/**
238+
* Special case for blog layout with limit 0 - don't load articles for performance reasons. We also need to
239+
* create an empty pagination object to avoid fatal errors in the view.
240+
*/
241+
if ($limit == 0 && $this->getState('view.layout') === 'blog') {
242+
$this->_articles = [];
243+
$this->_pagination = new Pagination(0, 0, 0);
244+
245+
return $this->_articles;
246+
}
247+
236248
$model = $this->bootComponent('com_content')->getMVCFactory()
237249
->createModel('Articles', 'Site', ['ignore_request' => true]);
238250
$model->setState('params', Factory::getApplication()->getParams());

components/com_content/src/View/Category/HtmlView.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ class HtmlView extends CategoryView
7272
*/
7373
public function display($tpl = null)
7474
{
75+
/**
76+
* Pass the current layout to the model so it can apply special handling for the
77+
* blog layout. In the blog layout, if the total number of articles (leading +
78+
* intro + links) is 0, we skip loading any articles to avoid the performance
79+
* cost of loading all records when the limit is 0.
80+
*/
81+
$this->getModel()->setState('view.layout', $this->getLayout());
82+
7583
$this->commonCategoryDisplay();
7684

7785
// Flag indicates to not add limitstart=0 to URL

0 commit comments

Comments
 (0)