Call to a member function setState() on null (also “on bool”, “on boolean”, or “on a non-object”) means Joomla tried to call setState() on a model that was never created. getModel(), JModelLegacy::getInstance(), or createModel() returned false or null, and the next line did not check. This is not a session error, and clearing the cache does not create the missing class.
The line that dies is almost always a content module or an old component controller preparing a list query. The fix is to load the model, or to update or disable the extension named in the stack trace.
What you will learn
- What
setState()does on a Joomla model, and why this is not React and not the session - Why the same bug is worded three different ways on PHP 7 and PHP 8
- How to read the file path and name the extension in one minute
- The Joomla 3 include-path failure, and the Joomla 4, 5, and 6
bootComponent()pattern - What to do when the administrator will not open
What the error actually means
Joomla list screens do not read $_GET inside the query. They park filters on the model first:
$model->setState('filter.published', 1);
$model->setState('list.limit', 5);
$model->setState('params', $params);
$items = $model->getItems();
setState() only exists on a model object (ListModel, BaseDatabaseModel, and the older JModelLegacy). If $model is false or null, PHP stops with a fatal error before getItems() runs. The message changes with the PHP version, not with the bug:
| What PHP says | What $model is |
Typical PHP |
|---|---|---|
| on a non-object | false from getInstance() or getModel() |
PHP 5 |
| on boolean | Same false |
PHP 7 |
| on bool | Same false |
PHP 8 and newer |
| on null | createModel() found nothing |
PHP 7.0+ and Joomla 4+ |
A different sentence, Call to undefined method ... setState(), means you do have an object, but it is the wrong class. Do not mix those up. This article is only the null or false case.
This is not the session, and it is not React
Session data in Joomla is $app->setUserState() and getUserState(). Deleting files in /tmp, logging out, or emptying #__session does not make getModel() return an object. Do that only when the error text actually names the session handler.
React’s setState() is a JavaScript method on a component. A PHP fatal in a .php file under modules or components has nothing to do with a React build. If the stack trace is a .js bundle, you are in a different app that happens to be hosted beside Joomla.
Where it breaks
| Path in the error | What failed | Fix |
|---|---|---|
modules/mod_articles_latest, mod_articles_category, mod_articles_news, mod_related_items |
The articles model was not booted before setState('params') |
Use the core helper pattern below, or replace a cloned module |
components/com_SOMETHING/controller.php or controllers/cpanel.php |
$this->getModel() returned false, then the controller called setState anyway |
Update that component. Pass the model name. Check the return value |
administrator/components/com_SOMETHING |
Same failure, backend only | Disable that admin component. The public site can stay up |
libraries/legacy/controller or libraries/src/MVC/Controller |
Core ran. The component in the URL did not provide a model | Read option=com_... in the URL. Fix that extension, not the library |
templates/YOUR_TEMPLATE/html |
An override copied an old helper | Compare it with the current core file and drop the stale copy |
The classic core case was Joomla 3.5.0: mod_related_items/helper.php line 44 called setState() on false because com_content models were not on the lookup path. That was fixed in 3.5.1. The report is still the best illustration of the bug: Related Articles module fatal error. Third-party modules still copy the broken pattern.
Step 1: Get the file and the line
- If the page is a blank 500, open the host PHP error log or
administrator/logs/. The fatal is one line: message, file, line number. - On a staging copy you can set Global Configuration → Server → Error Reporting to Maximum. Turn it off again on production. Do not leave
display_errorson a public site. - Copy the first fatal only. Later errors are fallout.
- A white page with no
setStatetext may be.htaccessinstead. Check that only after the log is silent. Guide: Joomla 500 on mod_rewrite.
Step 2: Confirm the variable is empty
Open the file at the line number. You want a call shaped like one of these:
$model->setState($this->getModel()->setState($defaultModel->setState(
Look up three to ten lines. The assignment is getInstance, getModel, or createModel. There is no if (!$model) before setState. That missing check is the crash. Adding a return when the model is empty stops the fatal. It does not by itself bring the module back. You still have to make createModel succeed.
Step 3: Name the extension from the path
mod_prefix: a module. Unpublish that module to confirm the homepage returns. System → Manage → Extensions, orpublished = 0on that row in#__modulesif you cannot log in.com_prefix: a component. The menu item or the URLoption=is what triggers it. Note the folder name before you disable anything.plg_orplugins/: a plugin. Rename that plugin’s folder over FTP if the administrator is already dead.- Path contains
libraries/joomlaorlibraries/srcand your Joomla version is current: core is the messenger. The broken model belongs to the component in the request.
Take a backup before you rename folders or edit PHP. Method: how to backup a Joomla website.
Step 4: Load the articles model the way core does now
On Joomla 4, 5, and 6, article modules boot the component, then set state. This is the current core pattern in Latest Articles:
$model = $app->bootComponent('com_content')
->getMVCFactory()
->createModel('Articles', 'Site', ['ignore_request' => true]);
if ($model === null) {
return [];
}
$model->setState('params', $app->getParams());
$model->setState('filter.published', 1);
$model->setState('list.limit', (int) $params->get('count', 5));
$app is Factory::getApplication(). ignore_request stops the model from reading the page URL as its own filters, which is what you want inside a module. Core reference: ArticlesLatestHelper.php.
If createModel still returns null, com_content is missing, half-updated, or the model name is wrong. Reinstalling random core files is not the first move. Confirm components/com_content exists and that System → Maintenance → Database shows no schema errors. A partial update leaves new PHP calling old tables, or the reverse. Update path: update Joomla and fix update errors.
Step 5: Fix the Joomla 3 version of the same bug
Joomla 3 will not boot a component. You add the model folder, then ask for the class prefix ContentModel:
JModelLegacy::addIncludePath(
JPATH_SITE . '/components/com_content/models',
'ContentModel'
);
$model = JModelLegacy::getInstance(
'Articles',
'ContentModel',
array('ignore_request' => true)
);
if (!$model) {
return array();
}
$model->setState('params', $params);
The file on disk must be components/com_content/models/articles.php and the class must be ContentModelArticles. A renamed class returns false from getInstance, and the next setState is this fatal.
Do not paste the Joomla 3 block into Joomla 4, 5, or 6. JModelLegacy is legacy. On current Joomla the failure mode changes: either the class is missing (see class not found after an upgrade) or getInstance returns false and you are back to setState() on bool. Use bootComponent().
Step 6: Update or disable the extension in the trace
If the file sits in a commercial component, you cannot invent its model name from the articles example. The controller is calling $this->getModel() with no name, the default model file is gone or not autoloaded after a Joomla 3.10 or Joomla 4 hop, and setState runs on false. That is an extension bug.
- Update it to a build that lists your Joomla major.
- If there is no update, disable it and unpublish its modules and menu items.
- Do not edit
libraries/to hide the message. The next core update overwrites the library and the fatal returns. - A template override of a module helper is a copy. Delete the override and let the current module file run. Then retest.
Major-version breakage of this kind is covered in Joomla upgrade issues. Hop order still matters. A Joomla 3 controller will not start loading models correctly just because the site folder was copied onto Joomla 5.
Step 7: Clear cache after the page renders
Module HTML is often cached. A cached fatal, or a cached empty module, can linger after you fix the PHP. Clear it only once the uncached page works:
- System → Maintenance → Clear Cache, or the cache button on the module.
- Clear the host or CDN cache if the HTML is stored there.
- Reload the page that crashed. The log line for
setStateshould be gone.
If you clear cache first and the model is still null, the error comes straight back. Cache was never the cause.
Step 8: Get the administrator back
- Read the log. If the path contains
/administrator/components/com_or/plugins/, rename that one folder via FTP or the host file manager. Joomla skips an extension whose folder is missing. - If a site module crashes every admin page because it is assigned to the admin menu, unpublish it in
#__modules(publishedset to 0). Matchmoduleto themod_name from the log. - Leave
com_content,com_users, andcom_loginin place. Renaming those locks you out for a different reason. - When the administrator loads, update or uninstall the extension properly, then restore the folder name only if you still need it.
What a correct call looks like
Core always sets state after it knows the model exists. The states you will see in article modules are the query, not user session keys:
params: component or module parametersfilter.published,filter.category_id,filter.access,filter.language,filter.featuredlist.start,list.limit,list.ordering,list.direction
If your code sets those on a model that failed to load, fix the load. If your code sets them on $app, you wanted setUserState() and you are in the wrong API.
When to stop patching the module
Stop if any of these are true:
- The trace names a component you cannot update, and the site still runs Joomla 3
- Several modules fatal with the same
createModelnull after a half-finished upgrade - You already renamed folders and you are not sure which ones the business needs
Infyways runs those repairs and version jumps from $149, with a compatibility audit within 12 hours. Start at Joomla Upgrade Services.
Key takeaways
setState()on null or bool means the model object was never created.- It is not the session, not React, and not fixed by emptying
/tmp. - The file path is the extension name. Start there.
- Joomla 4, 5, and 6 load article models with
bootComponent('com_content')andcreateModel('Articles', 'Site'). - Joomla 3 needs
addIncludePathplusContentModelArticles. CheckgetInstancebeforesetState. - Clear cache after the page renders, not before.
Frequently asked questions
What does Call to a member function setState() mean in Joomla?
PHP called setState() on null or false. In Joomla that value was supposed to be a model from getModel(), getInstance(), or createModel().
Is this a session or login error?
No. Session storage uses setUserState(), which is a different method. Logging out or deleting /tmp does not load a missing model.
Why does it say on bool on one site and on null on another?
Same failure. getModel() and getInstance() return false, so PHP 8 says “on bool”. createModel() returns null, so PHP says “on null”.
Which file should I open?
The file and line in the error. That line is the setState call. The extension folder in that path is what you update or disable.
Will Clear Cache fix it?
No. Clear cache only after the model loads, so Joomla does not keep serving a cached copy of the crash.
Does Joomla 5 or 6 still use setState()?
Yes. Article modules still call $model->setState() after createModel('Articles', 'Site'). The method is fine. A null model is not.
Can I fix it by reinstalling Joomla core?
Only when the trace points at a core file that does not match a stock copy of your version. If the path is a third-party component, reinstalling core leaves the bug in place.
The administrator is a white screen. How do I get in?
Rename the plugin or admin component folder named in the log. Do not rename com_login or com_users. Unpublish a site module from #__modules if that module is what crashes.
Who can fix setState() fatals across an upgrade?
Infyways traces the model load and finishes the version jump when the extension has no update. Request a Joomla upgrade audit.
