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

XDMoD 11.0 PHP 7.4 Changes #1806

Merged
merged 30 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9b67a0c
PHP8 Related Changes
eiffel777 Dec 15, 2023
2397fee
fixing up upgrade docs
spark0r May 22, 2024
eb2b0ed
updates per code review
spark0r May 22, 2024
e47518d
appeasing the style gods
spark0r May 28, 2024
c62a7ce
Updating build
spark0r May 29, 2024
cf6f39a
Updating the upgrade docs to hopefully make more sense
spark0r May 29, 2024
e996e98
Updates per code review
spark0r May 29, 2024
68fbbe5
forgot to return values
spark0r May 29, 2024
cebf3a0
appeasing the style gods
spark0r May 29, 2024
6f37189
Adding phpunitarraysubset back
spark0r May 29, 2024
b9937c4
appeasing the style gods... again
spark0r May 29, 2024
b64b7fb
Updates per code review
spark0r May 30, 2024
8a15723
Pinning phpmailer/phpmailer to a version
spark0r May 30, 2024
02c9784
Removing extraneous code
spark0r May 30, 2024
61fa9d9
Upgrade doc updates per code review
spark0r May 30, 2024
ba55069
Turns out we do need this
spark0r May 30, 2024
779593b
Just some minor wordsmithing
spark0r May 30, 2024
2f10c4a
additional wordsmithing
spark0r May 30, 2024
973db40
lksdjf
spark0r May 30, 2024
5b9b72d
more appeasing
spark0r May 30, 2024
ec2d5db
testing php 7.4
spark0r May 30, 2024
4410b2f
missed
spark0r May 30, 2024
8276c78
Missed this some how
spark0r May 30, 2024
ca0c621
addressing PHP Deprecation notice
spark0r May 31, 2024
b0200be
updating mentions of PHP8 to PHP7.4
spark0r May 31, 2024
48d21d4
trying to get rid of deprecation notice
spark0r May 31, 2024
988a69f
alksjdf
spark0r May 31, 2024
d0fd8c4
Update .circleci/config.yml
ryanrath Jun 7, 2024
491410a
Being more specific on phpword version
spark0r Jun 10, 2024
c65cc9e
Throwing exception as opposed to swallowing error case
spark0r Jun 10, 2024
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
25 changes: 20 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
steps:
- run:
name: Generate OpenSSL Key
command: openssl genrsa -rand /proc/cpuinfo:/proc/dma:/proc/filesystems:/proc/interrupts:/proc/ioports:/proc/uptime 2048 > /etc/pki/tls/private/localhost.key
command: openssl genrsa -rand /proc/cpuinfo:/proc/filesystems:/proc/interrupts:/proc/ioports:/proc/uptime 2048 > /etc/pki/tls/private/localhost.key
- run:
name: Generate Certificate
command: /usr/bin/openssl req -new -key /etc/pki/tls/private/localhost.key -x509 -sha256 -days 365 -set_serial $RANDOM -extensions v3_req -out /etc/pki/tls/certs/localhost.crt -subj "/C=XX/L=Default City/O=Default Company Ltd"
Expand All @@ -35,6 +35,15 @@ jobs:
#- setup_remote_docker:
# docker_layer_caching: true
# Download and cache dependencies
- run:
name: Update php module
command: dnf module -y reset php && dnf module -y enable php:7.4
- run:
name: Install PHP 7.4 and PHP module pre-reqs & an updated version of PHP Pear
command: dnf install -y php libzip-devel php-pear php-devel
- run:
name: Install MongoDB Pear module
command: yes '' | pecl install mongodb || true
Copy link
Contributor

Choose a reason for hiding this comment

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

Why || true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So at one point during development yes '' | pecl install mongodb was returning a non-zero exit code due to not being able to add information php.ini. that doesn't seem to be the case anymore. I'll remove the extraneous || true

Copy link
Contributor Author

@ryanrath ryanrath May 30, 2024

Choose a reason for hiding this comment

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

Or judging by the latest build failure it looks like we do need this. Specifically it returns

configuration option "php_ini" is not set to php.ini location
You should add "extension=mongodb.so" to php.ini

and exit code=141

- run:
name: install the composer dependencies
command: composer install
Expand All @@ -43,7 +52,9 @@ jobs:
command: |
mkdir ~/phpunit
mkdir /tmp/screenshots
- run: ~/bin/buildrpm xdmod
- run:
name: Build XDMoD RPM
command: ~/bin/buildrpm xdmod
- run:
name: Install / Upgrade XDMoD from RPM
command: ./tests/ci/bootstrap.sh
Expand Down Expand Up @@ -82,20 +93,24 @@ jobs:
chown root:root -R /usr/local/node-v10.24.1-linux-x64
- run: pushd ./tests/ui && PATH=/usr/local/node-v10.24.1-linux-x64/bin:$PATH /usr/local/node-v10.24.1-linux-x64/bin/npm install && popd
- run: PATH=/usr/local/node-v10.24.1-linux-x64/bin:$PATH ./tests/ui/runtests.sh --headless --log-junit ~/phpunit

- run:
name: 'Run SSO Tests'
command: |
PATH=/usr/local/node-v10.24.1-linux-x64/bin:$PATH ./tests/ci/samlSetup.sh
PATH=/usr/local/node-v10.24.1-linux-x64/bin:$PATH ./tests/ui/runtests.sh --headless --log-junit ~/phpunit --sso
./vendor/phpunit/phpunit/phpunit -c ./tests/integration/phpunit.xml.dist --testsuite sso --log-junit ~/phpunit/xdmod-sso-integration.xml
- run:
name: Ensure that no unexpected Apache errors were generated
command: test ! -e /var/log/php-fpm/www-error.log
name: Ensure that no unexpected Apache errors were generated ( We expect PHP Deprecated )
command: >
jpwhite4 marked this conversation as resolved.
Show resolved Hide resolved
if [ -e /var/log/php-fpm/www-error.log ]; then
test `egrep -v "PHP Deprecated.*vendor\/.*" /var/log/php-fpm/www-error.log | wc -l` = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
test `egrep -v "PHP Deprecated.*vendor\/.*" /var/log/php-fpm/www-error.log | wc -l` = 0;
test `egrep -v "PHP Deprecated.*\/vendor\/.*" /var/log/php-fpm/www-error.log | wc -l` = 0;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as my xdmod-supremm comment, just interested to see what the thought was in adding \/ here.

fi
- run:
name: Ensure that no PHP command-line errors were generated
command: >
if [ -e /var/log/php_errors.log ]; then
test `fgrep -v 'vendor/phpunit/phpunit/src' /var/log/php_errors.log | wc -l` = 0;
test `egrep -v "PHP Deprecated.*vendor\/.*|PHP Notice: fread()" /var/log/php_errors.log | wc -l` = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
test `egrep -v "PHP Deprecated.*vendor\/.*|PHP Notice: fread()" /var/log/php_errors.log | wc -l` = 0;
test `egrep -v "PHP Deprecated.*\/vendor\/.*|PHP Notice: fread()" /var/log/php_errors.log | wc -l` = 0;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as my xdmod-supremm comment, just interested to see what the thought was in adding \/ here.

fi
- store_artifacts:
path: /tmp/screenshots
Expand Down
2 changes: 1 addition & 1 deletion bin/acl-config
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ SQL;
$inserted = 0;
while ($row = $statement->fetch(PDO::FETCH_NUM) ) {
$inserted += 1;
if (fwrite($bulkdatafile, join($row, ',') . "\n") === false) {
if (fwrite($bulkdatafile, join(',', $row) . "\n") === false) {
throw new \Exception('Error writing to temporary file');
}
}
Expand Down
2 changes: 1 addition & 1 deletion classes/CCR/MailWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MailWrapper

public static function initPHPMailer($properties)
{
$mail = new \PHPMailer(true);
$mail = new \PHPMailer\PHPMailer\PHPMailer(true);
$mail->isSendMail();
$address = \xd_utilities\getConfiguration('mailer', 'sender_email');
$mail->Sender = $address;
Expand Down
2 changes: 1 addition & 1 deletion classes/DB/PDODBMultiIngestor.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class PDODBMultiIngestor implements Ingestor
function __construct(
$dest_db,
$source_db,
$pre_ingest_update_statements = array(),
jpwhite4 marked this conversation as resolved.
Show resolved Hide resolved
$pre_ingest_update_statements,
$source_query,
$insert_table,
$insert_fields = array(),
Expand Down
2 changes: 1 addition & 1 deletion classes/DB/PDODBUnbufferedMultiIngestor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class PDODBUnbufferedMultiIngestor Extends PDODBMultiIngestor
public function __construct(
PDODB $dest_db,
PDODB $source_db,
array $pre_ingest_update_statements = array(),
array $pre_ingest_update_statements,
$source_query,
$insert_table,
array $insert_fields = array(),
Expand Down
2 changes: 1 addition & 1 deletion classes/DataWarehouse/ExportBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public static function getFormat(
* @return array(headers => array of http headers, results => the encoded data to send)
*/
public static function export(
array $exportedDatas = array(),
array $exportedDatas,
$format,
$inline = true,
$filename = 'data'
Expand Down
6 changes: 3 additions & 3 deletions classes/DataWarehouse/Visualization.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public static function getColors($count = NULL, $palleteIndex = 0, $includeWhite
srand();
return $ret;
}

public static function HSVtoRGB(array $hsv)
{
list($H, $S, $V) = $hsv;
//1
$H *= 6;
//2
$I = floor($H);
//2 NOTE: we cast to int so that the switch below works as intended in PHP8
$I = (int)floor($H);
$F = $H - $I;
//3
$M = $V * (1 - $S);
Expand Down
9 changes: 8 additions & 1 deletion classes/ETL/Aggregator/pdoAggregator.php
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,14 @@ protected function _execute($aggregationUnit)
$aggregationPeriodList = $this->getDirtyAggregationPeriods($aggregationUnit);
$numAggregationPeriods = count($aggregationPeriodList);
$firstPeriod = current($aggregationPeriodList);
$periodSize = $firstPeriod['period_end_day_id'] - $firstPeriod['period_start_day_id'];

// There are instances where $firstPeriod is a bool not an array ( when $aggregationPeriodList is empty or at the end of the array)
// the following code takes that into account.
$periodSize = 0;
if (!is_bool($firstPeriod)) {
$periodSize = $firstPeriod['period_end_day_id'] - $firstPeriod['period_start_day_id'];
}

$batchSliceSize = $this->options->batch_aggregation_periods_per_batch;
$tmpTableName = null;
$qualifiedTmpTableName = null;
Expand Down
2 changes: 1 addition & 1 deletion classes/ETL/DataEndpoint/aStructuredFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ protected function attachFilters()
$this->logger->warning(
sprintf("Skipping filter '%s': %s", $config->name, implode(", ", $messages))
);
continue;
continue 2;
}
$filterName = 'xdmod.external_process';
$resource = @stream_filter_prepend($fd, $filterName, STREAM_FILTER_READ, $config);
Expand Down
10 changes: 7 additions & 3 deletions classes/ETL/DbModel/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,14 @@ public function setSystemQuoteChar($char)

public function quote($identifier)
{
// Don't quote the identifier if it's already been quoted
// We can't quote non-strings so....
if (!is_string($identifier)) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this the safest way to handle this case? What scenarios exist where the quote function was called with a non string object? What was the object and what happened next?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's probably not, I've updated this in the latest commit to throw an Exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So just some background, this code works fine in 7.2|7.4, but it was failing in 8.0 due to 8.X being more stringent about types.

return $identifier;
}

if (0 === strpos($identifier, $this->systemQuoteChar)
&& (strlen($identifier) - 1) === strrpos($identifier, $this->systemQuoteChar) ) {
// Don't quote the identifier if it's already been quoted
if (str_starts_with($identifier, $this->systemQuoteChar)
&& str_ends_with($identifier, $this->systemQuoteChar)) {
return $identifier;
} else {
return $this->systemQuoteChar . $identifier . $this->systemQuoteChar;
Expand Down
2 changes: 1 addition & 1 deletion classes/ETL/Ingestor/HpcdbHostsIngestor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class HpcdbHostsIngestor extends pdoIngestor implements iAction
/**
* @see ETL\Ingestor\pdoIngestor::transform
*/
public function transform(array $srcRecord, $orderId)
public function transform(array $srcRecord, &$orderId)
{
$srcRecord = parent::transform($srcRecord, $orderId);
$transformedRecord = array();
Expand Down
2 changes: 2 additions & 0 deletions classes/ETL/aRdbmsDestinationAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,8 @@ public function getSqlColumnNames($sql)

foreach ( $parsedSql['SELECT'] as $item ) {
if ( array_key_exists('alias', $item)
&& is_array($item['alias'])
&& array_key_exists('as', $item['alias'])
&& $item['alias']['as']
&& array_key_exists('name', $item['alias'])
) {
Expand Down
4 changes: 2 additions & 2 deletions classes/Realm/GroupBy.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public function __construct($shortName, \stdClass $config, Realm $realm, LoggerI
break;
case 'dataset_display_type':
if ( ! is_object($optionValue) ) {
continue;
continue 2;
}
foreach ($optionValue as $datasetType => $chartDisplayValue ) {
if ( ! array_key_exists($datasetType, $this->chartOptions[$optionKey]) ) {
Expand All @@ -388,7 +388,7 @@ public function __construct($shortName, \stdClass $config, Realm $realm, LoggerI
break;
case 'limit':
if ( ! is_object($optionValue) ) {
continue;
continue 2;
}
foreach ($optionValue as $pageType => $limitValue ) {
if ( ! array_key_exists($pageType, $this->chartOptions[$optionKey]) ) {
Expand Down
5 changes: 5 additions & 0 deletions classes/Rest/Utilities/Conversions.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public static function toInt($value)
*/
public static function toString($value)
{
// If no value was provided, then return an empty string.
if (is_null($value)) {
return '';
}

$isObject = is_object($value);
$hasToString = method_exists($value, '__toString');
$isArray = is_array($value);
Expand Down
15 changes: 8 additions & 7 deletions composer.json
Copy link
Contributor

Choose a reason for hiding this comment

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

Are * safe to use for backwards compatibility?

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"COMMENT": "If kassner/log-parser is updated to version >2.1.1, then the call to web_parser->addPattern in classes/ETL/DataEndpoint/WebServerLogFile.php (added in https://github.com/ubccr/xdmod/pull/1816) can be removed along with this 'extra' section."
},
"require": {
"php": "^5.4 || ^7.2",
"php": "^7.4",
"egulias/email-validator": "^1.2",
"google/recaptcha": "~1.1",
"greenlion/php-sql-parser": "~4.2",
Expand All @@ -12,29 +12,30 @@
"moment/moment-min-file": "^2.13.0",
"moment/moment-timezone-min-file": "^0.5.4",
"paragonie/random_compat": "~2.0",
"phpmailer/phpmailer": "^5.2",
"phpmailer/phpmailer": "~6.9",
"robrichards/xmlseclibs": "~3.0",
"sencha/extjs-gpl": "3.4.*",
"silex/silex": "~1.2",
"simplesamlphp/simplesamlphp": "~1",
"simplesamlphp/simplesamlphp": "^1.16",
"symfony/polyfill-php56": "~1.11",
"symfony/process": "~2.0",
"taq/pdooci": "^1.0",
"tildeio/rsvpjs-min-file": "^3.0.18",
"ubccr/simplesamlphp-module-authglobus": "^1.3",
"ubccr/simplesamlphp-module-authoidcoauth2": "^1.1",
"phpoffice/phpword": "^0.17.0",
"phpoffice/phpword": "^1.2.0",
"monolog/monolog": "^1.25",
"plotly/plotly": "^2.29.1",
"kassner/log-parser": "~1.5",
"geoip2/geoip2": "~2.0",
"ua-parser/uap-php": "^3.9",
"mongodb/mongodb": "^1.11"
"mongodb/mongodb": "^1.14"
},
"require-dev": {
"phpunit/phpunit": "~4.8",
"phpunit/phpunit": "^9.0",
"ccampbell/chromephp": "^4.1",
"swaggest/json-schema": "^0.12.41"
"swaggest/json-schema": "^0.12.41",
"dms/phpunit-arraysubset-asserts": "^0.5.0"
},
"repositories": [
{
Expand Down
Loading