fix: Add timeout and user fallback for cronjob safety
- set_time_limit(300) prevents infinite SMTP hangs - Fallback to admin user if $user is empty in cronjob context Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
94356a92da
commit
886021bdd5
1 changed files with 10 additions and 0 deletions
|
|
@ -54,9 +54,19 @@ class PreisBot
|
||||||
{
|
{
|
||||||
global $conf, $user, $langs;
|
global $conf, $user, $langs;
|
||||||
|
|
||||||
|
// Sicherheits-Timeout: Max 5 Minuten für den gesamten Job
|
||||||
|
@set_time_limit(300);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||||
|
|
||||||
|
// User-Kontext sicherstellen (Cronjob hat manchmal keinen User)
|
||||||
|
if (empty($user) || !is_object($user) || empty($user->id)) {
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||||
|
$user = new User($this->db);
|
||||||
|
$user->fetch(1); // Admin-User
|
||||||
|
}
|
||||||
|
|
||||||
$priceSource = getDolGlobalString('PREISBOT_PRICE_SOURCE', 'cheapest');
|
$priceSource = getDolGlobalString('PREISBOT_PRICE_SOURCE', 'cheapest');
|
||||||
$priceDirection = getDolGlobalString('PREISBOT_PRICE_DIRECTION', 'up_only');
|
$priceDirection = getDolGlobalString('PREISBOT_PRICE_DIRECTION', 'up_only');
|
||||||
$minMargin = (float) getDolGlobalString('PREISBOT_MIN_MARGIN', 20);
|
$minMargin = (float) getDolGlobalString('PREISBOT_MIN_MARGIN', 20);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue