I believe this is in all versions, clicking the "page break" button in the editor
$isNew = ($this->item->id == 0);
$checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $userId);
Warning
: Attempt to read property "id" on null in
/var/www/u2666/data/www/site.ru/administrator/components/com_content/src/View/Article/HtmlView.php
on line
139
Warning
: Attempt to read property "checked_out" on null in
/var/www/u2666/data/www/site.ru/administrator/components/com_content/src/View/Article/HtmlView.php
on line
140
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*
* @throws \Exception
*/
protected function addToolbar()
{
if ($this->getLayout() === 'modal') {
$this->addModalToolbar();
return;
}
// FIX: Если это лейаут разрыва страницы, тулбар статьи нам не нужен вообще
if ($this->getLayout() === 'pagebreak') {
return;
}
$user = $this->getCurrentUser();
$userId = $user->id;
// FIX: Проверка на существование item перед обращением к свойствам
$isNew = (!empty($this->item) && $this->item->id == 0);
// FIX: Безопасная проверка checked_out
$checkedOut = false;
if (!empty($this->item)) {
$checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $userId);
}
// Дополнительная защита: если item все еще null, используем дефолтное значение заголовка
$stateKey = $checkedOut ? 'VIEW_ARTICLE' : ($isNew ? 'ADD_ARTICLE' : 'EDIT_ARTICLE');
$this->toolbarTitle = Text::_('COM_CONTENT_PAGE_' . $stateKey);
parent::addToolbar();
}
/**
* Add the modal toolbar.
*
* @return void
*
* @since 5.0.0
*
* @throws \Exception
*/
protected function addModalToolbar()
{
// FIX: Исключаем лишнюю логику для pagebreak, если вдруг попали сюда
if ($this->getLayout() === 'pagebreak') {
return;
}
$user = $this->getCurrentUser();
$userId = $user->id;
// FIX: Безопасное получение isNew
$isNew = (!empty($this->item) && $this->item->id == 0);
// FIX: Безопасное получение checkedOut
$checkedOut = false;
if (!empty($this->item)) {
$checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $userId);
}
$toolbar = $this->getDocument()->getToolbar();
$canDo = null;
// Проверяем canDo только если item существует, иначе берем общие права компонента
if (!empty($this->item)) {
$canDo = $this->canDo ?? ContentHelper::getActions('com_content', 'article', $this->item->id);
} else {
$canDo = ContentHelper::getActions('com_content');
}
ToolbarHelper::title(
Text::_('COM_CONTENT_PAGE_' . ($checkedOut ? 'VIEW_ARTICLE' : ($isNew ? 'ADD_ARTICLE' : 'EDIT_ARTICLE'))),
'pencil-alt article-add'
);
$canCreate = $isNew && (\count($user->getAuthorisedCategories('com_content', 'core.create')) > 0);
$canEdit = false;
if (!empty($this->item)) {
$canEdit = $canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by == $userId);
}
if ($canCreate || $canEdit) {
$toolbar->apply('article.apply');
$toolbar->save('article.save');
}
$toolbar->cancel('article.cancel');
}
| Labels |
Added:
No Code Attached Yet
|
||
Please test #46908 and report your test result with https://issues.joomla.org/tracker/joomla-cms/46908
It works too
Please close this duplicate
| Status | New | ⇒ | Closed |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2026-02-19 15:24:37 |
| Closed_By | ⇒ | drmenzelit |
Please test #46908 and report your test result with https://issues.joomla.org/tracker/joomla-cms/46908