Skip to content

Commit f79411c

Browse files
authored
Merge pre-release/2025-R5.3 into master (#1014)
* LIMS-1983: Update phpCAS and php-jwt (#1005) * LIMS-1970: Fix Logs & Files view if filepath is null (#1004) * LIMS-1962: Allow downloading of html files (#1006) * LIMS-1431 - Display Metal Id downstream pipeline (#1003) * LIMS-1854: Prevent submission of multiple reprocessing jobs (#1009) * LIMS-1956: Add dewar names and serial nos to shipment requests (#1000) * Fix unit tests (#1015)
1 parent e80bd1e commit f79411c

File tree

21 files changed

+281
-74
lines changed

21 files changed

+281
-74
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ defaults:
1919
shell: bash
2020
working-directory: ./api
2121

22-
# Note, jobs do not share the same working environment, whereas steps do. Also, jobs will run in parallel unless the 'needs' tag is used to flag a dependency
2322
jobs:
2423
php-build:
2524
name: Checkout, build, test and lint PHP code
@@ -33,6 +32,9 @@ jobs:
3332
with:
3433
php-version: 7.3
3534
tools: psalm:4
35+
# Added extensions and coverage here so they are ready for the native run
36+
extensions: mysqli, zip, xdebug
37+
coverage: xdebug
3638

3739
- name: Validate composer.json and composer.lock
3840
run: composer validate
@@ -49,17 +51,12 @@ jobs:
4951
- name: Install dependencies
5052
run: composer install --prefer-dist --no-progress
5153

54+
# CHANGED: Replaced php-actions/phpunit with native execution
55+
# This runs the PHPUnit located in your vendor folder, avoiding the PHAR crash
5256
- name: PHPUnit Tests
53-
uses: php-actions/phpunit@v3
57+
run: vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-text
5458
env:
5559
XDEBUG_MODE: coverage
56-
with:
57-
bootstrap: api/vendor/autoload.php
58-
configuration: api/tests/phpunit.xml
59-
php_extensions: xdebug mysqli zip
60-
args: --coverage-text
61-
php_version: 7.3
62-
version: 9
6360

6461
- name: Run Psalm
6562
run: psalm --output-format=github
@@ -77,8 +74,7 @@ jobs:
7774
node-version: 18.x
7875
- name: JavaScript build, lint and test
7976
working-directory: ./client
80-
# hack the output from the linting steps to avoid these stopping the builds - we are not going to get
81-
# to a clean output without considerable effort, but it's useful to see the output
77+
# hack the output from the linting steps to avoid these stopping the builds
8278
run: |
8379
cp src/js/config_sample.json src/js/config.json
8480
node --version

api/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
}
1515
],
1616
"require": {
17-
"apereo/phpcas": "1.3.8",
17+
"apereo/phpcas": "1.6.1",
1818
"ezyang/htmlpurifier": "4.12.0",
19-
"firebase/php-jwt": "2.2.0",
19+
"firebase/php-jwt": "6.0.0",
2020
"jdorn/sql-formatter": "1.2.9",
2121
"mpdf/mpdf": "8.1.2",
2222
"ralouphie/getallheaders": "2.0.5",

api/config_sample.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@
264264
$use_shipping_service_incoming_shipments = null;
265265
$use_shipping_service_redirect = null;
266266
$use_shipping_service_redirect_incoming_shipments = null;
267-
$shipping_service_api_url = null;
268267
$shipping_service_api_user = null;
269268
$shipping_service_api_password = null;
270269
$shipping_service_app_url = null;

api/src/Authentication/Type/CAS.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ function check()
2727
/**
2828
* @psalm-suppress UndefinedConstant define in CAS.php
2929
*/
30-
phpCAS::client(CAS_VERSION_2_0, $cas_url, 443, '/cas');
30+
$protocol = 'http';
31+
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
32+
$protocol = 'https';
33+
}
34+
$hostname = $_SERVER['HTTP_HOST'];
35+
$service_base_url = $protocol . '://' . $hostname;
36+
phpCAS::client(CAS_VERSION_2_0, $cas_url, 443, '/cas', $service_base_url);
3137
phpCAS::setCasServerCACert($cacert);
3238

3339
try {

api/src/Controllers/AuthenticationController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
namespace SynchWeb\Controllers;
44

55
use Exception;
6-
use JWT;
6+
use Firebase\JWT\JWT;
7+
use Firebase\JWT\Key;
78
use Slim\Slim;
89
use SynchWeb\Model\User;
910

@@ -280,7 +281,7 @@ private function checkForAndValidateAuthenticationToken()
280281

281282
try
282283
{
283-
$token = JWT::decode($jwt, $jwt_key, array('HS512'));
284+
$token = JWT::decode($jwt, new Key($jwt_key, 'HS512'), array('HS512'));
284285
$this->loginId = $token->data->login;
285286
}
286287
catch (\Exception $e)

api/src/Downstream/Type/Dimple.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,12 @@ function _get_blobs() {
2222
);
2323
}
2424

25-
# This will break if dimple is run more than once on the same scalingid
26-
# TODO: Change structure of MXMRRun to link to autoprocprogram
27-
# https://jira.diamond.ac.uk/browse/SCI-7941
2825
function _find_mrrun() {
29-
if (!array_key_exists("scaling_id", $this->process['PARAMETERS'])) {
30-
return;
31-
}
32-
3326
$mrrun = $this->db->pq(
34-
"SELECT mxmrrunid, processingstatus, processingmessage,
35-
rvaluestart, rvalueend, rfreevaluestart, rfreevalueend
27+
"SELECT m.mxmrrunid
3628
FROM mxmrrun m
37-
INNER JOIN autoprocprogram app
38-
ON m.autoprocprogramid = app.autoprocprogramid
39-
WHERE autoprocscalingid=:1",
40-
array($this->process['PARAMETERS']["scaling_id"])
29+
WHERE m.autoprocprogramid=:1",
30+
array($this->autoprocprogramid)
4131
);
4232

4333
if (!sizeof($mrrun)) {
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
namespace SynchWeb\Downstream\Type;
4+
5+
use SynchWeb\Downstream\DownstreamPlugin;
6+
use SynchWeb\Downstream\DownstreamResult;
7+
8+
class MetalId extends DownstreamPlugin {
9+
var $has_images = true;
10+
var $friendlyname = 'Metal Id';
11+
var $has_mapmodel = array(0, 0);
12+
var $_mrrun;
13+
14+
function results() {
15+
$blobs = $this->_get_blobs();
16+
if (sizeof($blobs)) {
17+
$headings = array('Peak', 'Height', 'XYZ');
18+
} else {
19+
$headings = array('No peaks found');
20+
}
21+
$peaks = array($headings);
22+
foreach($blobs as $n => $blob) {
23+
$peak = array($n+1, $blob['HEIGHT'], '('.$blob['X'].', '.$blob['Y'].', '.$blob['Z'].')');
24+
array_push($peaks, $peak);
25+
}
26+
$dat = array();
27+
$dat['BLOBS'] = sizeof($blobs);
28+
$dat['PEAKS'] = $peaks;
29+
30+
$integrator = $this->_lookup_autoproc(
31+
null,
32+
$this->process['PARAMETERS']['scaling_id']
33+
);
34+
if ($integrator) {
35+
$dat['PARENTAUTOPROCPROGRAM'] = $integrator['PROCESSINGPROGRAMS'];
36+
$dat['PARENTAUTOPROCPROGRAMID'] = $integrator['AUTOPROCPROGRAMID'];
37+
}
38+
39+
$results = new DownstreamResult($this);
40+
$results->data = $dat;
41+
42+
return $results;
43+
}
44+
45+
function _find_mrrun() {
46+
$mrrun = $this->db->pq(
47+
"SELECT m.mxmrrunid
48+
FROM mxmrrun m
49+
WHERE m.autoprocprogramid=:1",
50+
array($this->autoprocprogramid)
51+
);
52+
53+
if (!sizeof($mrrun)) {
54+
return;
55+
}
56+
57+
$this->_mrrun = $mrrun[0];
58+
return true;
59+
}
60+
61+
function _get_blobs() {
62+
if (!$this->_find_mrrun()) {
63+
return array();
64+
}
65+
return $this->db->pq(
66+
"SELECT view1, filepath, x, y, z, height
67+
FROM mxmrrunblob
68+
WHERE mxmrrunid = :1
69+
AND filepath is not NULL",
70+
array($this->_mrrun["MXMRRUNID"])
71+
);
72+
}
73+
74+
function images($n = 0) {
75+
$blobs = $this->_get_blobs();
76+
if ($n < sizeof($blobs)) {
77+
return $blobs[$n]["FILEPATH"] . '/' . $blobs[$n]["VIEW1"];
78+
}
79+
}
80+
}

api/src/Page/Download.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ function _get_file($id, $file)
268268
$response->headers->set("Content-Length", filesize($filename));
269269
} elseif ($filesystem->exists($filename.'.gz')) {
270270
$filename = $filename.'.gz';
271-
if ($this->arg('download') == 1) {
272-
// View log file, so unzip and serve
271+
if ($this->has_arg('download') && $this->arg('download') < 3) {
272+
// View/open file, so unzip and serve
273273
$response = new Response(readgzfile($filename));
274274
$this->set_mime_content($response, $file['FILENAME'], $id);
275275
} else {
@@ -549,21 +549,20 @@ function set_mime_content($response, $filename, $prefix = null)
549549

550550
if (in_array($path_ext, array('html', 'htm'))) {
551551
$response->headers->set("Content-Type", "text/html");
552-
$this->_set_disposition_inline($response);
553552
} elseif ($path_ext == 'pdf') {
554553
$response->headers->set("Content-Type", "application/pdf");
555-
$this->_set_disposition_attachment($response, $saved_filename);
556554
} elseif ($path_ext == 'png') {
557555
$response->headers->set("Content-Type", "image/png");
558-
$this->_set_disposition_attachment($response, $saved_filename);
559556
} elseif (in_array($path_ext, array('jpg', 'jpeg'))) {
560557
$response->headers->set("Content-Type", "image/jpeg");
561-
$this->_set_disposition_attachment($response, $saved_filename);
562-
} elseif (in_array($path_ext, array('log', 'txt', 'error', 'LP', 'json', 'lsa'))) {
558+
} elseif (in_array($path_ext, array('log', 'txt', 'error', 'LP', 'json', 'lsa', 'lst'))) {
563559
$response->headers->set("Content-Type", "text/plain");
564-
$this->_set_disposition_inline($response);
565560
} else {
566561
$response->headers->set("Content-Type", "application/octet-stream");
562+
}
563+
if ($this->has_arg('download') && $this->arg('download') < 3) {
564+
$this->_set_disposition_inline($response);
565+
} else {
567566
$this->_set_disposition_attachment($response, $saved_filename);
568567
}
569568
}

api/src/Page/Process.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ function _enqueue()
383383
);
384384
$this->_send_zocalo_message($rabbitmq_zocalo_vhost, $message);
385385

386-
$this->_output(new \stdClass);
386+
$this->_output('Job successfully submitted');
387387
}
388388

389389
function _enqueue_downstream()
@@ -413,7 +413,7 @@ function _enqueue_downstream()
413413

414414
$this->_submit_zocalo_recipe($this->arg('RECIPE'), $parameters);
415415

416-
$this->_output(new \stdClass);
416+
$this->_output('Job successfully submitted');
417417
}
418418

419419
/*

0 commit comments

Comments
 (0)