Skip to content

Commit

Permalink
Handle non-standard ports when generating URL for background search i…
Browse files Browse the repository at this point in the history
…ndexing
  • Loading branch information
collectiveaccess committed Sep 25, 2021
1 parent aba331d commit f99d0b3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions app/lib/Controller/Request/RequestHTTP.php
Expand Up @@ -7,7 +7,7 @@
* ----------------------------------------------------------------------
*
* Software by Whirl-i-Gig (http://www.whirl-i-gig.com)
* Copyright 2007-2018 Whirl-i-Gig
* Copyright 2007-2021 Whirl-i-Gig
*
* For more information visit http://www.CollectiveAccess.org
*
Expand Down Expand Up @@ -623,18 +623,24 @@ function close() {
}

if(defined('__CA_SITE_HOSTNAME__') && strlen(__CA_SITE_HOSTNAME__) > 0) {
$host_without_port = __CA_SITE_HOSTNAME__;
$host_port = null;
if(preg_match("/:([\d]+)$/", $host_without_port, $m)) {
$host_without_port = preg_replace("/:[\d]+$/", '', $host_without_port);
$host_port = (int)$m[1];
}

if (
!($vn_port = (int)$this->getAppConfig()->get('out_of_process_search_indexing_port'))
&&
!($vn_port = (int)getenv('CA_OUT_OF_PROCESS_SEARCH_INDEXING_PORT'))
) {
if(__CA_SITE_PROTOCOL__ == 'https') {
$vn_port = 443;
$vn_port = $host_port ?? 443;
} elseif(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT']) {
$vn_port = $_SERVER['SERVER_PORT'];
} else {
$vn_port = 80;
$vn_port = $host_port ?? 80;
}
}

Expand All @@ -651,7 +657,7 @@ function close() {
&&
!($vs_indexing_hostname = getenv('CA_OUT_OF_PROCESS_SEARCH_INDEXING_HOSTNAME'))
) {
$vs_indexing_hostname = __CA_SITE_HOSTNAME__;
$vs_indexing_hostname = $host_without_port;
}
// trigger async search indexing
if((__CA_APP_TYPE__ === 'PROVIDENCE') && !$this->getAppConfig()->get('disable_out_of_process_search_indexing')) {
Expand Down

0 comments on commit f99d0b3

Please sign in to comment.