-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional Cleanup for Building in PHP 7.0 #183
Changes from 9 commits
c08959a
354758e
8aa0c26
caf764b
d85e68e
d18080f
5230c82
38b24a7
b1d4bb9
caf7aaa
8637fd1
d2aad5e
b35b647
7633fe1
1b9babd
7d2524b
a81518e
9dbb9ed
2a22b5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
// Register a custom autoloader for XDMoD components. | ||
$include_path = ini_get('include_path'); | ||
$include_path .= ":" . $baseDir . '/classes'; | ||
$include_path .= ":" . $baseDir . '/classes/CCR'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that we want to make this change to the linker. This effectively changes the interpretation of the namespaces, which I don't think is a good idea. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you have files that are incorrectly referencing the wrong namespace then please fix those files. |
||
$include_path .= ":" . $baseDir . '/classes/DB'; | ||
$include_path .= ":" . $baseDir . '/classes/DB/TACCStatsIngestors'; | ||
$include_path .= ":" . $baseDir . '/classes/DB/TGcDBIngestors'; | ||
|
@@ -28,32 +29,33 @@ | |
$include_path .= ":" . $baseDir . '/classes/User'; | ||
$include_path .= ":" . $baseDir . '/classes/ReportTemplates'; | ||
$include_path .= ":" . $baseDir . '/classes/AppKernel'; | ||
$include_path .= ":" . $baseDir . '/external_libraries/Zend/library'; | ||
$include_path .= ":" . $baseDir . '/libraries/HighRoller_1.0.5'; | ||
|
||
ini_alter('include_path', $include_path); | ||
|
||
use CCR\Log; | ||
|
||
function xdmodAutoload($className) | ||
{ | ||
$pathList = explode(":", ini_get('include_path')); | ||
$pathList = explode(":", ini_get('include_path')); | ||
|
||
// if class does not have a namespace | ||
if(strpos($className,'\\') === FALSE) { | ||
$includeFile = $className.".php"; | ||
foreach ($pathList as $path) { | ||
if (is_readable("$path/$includeFile")) { | ||
require_once("$path/$includeFile"); | ||
break; | ||
} | ||
} | ||
} else { | ||
// convert namespace to full file path | ||
$class = dirname(__FILE__) . '/../classes/' | ||
if(strpos($className, '\\') === false) { | ||
$includeFile = $className.".php"; | ||
foreach ($pathList as $path) { | ||
if (is_readable("$path/$includeFile")) { | ||
require_once("$path/$includeFile"); | ||
break; | ||
} | ||
} | ||
} else { | ||
// convert namespace to full file path | ||
$class = dirname(__FILE__) . '/../classes/' | ||
. str_replace('\\', '/', $className) . '.php'; | ||
if (is_readable("$class")) { | ||
require_once($class); | ||
} | ||
} | ||
if (is_readable("$class")) { | ||
require_once($class); | ||
} | ||
} | ||
} | ||
|
||
spl_autoload_register('xdmodAutoload'); | ||
|
@@ -65,14 +67,14 @@ function xdmodAutoload($className) | |
$libraries = scandir($baseDir . '/libraries'); | ||
|
||
foreach ($libraries as $library) { | ||
$file = "$baseDir/libraries/$library"; | ||
if (is_dir($file)) { | ||
continue; | ||
} | ||
require_once($file); | ||
$file = "$baseDir/libraries/$library"; | ||
if (is_dir($file)) { | ||
continue; | ||
} | ||
require_once($file); | ||
} | ||
|
||
class HttpCodeMessages | ||
class HttpCodeMessages | ||
{ | ||
// HTTP 1.1 messages from: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html | ||
|
||
|
@@ -136,73 +138,73 @@ class HttpCodeMessages | |
*/ | ||
function handle_uncaught_exception($exception) | ||
{ | ||
$logfile = LOG_DIR . "/" . xd_utilities\getConfiguration('general', 'exceptions_logfile'); | ||
$logfile = LOG_DIR . "/" . xd_utilities\getConfiguration('general', 'exceptions_logfile'); | ||
|
||
$logConf = array('mode' => 0644); | ||
$logger = Log::factory('file', $logfile, 'exception', $logConf); | ||
$logConf = array('mode' => 0644); | ||
$logger = Log::factory($logfile, $logConf); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you change this function call? Originally the code used the PEAR::Log factory function to generate a file logger. Now you have changed it to use a CCR::Log factory function that does something completely different. Please revert this change. |
||
|
||
$logger->log('Exception Code: '.$exception->getCode(), PEAR_LOG_ERR); | ||
$logger->log('Message: '.$exception->getMessage(), PEAR_LOG_ERR); | ||
$logger->log('Origin: '.$exception->getFile().' (line '.$exception->getLine().')', PEAR_LOG_INFO); | ||
$logger->log('Exception Code: '.$exception->getCode(), PEAR_LOG_ERR); | ||
$logger->log('Message: '.$exception->getMessage(), PEAR_LOG_ERR); | ||
$logger->log('Origin: '.$exception->getFile().' (line '.$exception->getLine().')', PEAR_LOG_INFO); | ||
|
||
$stringTrace = (get_class($exception) == 'UniqueException') ? $exception->getVerboseTrace() : $exception->getTraceAsString(); | ||
$stringTrace = (get_class($exception) == 'UniqueException') ? $exception->getVerboseTrace() : $exception->getTraceAsString(); | ||
|
||
$logger->log("Trace:\n".$stringTrace."\n-------------------------------------------------------", PEAR_LOG_INFO); | ||
$logger->log("Trace:\n".$stringTrace."\n-------------------------------------------------------", PEAR_LOG_INFO); | ||
|
||
// If working in a server context, build headers to output. | ||
$httpCode = 500; | ||
$headers = array(); | ||
$isServerContext = isset($_SERVER['SERVER_PROTOCOL']); | ||
if ($isServerContext) { | ||
$uncheckedExceptionHttpCode = null; | ||
if ($exception instanceof XDException) { | ||
$uncheckedExceptionHttpCode = $exception->httpCode; | ||
$headers = $exception->headers; | ||
} else if ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface) { | ||
$uncheckedExceptionHttpCode = $exception->getStatusCode(); | ||
$headers = $exception->getHeaders(); | ||
} | ||
|
||
if ($uncheckedExceptionHttpCode !== null) { | ||
if (array_key_exists($uncheckedExceptionHttpCode, HttpCodeMessages::$messages)) { | ||
$httpCode = $uncheckedExceptionHttpCode; | ||
} | ||
} | ||
} | ||
|
||
$exceptionData = xd_response\buildError($exception); | ||
$content = json_encode($exceptionData); | ||
if ($isServerContext) { | ||
$headers['Content-Type'] = 'application/json'; | ||
} | ||
|
||
return array( | ||
$httpCode = 500; | ||
$headers = array(); | ||
$isServerContext = isset($_SERVER['SERVER_PROTOCOL']); | ||
if ($isServerContext) { | ||
$uncheckedExceptionHttpCode = null; | ||
if ($exception instanceof XDException) { | ||
$uncheckedExceptionHttpCode = $exception->httpCode; | ||
$headers = $exception->headers; | ||
} elseif ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface) { | ||
$uncheckedExceptionHttpCode = $exception->getStatusCode(); | ||
$headers = $exception->getHeaders(); | ||
} | ||
|
||
if ($uncheckedExceptionHttpCode !== null) { | ||
if (array_key_exists($uncheckedExceptionHttpCode, HttpCodeMessages::$messages)) { | ||
$httpCode = $uncheckedExceptionHttpCode; | ||
} | ||
} | ||
} | ||
|
||
$exceptionData = xd_response\buildError($exception); | ||
$content = json_encode($exceptionData); | ||
if ($isServerContext) { | ||
$headers['Content-Type'] = 'application/json'; | ||
} | ||
|
||
return array( | ||
'content' => $content, | ||
'isServerContext' => $isServerContext, | ||
'headers' => $headers, | ||
'httpCode' => $httpCode, | ||
); | ||
); | ||
} // handle_uncaught_exception | ||
|
||
function global_uncaught_exception_handler($exception) | ||
{ | ||
// Perform logging and output building for the exception. | ||
$exceptionOutput = handle_uncaught_exception($exception); | ||
$exceptionOutput = handle_uncaught_exception($exception); | ||
|
||
// If running in a server context... | ||
if ($exceptionOutput['isServerContext']) { | ||
// Set the exception's headers (if any). | ||
foreach ($exceptionOutput['headers'] as $headerKey => $headerValue) { | ||
header("$headerKey: $headerValue"); | ||
} | ||
if ($exceptionOutput['isServerContext']) { | ||
// Set the exception's headers (if any). | ||
foreach ($exceptionOutput['headers'] as $headerKey => $headerValue) { | ||
header("$headerKey: $headerValue"); | ||
} | ||
|
||
// Set the status code header. | ||
$httpCode = $exceptionOutput['httpCode']; | ||
header("{$_SERVER['SERVER_PROTOCOL']} $httpCode ".HttpCodeMessages::$messages[$httpCode]); | ||
} | ||
// Set the status code header. | ||
$httpCode = $exceptionOutput['httpCode']; | ||
header("{$_SERVER['SERVER_PROTOCOL']} $httpCode ".HttpCodeMessages::$messages[$httpCode]); | ||
} | ||
|
||
// Print the exception's content. | ||
echo $exceptionOutput['content']; | ||
echo $exceptionOutput['content']; | ||
} // global_uncaught_exception_handler | ||
|
||
set_exception_handler('global_uncaught_exception_handler'); | ||
|
@@ -212,14 +214,13 @@ function global_uncaught_exception_handler($exception) | |
$config = Xdmod\Config::factory(); | ||
|
||
$org = $config['organization']; | ||
define('ORGANIZATION_NAME', $org['name']); | ||
define('ORGANIZATION_NAME', $org['name']); | ||
define('ORGANIZATION_NAME_ABBREV', $org['name']); | ||
|
||
$hierarchy = $config['hierarchy']; | ||
define('HIERARCHY_TOP_LEVEL_LABEL', $hierarchy['top_level_label']); | ||
define('HIERARCHY_TOP_LEVEL_INFO', $hierarchy['top_level_info']); | ||
define('HIERARCHY_TOP_LEVEL_LABEL', $hierarchy['top_level_label']); | ||
define('HIERARCHY_TOP_LEVEL_INFO', $hierarchy['top_level_info']); | ||
define('HIERARCHY_MIDDLE_LEVEL_LABEL', $hierarchy['middle_level_label']); | ||
define('HIERARCHY_MIDDLE_LEVEL_INFO', $hierarchy['middle_level_info']); | ||
define('HIERARCHY_MIDDLE_LEVEL_INFO', $hierarchy['middle_level_info']); | ||
define('HIERARCHY_BOTTOM_LEVEL_LABEL', $hierarchy['bottom_level_label']); | ||
define('HIERARCHY_BOTTOM_LEVEL_INFO', $hierarchy['bottom_level_info']); | ||
|
||
define('HIERARCHY_BOTTOM_LEVEL_INFO', $hierarchy['bottom_level_info']); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,6 @@ | |
"classes", | ||
"db", | ||
"etl", | ||
"external_libraries", | ||
"html", | ||
"libraries", | ||
"reporting", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,5 @@ build: | |
- composer install --no-progress | ||
- cp ~/assets/secrets open_xdmod/modules/xdmod/integration_tests/.secrets | ||
- ./open_xdmod/modules/xdmod/integration_tests/runtests.sh --log-junit `pwd`/shippable/testresults/results.xml | ||
on_failure: | ||
- cat /var/log/xdmod/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there should be a newline at the end of this file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What bug this this change intended to fix?