Skip to content

Commit

Permalink
Merge pull request #160 from zendtech/fix-5
Browse files Browse the repository at this point in the history
Remove out of class declarations
  • Loading branch information
alanseiden authored Oct 29, 2021
2 parents 44dbad2 + b3b98f8 commit 3fd7fe5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 26 deletions.
16 changes: 8 additions & 8 deletions ToolkitApi/CW/cw.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ function i5_connect($host='', $user='', $password='', $options=array())

// check and store CW_TRANSPORT_TYPE, if given. It's optional.
$transportType = ''; // empty is ok.
$iniTransportType = isset( $options [CW_TRANSPORT_TYPE]) ? $options [CW_TRANSPORT_TYPE] : getConfigValue('transport', 'transportType', 'ibm_db2');
$iniTransportType = isset( $options [CW_TRANSPORT_TYPE]) ? $options [CW_TRANSPORT_TYPE] : Toolkit::getConfigValue('transport', 'transportType', 'ibm_db2');
if ($iniTransportType) {
$validTransports = array ('ibm_db2', 'odbc', 'http', 'https');
if (!in_array($iniTransportType, $validTransports)) {
Expand All @@ -299,7 +299,7 @@ function i5_connect($host='', $user='', $password='', $options=array())
}

// convert host to dbname
$dbname = getConfigValue('hosts', $host);
$dbname = Toolkit::getConfigValue('hosts', $host);

if (!$dbname) {
i5ErrorActivity(I5_CONN_TIMEOUT, I5_CAT_TCPIP, "Undefined host ('$host')", "Try 'localhost' instead, or specify lookup in " . CONFIG_FILE . " ($host=DBNAME).");
Expand Down Expand Up @@ -334,7 +334,7 @@ function i5_connect($host='', $user='', $password='', $options=array())
// Check if INI file has asked us to always close previous connection before initiating new one within a single PHP request/script run.
// For compatibility with old toolkit behavior where a new connection would reset library lists and the like.
// It's false by default for backward compatibility with older releases of CW.
$forceNew = getConfigValue('cw', 'fullDbClose', false);
$forceNew = Toolkit::getConfigValue('cw', 'fullDbClose', false);

// get instance of toolkit (singleton)
try {
Expand Down Expand Up @@ -381,8 +381,8 @@ function i5_connect($host='', $user='', $password='', $options=array())
$tkit->setIsCw(true);

// override toolkit settings if nec.
$sbmjobParams = getConfigValue('system', 'sbmjob_params');
$xmlServiceLib = getConfigValue('system', 'XMLServiceLib', 'ZENDSVR');
$sbmjobParams = Toolkit::getConfigValue('system', 'sbmjob_params');
$xmlServiceLib = Toolkit::getConfigValue('system', 'XMLServiceLib', 'ZENDSVR');

$stateless = false; // default

Expand All @@ -399,7 +399,7 @@ function i5_connect($host='', $user='', $password='', $options=array())

} else {
// Not private. We may be stateless (inline).
$stateless = getConfigValue('system', 'stateless', false);
$stateless = Toolkit::getConfigValue('system', 'stateless', false);

if ($stateless) {
// don't need IPC if stateless, running in QSQ job.
Expand All @@ -416,7 +416,7 @@ function i5_connect($host='', $user='', $password='', $options=array())
}

// If INI file tells us to log CW's connection messages, do so.
if (getConfigValue('log', 'logCwConnect', true)) {
if (Toolkit::getConfigValue('log', 'logCwConnect', true)) {
logThis($connectionMsg);
}

Expand Down Expand Up @@ -573,7 +573,7 @@ function i5_close(ToolkitServiceCw &$connection)
}

// or explicitly asked to close by INI file.
$fullDbClose = getConfigValue('cw', 'fullDbClose', false);
$fullDbClose = Toolkit::getConfigValue('cw', 'fullDbClose', false);
if ($fullDbClose) {
$connection->disconnect();
}
Expand Down
2 changes: 1 addition & 1 deletion ToolkitApi/ToolkitPCML.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct($pcml, ToolkitService $connection, $countersAndCount
$this->setCountersAndCounted($countersAndCounted);

// Convert PCML from ANSI format (which old toolkit required) to UTF-8 (which SimpleXML requires).
$encoding = getConfigValue('system', 'encoding', 'ISO-8859-1'); // XML encoding
$encoding = Toolkit::getConfigValue('system', 'encoding', 'ISO-8859-1'); // XML encoding

/*
* Look for optionally set <?xml encoding attribute
Expand Down
18 changes: 1 addition & 17 deletions ToolkitApi/ToolkitService.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,6 @@ static function getInstance($databaseNameOrResource = '*LOCAL', $userOrI5NamingF

}


/**
* @todo integrate these functions into toolkit class. Back-ported from CW.
*
* keep non-OO functions for backward compatibility and CW support
*
* @param $heading
* @param $key
* @param null $default
* @return bool|null
*/
function getConfigValue($heading, $key, $default = null)
{
return Toolkit::getConfigValue($heading, $key, $default);
}

/**
* non-OO logging function ported from CW
*
Expand All @@ -52,7 +36,7 @@ function getConfigValue($heading, $key, $default = null)
*/
function logThis($msg)
{
$logFile = getConfigValue('log','logfile');
$logFile = Toolkit::getConfigValue('log','logfile');
if ($logFile) {
// it's configured so let's write to it. ("3" means append to a specific file)
$formattedMsg = "\n" . microDateTime() . ' ' . $msg;
Expand Down

0 comments on commit 3fd7fe5

Please sign in to comment.