“500 – An Error Has Occurred” Message When Trying to Login to Joomla’s Backend

Earlie today, we worked on moving a Joomla website for one of our clients from one server (Network Solutions) to another. The move went smoothly and according to plan and the website functioned after the necessary modifications on the configuration.php file. However, when we tried to login to Joomla’s backend. We were greeted with the following error:

500 – An Error Has Occurred.

Needless to say, the error was not helpful at all. We knew there was an error, but we didn’t know what it was. So we started our quest to find the root of the problem in order to fix it.

We first searched for the string “An error has occurred.” in a default Joomla installation – we knew that it was a constant in a language file, and it was! This error was declared in the language/en-GB/en-GB.ini file as the JERROR_AN_ERROR_HAS_OCCURRED constant.

Our next task was to search for this constant in the Joomla installation (e.g. the files that include this constant), and we discovered that it was included on line 28 in the error.php file located in the administrator/bluestork/system (please note that bluestork can be hathor or system, depending on the template you are using for your backend) directory. Here’s the line containing the constant:

<?php echo $this->error->getCode() ?> - <?php echo JText::_('JERROR_AN_ERROR_HAS_OCCURRED') ?>

So we added a print_r($this->error); just before the echo command in the line above, so it became something like this:

<?php print_r($this->error); echo $this->error->getCode() ?> - <?php echo JText::_('JERROR_AN_ERROR_HAS_OCCURRED') ?>

Printing the error revealed to us that the error was being generated by the line 153 in the application.php located under the administrator/includes/ directory. Here’s the line:

$contents = JComponentHelper::renderComponent($component);

Obviously, the Joomla application had a problem rendering the component, so we checked the renderComponent function located in the helper.php file (which can be found in the libraries/joomla/application/component directory) and we noticed that it wasn’t able to execute the login.php file located under administrator/components/com_login directory since the function executeComponent was returning an error. So we debugged the login.php file (yes, we know, this is becoming very tedious – but we want our readers to know each step we did to know the root of the problem), which lead us to discover that the problem is with this function call in the controller.php file located in the same folder:

$result = $app->login($credentials, array('action' => 'core.login.admin'));

Hmmm… The problem was with the login function, which meant that we should check the login function located in the application.php file under libraries/joomla/application, and so we did! And then we discovered what the real problem was, it was with this line:

$this->triggerEvent('onUserLoginFailure', array((array) $response));

The above line was triggering the onUserLoginFailure event plugin, which was defined in plugins/system/log/log.php. That event was trying to log the login attempt in this line:

$log->addEntry($errorlog);

The log class attempted to save the log under the logs directory – but the $log_path variable in the configuration.php did not refer to the absolute path of the logs directory (it was just /logs), so we changed it (as well as the $tmp_path) to the absolute path (which was something like /home/[ourclienthostingusername]/public_html/[ourclinetjoomlawebsitename]/logs) and everything worked!

If you have already changed the $log_path and the $tmp_path values to the absolute path of the logs and the tmp directory respectively and you still have the same problem, then make sure that these directories are writable by the Joomla application. You can do that by changing the permissions on these two directories to 777.

If you still have the problem after doing all the above, then we’re here to help. Just contact us and we’ll make sure you’ll be able to login to your Joomla backend. Don’t worry, we’ll finish the work in no time and our rates are very, very affordable!

No comments yet.

Leave a comment