Skip to content

Commit

Permalink
v6.1-a6 in dev: set_time_limit check in ccss pull
Browse files Browse the repository at this point in the history
  • Loading branch information
Hai Zheng committed Jan 4, 2024
1 parent 857adfb commit 931c32e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ The vast majority of plugins and themes are compatible with LiteSpeed Cache. The
* **Image Optimize** Fixed possible PHP warning for WP requests library response.
* **Image Optimize** Unlocked `noabort` to all async tasks to avoid image optimization timeout. (Peter Wells)
* **Crawler** CLI will now be able to force crawling even browser operation was fired shortly.
* **Page Optimize** Fixed a dynamic property creation warning in PHP8. (PR#606)
* **Page Optimize** Fixed an issue where getimagesize could cause page optimization to fail. (PR#607)
* **Tag** Fixed an array to string conversion warning. (PR#604)

= 6.0.0.1 - Dec 15 2023 =
* 🐞**Image Optimize** Grouped the taken notification to regional center servers to reduce the load after image pulled.
Expand Down
14 changes: 12 additions & 2 deletions src/css.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class CSS extends Base

protected $_summary;
private $_queue;
private $_endts;

/**
* Init
Expand Down Expand Up @@ -205,11 +206,22 @@ private function _cron_handler($type, $continue)
}

$i = 0;
$timeoutLimit = ini_get('max_execution_time');
$this->_endts = time() + $timeoutLimit;
foreach ($this->_queue as $k => $v) {
if (!empty($v['_status'])) {
continue;
}

if (function_exists('set_time_limit')) {
$this->_endts += 120;
set_time_limit(120);
}
if ($this->_endts - time() < 10) {
self::debug("🚨 End loop due to timeout limit reached " . $timeoutLimit . "s");
return;
}

Debug2::debug('[' . $type_tag . '] cron job [tag] ' . $k . ' [url] ' . $v['url'] . ($v['is_mobile'] ? ' 📱 ' : '') . ' [UA] ' . $v['user_agent']);

if ($type == 'ccss' && empty($v['url_tag'])) {
Expand Down Expand Up @@ -279,8 +291,6 @@ private function _send_req($request_url, $queue_k, $uid, $user_agent, $vary, $ur
return 'out_of_quota';
}

set_time_limit(120);

// Update css request status
$this->_summary['curr_request_' . $type] = time();
self::save_summary();
Expand Down
1 change: 1 addition & 0 deletions src/img-optm.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@ public function pull($manual = false)
while ($img_rows = $wpdb->get_results($_q)) {
if (function_exists('set_time_limit')) {
$endts += 600;
self::debug("Endtime extended to " . date("Ymd H:i:s", $endts));
set_time_limit(600);
}
if ($endts - time() < 10) {
Expand Down

0 comments on commit 931c32e

Please sign in to comment.