zendtech / IbmiToolkit

PHP frontend to XMLSERVICE for IBM i development.
BSD 3-Clause "New" or "Revised" License
46 stars 34 forks source link

Compatibility Wrapper seems to not work since 1.7.1 #117

Closed rodflohr closed 4 years ago

rodflohr commented 4 years ago

Starting with 1.7.1, the Compatibility Wrapper seems to be completely broken. Here is an example script:

<?php
// Test Compatibility Wrapper connection.

// Enable the next line if the XML Toolkit API is not in the include path
//ini_set('include_path', ini_get('include_path') . ":/usr/local/zendsvr/share/ToolkitAPI");

// Bring in the Compatibility Wrapper
require_once 'CW/cw.php';

$user = 'rod';
$password = 'rod';
$server = '127.0.0.1';

$conn = i5_connect($server, $user, $password);

if (!$conn ) die("<br>Connection failed");

echo "<pre>";
echo "<br>================<br>";
echo "connected";
echo "<br>================<br>";

i5_close($conn);

?>

Replace 'user' and 'password' with valid credentials. This script will return a 500 error. Here are the errors in php.log:

[27-Jul-2020 10:18:12 America/New_York] PHP Warning: Use of undefined constant I5_OPTIONS_CODEPAGEFILE - assumed 'I5_OPTIONS_CODEPAGEFILE' (this will throw an Error in a future version of PHP) in /usr/local/zendphp7/var/libraries/PHP_Toolkit_for_IBMI_i/1.7.1/library/CW/cw.php on line 162 [27-Jul-2020 10:18:12 America/New_York] PHP Stack trace: [27-Jul-2020 10:18:12 America/New_York] PHP 1. {main}() /www/zendphp7/htdocs/support/cw_connect_test.php:0 [27-Jul-2020 10:18:12 America/New_York] PHP 2. i5_connect() /www/zendphp7/htdocs/support/cw_connect_test.php:14 [27-Jul-2020 10:18:12 America/New_York] PHP Warning: Use of undefined constant I5_OPTIONS_RMTCCSID - assumed 'I5_OPTIONS_RMTCCSID' (this will throw an Error in a future version of PHP) in /usr/local/zendphp7/var/libraries/PHP_Toolkit_for_IBMI_i/1.7.1/library/CW/cw.php on line 171 [27-Jul-2020 10:18:12 America/New_York] PHP Stack trace: [27-Jul-2020 10:18:12 America/New_York] PHP 1. {main}() /www/zendphp7/htdocs/support/cw_connect_test.php:0 [27-Jul-2020 10:18:12 America/New_York] PHP 2. i5_connect() /www/zendphp7/htdocs/support/cw_connect_test.php:14 [27-Jul-2020 10:18:12 America/New_York] PHP Warning: Use of undefined constant I5_OPTIONS_INITLIBL - assumed 'I5_OPTIONS_INITLIBL' (this will throw an Error in a future version of PHP) in /usr/local/zendphp7/var/libraries/PHP_Toolkit_for_IBMI_i/1.7.1/library/CW/cw.php on line 181 [27-Jul-2020 10:18:12 America/New_York] PHP Stack trace: [27-Jul-2020 10:18:12 America/New_York] PHP 1. {main}() /www/zendphp7/htdocs/support/cw_connect_test.php:0 [27-Jul-2020 10:18:12 America/New_York] PHP 2. i5_connect() /www/zendphp7/htdocs/support/cw_connect_test.php:14 [27-Jul-2020 10:18:12 America/New_York] PHP Warning: Use of undefined constant CW_PERSISTENT - assumed 'CW_PERSISTENT' (this will throw an Error in a future version of PHP) in /usr/local/zendphp7/var/libraries/PHP_Toolkit_for_IBMI_i/1.7.1/library/CW/cw.php on line 204 [27-Jul-2020 10:18:12 America/New_York] PHP Stack trace: [27-Jul-2020 10:18:12 America/New_York] PHP 1. {main}() /www/zendphp7/htdocs/support/cw_connect_test.php:0 [27-Jul-2020 10:18:12 America/New_York] PHP 2. i5_connect() /www/zendphp7/htdocs/support/cw_connect_test.php:14 [27-Jul-2020 10:18:12 America/New_York] PHP Warning: Use of undefined constant I5_OPTIONS_PRIVATE_CONNECTION - assumed 'I5_OPTIONS_PRIVATE_CONNECTION' (this will throw an Error in a future version of PHP) in /usr/local/zendphp7/var/libraries/PHP_Toolkit_for_IBMI_i/1.7.1/library/CW/cw.php on line 216 [27-Jul-2020 10:18:12 America/New_York] PHP Stack trace: [27-Jul-2020 10:18:12 America/New_York] PHP 1. {main}() /www/zendphp7/htdocs/support/cw_connect_test.php:0 [27-Jul-2020 10:18:12 America/New_York] PHP 2. i5_connect() /www/zendphp7/htdocs/support/cw_connect_test.php:14 [27-Jul-2020 10:18:12 America/New_York] PHP Warning: Use of undefined constant I5_OPTIONS_IDLE_TIMEOUT - assumed 'I5_OPTIONS_IDLE_TIMEOUT' (this will throw an Error in a future version of PHP) in /usr/local/zendphp7/var/libraries/PHP_Toolkit_for_IBMI_i/1.7.1/library/CW/cw.php on line 254 [27-Jul-2020 10:18:12 America/New_York] PHP Stack trace: [27-Jul-2020 10:18:12 America/New_York] PHP 1. {main}() /www/zendphp7/htdocs/support/cw_connect_test.php:0 [27-Jul-2020 10:18:12 America/New_York] PHP 2. i5_connect() /www/zendphp7/htdocs/support/cw_connect_test.php:14 [27-Jul-2020 10:18:12 America/New_York] PHP Warning: Use of undefined constant I5_OPTIONS_JOBNAME - assumed 'I5_OPTIONS_JOBNAME' (this will throw an Error in a future version of PHP) in /usr/local/zendphp7/var/libraries/PHP_Toolkit_for_IBMI_i/1.7.1/library/CW/cw.php on line 260 [27-Jul-2020 10:18:12 America/New_York] PHP Stack trace: [27-Jul-2020 10:18:12 America/New_York] PHP 1. {main}() /www/zendphp7/htdocs/support/cw_connect_test.php:0 [27-Jul-2020 10:18:12 America/New_York] PHP 2. i5_connect() /www/zendphp7/htdocs/support/cw_connect_test.php:14 [27-Jul-2020 10:18:12 America/New_York] PHP Warning: Use of undefined constant CW_EXISTING_TRANSPORT_CONN - assumed 'CW_EXISTING_TRANSPORT_CONN' (this will throw an Error in a future version of PHP) in /usr/local/zendphp7/var/libraries/PHP_Toolkit_for_IBMI_i/1.7.1/library/CW/cw.php on line 268 [27-Jul-2020 10:18:12 America/New_York] PHP Stack trace: [27-Jul-2020 10:18:12 America/New_York] PHP 1. {main}() /www/zendphp7/htdocs/support/cw_connect_test.php:0 [27-Jul-2020 10:18:12 America/New_York] PHP 2. i5_connect() /www/zendphp7/htdocs/support/cw_connect_test.php:14 [27-Jul-2020 10:18:12 America/New_York] PHP Warning: Use of undefined constant CW_TRANSPORT_TYPE - assumed 'CW_TRANSPORT_TYPE' (this will throw an Error in a future version of PHP) in /usr/local/zendphp7/var/libraries/PHP_Toolkit_for_IBMI_i/1.7.1/library/CW/cw.php on line 280 [27-Jul-2020 10:18:12 America/New_York] PHP Stack trace: [27-Jul-2020 10:18:12 America/New_York] PHP 1. {main}() /www/zendphp7/htdocs/support/cw_connect_test.php:0 [27-Jul-2020 10:18:12 America/New_York] PHP 2. i5_connect() /www/zendphp7/htdocs/support/cw_connect_test.php:14 [27-Jul-2020 10:18:12 America/New_York] PHP Fatal error: Uncaught Error: Call to undefined function getConfigValue() in /usr/local/zendphp7/var/libraries/PHP_Toolkit_for_IBMI_i/1.7.1/library/CW/cw.php:280 Stack trace:

0 /www/zendphp7/htdocs/support/cw_connect_test.php(14): i5_connect('127.0.0.1', 'rod', 'rod')

1 {main}

thrown in /usr/local/zendphp7/var/libraries/PHP_Toolkit_for_IBMI_i/1.7.1/library/CW/cw.php on line 280

I can at least get rid of the undefined constants by including cwclasses.php into cw.php, but there are still other errors. It does not appear to ever have worked, although I am testing on PHP 7.3, so possibly it was OK in PHP 5, although it seems unlikely. Currently it seems the only way I can get Compatibility Wrapper working for my customers is to back them down to 1.6.1.

alanseiden commented 4 years ago

@rodflohr Try this workaround in your demo script: Underneath your require_once of cw.php, add the line: require_once 'CW/cwclasses.php'; Let us know if that solves the issue.

We will work with @chukShirley on a permanent fix.

rodflohr commented 4 years ago

@alanseiden That seems to work. Interesting that placing that require inside cw.php does not work. Some scoping issue with the objects?

alanseiden commented 4 years ago

@rodflohr We find that placing the classes require inside cw.php does work (at least with the latest on Github) but we didn't want to suggest people changing the toolkit on their own. We'll submit a PR and then tag the latest release.

rodflohr commented 4 years ago

@alanseiden Works for me in 1.8.3. For some reason I was testing in 1.7.1, where that fix did not seem to work all the way. Thanks for pointing this out.

alanseiden commented 4 years ago

@rodflohr We have fixed this issue in 1.8.4. Please test and let us know if 1.8.4 addresses the issue.