Skip to content

Commit

Permalink
Redirect loop when site is offline and home page sends a 404 (solves
Browse files Browse the repository at this point in the history
  • Loading branch information
infograf768 committed Aug 10, 2015
1 parent 230ff77 commit ef0467c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions language/en-GB/en-GB.ini
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ JGLOBAL_LT="<"
JGLOBAL_NEWITEMSLAST_DESC="New items default to the last position. Ordering can be changed after this item has been saved."
JGLOBAL_NO_MATCHING_RESULTS="No Matching Results"
JGLOBAL_NUM="#"
JGLOBAL_OFFLINE_ERROR="This site is offline and the Home Page sends a 404 error. Please contact a site administrator."
JGLOBAL_OTPMETHOD_NONE="Disable Two Factor Authentication"
JGLOBAL_PASSWORD="Password"
JGLOBAL_PASSWORD_RESET_REQUIRED="You are required to reset your password before proceeding."
Expand Down
12 changes: 11 additions & 1 deletion libraries/legacy/error/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -786,11 +786,21 @@ public static function customErrorPage(&$error)

// Push the error object into the document
$document->setError($error);
$homemenu = $app->getMenu()->getDefault(JFactory::getLanguage()->getTag());
$active = $app->getMenu()->getActive();

// If site is offline and it's a 404 error, just go to index (to see offline message, instead of 404)
// If the 404 concerns the home page, exit and display a message
if ($error->getCode() == '404' && JFactory::getConfig()->get('offline') == 1)
{
JFactory::getApplication()->redirect('index.php');
if ($homemenu !== $active)
{
JFactory::getApplication()->redirect('index.php');
}
else
{
jexit(JText::_('JGLOBAL_OFFLINE_ERROR'));
}
}

@ob_end_clean();
Expand Down

0 comments on commit ef0467c

Please sign in to comment.