Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Reports do not send whilst set to a daily basis #1961

Closed
Mooash opened this Issue · 32 comments

5 participants

@Mooash

Hi guys,

Whilst setting up websites I've set it to email reports to myself, mooash@gmail.com, on a weekly basis. The only problem is, that it doesn't do this. When I hit "Send report now." the report sends, but on Monday it doesn't send. I live in Australia, Tasmania to be exact and my server is hosted in Richmond, Virginia in the USA. I shall attach a screenshot of my current report settings. I don't think whether this is a bug or just me fucking something up somehow, if it is the later then I am sorry in advance!

Cheers,

James
Keywords: mail report piwik

@Mooash

Attachment: First Screenshot
screenshot 1.png

@Mooash

Attachment: Second Screenshot
screenshot 2.png

@JulienMoumne
Collaborator

Did you check your mail configuration by clicking on "Send Report Now" ?

@robocoder
Collaborator

Are you running Piwik 1.1.1? This fix went in for php 5.1.x: [3617]

@Mooash

Sorry, the title of this ticket is wrong. It should be weekly* not daily basis. But I am currently testing on daily trying and get them working.

@JulienM, yes, when I hit "Send Report Now" the reports do send.

@vipsoft, I upgraded to the latest version last night, but no matter what version I've been running they haven't sent. I'm currently running php version 5.2.14

@Mooash

Actually I tried sending a daily report then, the email went through, but the PDF didn't have any information in it. The structure of the file was all their, the tables and such, but no information.

@mattab
Owner

what language did you set your piwik to? maybe you set it to an unsupported language (there are not many left, but a few are not supported by the PDF library and fonts)

@Mooash

My Piwik is currently set to English.

@mattab
Owner

Please post the PDF without any info in it so we can see what you mean.

To summarize, daily PDF is empty but is sent, and weekly/monthly PDF don't send at all?

@Mooash

Ah. Turns out the PDF's do show content, Google reader was stuffing up.

Sorry about the confusion, my explanation is very messy.

Pretty much when I schedule reports to send no matter whether its weekly or daily, I am yet to test monthly out yet, they do not send. Yet when I click "Send Report Now" they do send. My settings are still set to as they were above on the attachment. Sorry for all the confusion.

Make a little bit more sense now?

@anonymous-piwik-user

We are also experiencing the same issue with Pwiki 1.1.1. Reports are set up to send daily but never send. If we click the "Send Report Now" button, it works without error.

If there's any workaround or further information we can provide to help debug the issue please let us know!

@mattab
Owner

Questions

  • Do you have 'enable browser to trigger archiving' to yes or no?
  • Have you setup cronjob?
@Mooash

Hi matt, I have 'enable browser to trigger archiving' set to yes I'm pretty sure. And I don't have a cronjob setup.

@anonymous-piwik-user

On second thought it seems that the original "if(strlen($piwikHost) == 0)" is meant as a fix for this problem. But it fails because getCurrentHost allows for passing a parameter and has a default value of "unknown". I assume that "unknown" is used elsewhere, or maybe just some Piwik code convention. The author of the PDF plugin wasn't aware of this and checks for an empty string - makes sense.
There are at least three solutions.
1. reduce my code from the forum in Mail.php to just

    public function setFrom($email, $name = null)
    {
        $piwikHost = Piwik_Url::getCurrentHost();
        if ($piwikHost == "" || $piwikHost == "unknown")
            $piwikHost = $_ENV['HOSTNAME'];
        $email = str_replace('{DOMAIN}', $piwikHost, $email);
        parent::setFrom($email, $name);
    ```}

2. pass in the host (which may create other problems, e.g. overwrite values)

3. change getCurrentHost in Url.php. The $default='unknown' doesn't make any sense to me. You cannot pass a $default parameter there, because it would get set to $_SERVER[later, anyway. So, you always end up with "unknown" or $_SERVER['HTTP_HOST']('HTTP_HOST']). (Unless you run via cron *and* pass something in, but this isn't done.)
Proposed change:

static public function getCurrentHost()
{
    ...

    if(isset($_SERVER['HTTP_HOST']))
    {
        $default = Piwik_Common::sanitizeInputValue($_SERVER['HTTP_HOST']);
    }
    elseif ($_ENV['HOSTNAME'])
    {
        $default = Piwik_Common::sanitizeInputValue($_ENV['HOSTNAME']);
    }
    else
    {
        $default = "unknown";
    }

    ...
}

Btw, I don't understand this construct:

static $hostHeaders = null;
if(is_null($hostHeaders))


Isn't that always to be true, anyway?
@anonymous-piwik-user

I have found that this will not always work. I thought it worked, but I guess I still had the hard-coded FQDN in the code.

$_ENV['HOSTNAME']

gets the hostname if run on the command line. However, via cron it seems to be empty. I'm too lazy zu troubleshoot this any further. I just changed the code to set a given hostname if there's still an empty $piwikHost at the end.

So, there should be an option that always fills in an appropriate FQDN if it's still empty.

Possible solutions:

  • have the user enter a sender address for the reports
  • use the hostname from piwik_site - main_url
@robocoder
Collaborator

What if you usephp_uname('n') to get the host name?

@anonymous-piwik-user

php_uname seems to have a bug. I get "host" only, no matter if I use 'n' or even 'a' ! Version is 5.2.16

@anonymous-piwik-user

Oh, wrong usage. I thought I could get a direct output from this command on the command line. I added it to Mail.php, let's see tomorrow.

@Mooash

I am so confused right now...

@anonymous-piwik-user

Ok, "$piwikHost = php_uname('n')" in Mail.php (=solution 1. above) works for cron. Do you want to go with solution 1., 2. or 3.? I can test No. 3 as well if you want. Something like

    static public function getCurrentHost()
    {
        ...

        if(isset($_SERVER['HTTP_HOST']))
        {
            $default = Piwik_Common::sanitizeInputValue($_SERVER['HTTP_HOST']);
        }
        elseif (isset($_ENV['HOSTNAME']))
        {
            $default = Piwik_Common::sanitizeInputValue($_ENV['HOSTNAME']);
        }
        else
        {
            $default = php_uname('n'); //not necessary to sanitize?
        }

        ...
    }

@Mooash

Alright, I just changed my mail.php and I just setup a cron job. I'll get back to you soon!

@mattab
Owner

Is there any update on this? Is there a proposed patch for trunk? please attach :)

@anonymous-piwik-user

There was no answer to my question if I should test solution 3 as well. Won't test solution 3 if you want to use solution 1. I'm running with solution 1 now. I can test solution 3 if you want to implement it. I think that's the preferred way to do it (it fixes the problem at the source), but I don't know what you prefer.

@Mooash

I've tried using solution 1 but I don't my host likes cron jobs much, that or I'm just retarded in setting it up. Maybe we could try solution 3?

@anonymous-piwik-user

Solution 1 works. You may not have correctly implemmented it. And solution 3 is outlined above. You can just try it.

@Mooash

Do I need to use cron to use it?

@anonymous-piwik-user

No. If you do not use cron I think you do not need either solution. This solution should only be necessary if archive.sh is run by cron because then the environment doesn't include the $_SERVER array which is originally used to get the hostname.

@mattab
Owner

I'll mark it as fixed because I think this is not a bug in 1.2-rc as this code has changed and now we pass piwik.org as parameter to the function.

@mattab
Owner

(In [3936]) Refs #1961 Adding new config parameter to configure the default hostname when it couldn't be detected

To test with this new code, please try 1.2-rc3, more info in: http://forum.piwik.org/read.php?2,72265

@anonymous-piwik-user

I would not pass piwik.org in. You may get lots of botmail to non-existant addresses under piwik.org. I would either pass nothing or "unknown" (as now) or something like @setconfigparameter_parametername_@example.com. This would trip off people if there is a problem and the latter syntax would even tell them what to do.

@mattab
Owner

(In [3943]) Refs #1961 changing default host from piwik.org thanks for the tip!

@Mooash Mooash added this to the Piwik 1.2 milestone
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.