Skip to content

Commit 5843469

Browse files
authored
Allow gap between async requests (#937)
* Allow gap between async requests * Include explanation of ASYNC_REQUEST_INTERVAL in config_extended.php
1 parent 4f04d9d commit 5843469

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

public_html/lists/admin/init.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,10 +786,14 @@
786786
}
787787
if (!defined('HTTP_PROXY_HOST')) {
788788
define('HTTP_PROXY_HOST', false);
789-
}
789+
}
790790
if (!defined('HTTP_PROXY_PORT')) {
791791
define('HTTP_PROXY_PORT', false);
792792
}
793+
// interval in milliseconds between asynchronous requests
794+
if (!defined('ASYNC_REQUEST_INTERVAL')) {
795+
define('ASYNC_REQUEST_INTERVAL', 0);
796+
}
793797

794798
if (!isset($GLOBALS['export_mimetype'])) {
795799
$GLOBALS['export_mimetype'] = 'application/csv';

public_html/lists/admin/js/phplistapp.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,12 @@ function loadDivContent(index) {
7777
div = asyncLoadDiv[index];
7878
url = asyncLoadUrl[index];
7979
$("#"+div).html(busyImage + '<span class="loadingprogressbanner"></span>');
80-
$("#"+div).load(url, function() {
81-
loadDivContent(index + 1);
80+
$("#"+div).load(url, function(response, status, xhr) {
81+
if (status == "error") {
82+
$("#"+div).html('');
83+
} else {
84+
setTimeout(() => loadDivContent(index + 1), asyncRequestInterval);
85+
}
8286
});
8387
}
8488
}

public_html/lists/admin/lib.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,6 +2385,7 @@ function asyncLoadContentDiv($url,$divname)
23852385
if (typeof asyncLoadDiv == "undefined") {
23862386
var asyncLoadDiv = new Array();
23872387
var asyncLoadUrl = new Array();
2388+
var asyncRequestInterval = ' . ASYNC_REQUEST_INTERVAL . ';
23882389
}
23892390
asyncLoadDiv[asyncLoadDiv.length] = "'.$divname.'";
23902391
asyncLoadUrl[asyncLoadUrl.length] = "'.$url.'";

public_html/lists/config/config_extended.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -893,18 +893,22 @@
893893
// adds constant to email headers
894894
define('GOOGLE_SENDERID', '');
895895

896-
// For ajax based signup forms (https://discuss.phplist.org/t/solved-ajax-subscribe-api/974) the access-control-allow-origin header
896+
// For ajax based signup forms (https://discuss.phplist.org/t/solved-ajax-subscribe-api/974) the access-control-allow-origin header
897897
// has to be set properly.
898898
// Add the addresses of the websites you want to allow to perform ajax requests to PHPList.
899899
define('ACCESS_CONTROL_ALLOW_ORIGINS', ['https://example.com','https://example.org']);
900900

901901
// when using Mysql, what engine should we use
902902
// there is no need to set this, when you have a valid engine defined in your Mysql server settings
903903
// If you set this, the next time upgrade is run on commandline, the system will attempt to change all tables to this engine.
904-
// this is useful for old systems that have been created
904+
// this is useful for old systems that have been created
905905
// for valid engines, check your server documentation (MariaDB or Mysql)
906906
// Warning, setting this value incorrectly will cause your database creation to break
907907
// the current value is a sensible one to use. It is advised not to change this.
908-
// if you are on a shared hosting environment, make sure you have the database permissions to update the
908+
// if you are on a shared hosting environment, make sure you have the database permissions to update the
909909
// information.schema tables.
910910
$mysql_database_engine = 'InnoDB';
911+
912+
// The subscriber totals for each list on the lists page are calculated by sending a sequence of asynchronous requests.
913+
// You can include a delay between requests using this setting. The value is in milliseconds.
914+
define('ASYNC_REQUEST_INTERVAL', 0);

0 commit comments

Comments
 (0)