@@ -104,7 +104,11 @@ public function display($tpl = null)
104104 $ this ->form = $ model ->getForm ();
105105 $ this ->item = $ model ->getItem ();
106106 $ this ->state = $ model ->getState ();
107- $ this ->canDo = ContentHelper::getActions ('com_content ' , 'article ' , $ this ->item ->id );
107+ $ this ->canDo = ContentHelper::getActions (
108+ 'com_content ' ,
109+ 'article ' ,
110+ $ this ->item ? (int ) $ this ->item ->id : 0
111+ );
108112
109113 if ($ this ->getLayout () === 'modalreturn ' ) {
110114 parent ::display ($ tpl );
@@ -157,8 +161,10 @@ protected function addToolbar()
157161 Factory::getApplication ()->getInput ()->set ('hidemainmenu ' , true );
158162 $ user = $ this ->getCurrentUser ();
159163 $ userId = $ user ->id ;
160- $ isNew = ($ this ->item ->id == 0 );
161- $ checkedOut = !(\is_null ($ this ->item ->checked_out ) || $ this ->item ->checked_out == $ userId );
164+ $ isNew = empty ($ this ->item ) || empty ($ this ->item ->id );
165+ $ checkedOut = !empty ($ this ->item )
166+ && !\is_null ($ this ->item ->checked_out )
167+ && $ this ->item ->checked_out != $ userId ;
162168 $ toolbar = $ this ->getDocument ()->getToolbar ();
163169
164170 // Built the actions for new and existing records.
@@ -267,8 +273,10 @@ protected function addModalToolbar()
267273 {
268274 $ user = $ this ->getCurrentUser ();
269275 $ userId = $ user ->id ;
270- $ isNew = ($ this ->item ->id == 0 );
271- $ checkedOut = !(\is_null ($ this ->item ->checked_out ) || $ this ->item ->checked_out == $ userId );
276+ $ isNew = empty ($ this ->item ) || empty ($ this ->item ->id );
277+ $ checkedOut = !empty ($ this ->item )
278+ && !\is_null ($ this ->item ->checked_out )
279+ && $ this ->item ->checked_out != $ userId ;
272280 $ toolbar = $ this ->getDocument ()->getToolbar ();
273281
274282 // Build the actions for new and existing records.
0 commit comments