Email sending rules and automatic status - wrong [url ] in email sent after record is edited by automatic status by CRON

Post Reply
swar
Posts: 60
Joined: 19 Dec 2020, 04:11
Name: A.R.
Location: Bratislava

Email sending rules and automatic status - wrong [url ] in email sent after record is edited by automatic status by CRON

Post by swar »

Where: ext/email_sending/

What: When the automatic status field is changed by CRON and at the same time an email is sent by sending rule type "editing record", the [URL] field in the email is corrupted.

Changing the constant "CRON_HTTP_SERVER_HOST" in config/server.php does not help.

I believe that problem is in function url_for in \includes\functions\urls.php which is called function output_singe_text in \includes\classes\fieldstypes\fieldtype_text_pattern.php. When the script is launched by CRON, the content of $_SERVER array in url_for() is not correct.

Code: Select all

function url_for() {
...
$host = $_SERVER['HTTP_HOST'];
$self = pathinfo($_SERVER['PHP_SELF']);
...
}
How replicate:
1. Create a field type Automatic status for any entity and set some rules for it.
2. Create an Email Sending Rule, type Editing record for Automatic status field. In message content, add [URL] field.
3. Run /cron/autostatus.php
4. Email is sent with wrong url, e.g. http://usr/home/hosting/html/example.co ... th=25-6480 instead of example.com/index.php?module=items/info&path=25-6480
User avatar
support
Site Admin
Posts: 6215
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Email sending rules and automatic status - wrong [url ] in email sent after record is edited by automatic status by

Post by support »

Did test and can't reproduce it. Function url_for have next code

Code: Select all

if(defined('IS_CRON') and IS_CRON == true)
    {
        $url = CRON_HTTP_SERVER_HOST . 'index.php?module=' . $module . $prams;
    }
So CRON_HTTP_SERVER_HOST should be using in cron.
swar
Posts: 60
Joined: 19 Dec 2020, 04:11
Name: A.R.
Location: Bratislava

Re: Email sending rules and automatic status - wrong [url ] in email sent after record is edited by automatic status by

Post by swar »

You are right, I tested it on the previous version of rukovoditel, this has been fixed in 3.0 and works fine now. I an sorry for confusion.
Post Reply