Topic: "Hidden" PHP errors
I can't remember if I've already written something about this or not
If you make a mistake in editing, say, lang/[language]/index.php, then you get an error like
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in C:\Apache\Apache2\htdocs\upload\lang\English\index.php on line 7
However, if you make a mistake in lang/[language]/common.php, you get a blank page
Why?
From common.php
// Attempt to load the common language file
@include PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
if (!isset($lang_common))
exit('There is no valid language pack \''.pun_htmlspecialchars($pun_user['language']).'\' installed. Please reinstall a language of that name.');
My proposed fix would remove the @ and do a file_exists before the include, something like this:
// Attempt to load the common language file
if (file_exists(PUN_ROOT.'lang/'.$pun_user['language'].'/common.php')
{
include PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
if (!isset($lang_common))
exit('There is no valid language pack \''.pun_htmlspecialchars($pun_user['language']).'\' installed. Please reinstall a language of that name.');
}
else
exit('There is no valid language pack \''.pun_htmlspecialchars($pun_user['language']).'\' installed. Please reinstall a language of that name.');
It should accomplish the same goal as the other code while also ensuring that errors in the common lang file get noticed