Skip to content
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

Merged
merged 19 commits into from
Jul 19, 2017
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ crashlytics-build.properties
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

# Visual Studio code
.vscode/**
settings.json
launch.json

## Build generated
build/
DerivedData
Expand Down
4 changes: 2 additions & 2 deletions classes/CCR/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace CCR;

require_once 'System.php';
Copy link
Member

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?

require_once 'Log.php';

use xd_utilities;
Expand Down Expand Up @@ -90,7 +91,7 @@ public static function factory(
$mask = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE
| E_STRICT | E_DEPRECATED | E_USER_DEPRECATED;

if ($e !== NULL && ($e['type'] & $mask) == 0) {
if ($e !== null && ($e['type'] & $mask) == 0) {
$logger->crit(array(
'message' => $e['message'],
'file' => $e['file'],
Expand Down Expand Up @@ -278,4 +279,3 @@ protected static function getConfiguration($option)
return xd_utilities\getConfiguration('logger', $option);
}
}

153 changes: 77 additions & 76 deletions configuration/linker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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';
Expand All @@ -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');
Expand All @@ -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

Expand Down Expand Up @@ -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);
Copy link
Member

@jpwhite4 jpwhite4 Jul 18, 2017

Choose a reason for hiding this comment

The 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');
Expand All @@ -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']);
6 changes: 0 additions & 6 deletions open_xdmod/modules/xdmod/assets/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ assets_dir="$(
module_dir="$assets_dir/.."
xdmod_dir="$module_dir/../../.."

echo Removing existing dependencies
rm -rf $xdmod_dir/external_libraries

echo Creating directory for external libraries
mkdir $xdmod_dir/external_libraries

echo Installing composer managed dependencies
cd $xdmod_dir
composer install --no-dev
Expand Down
1 change: 0 additions & 1 deletion open_xdmod/modules/xdmod/build.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"classes",
"db",
"etl",
"external_libraries",
"html",
"libraries",
"reporting",
Expand Down
2 changes: 2 additions & 0 deletions shippable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be a newline at the end of this file.