Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#1961 closed Bug (fixed)

Reports do not send whilst set to a daily basis

Reported by: Mooash Owned by:
Priority: low Milestone: Piwik 1.2
Component: Core Keywords: mail report piwik
Cc: Sensitive: no

Description

Hi guys,

Whilst setting up websites I've set it to email reports to myself, mooash@…, 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

Attachments (2)

screenshot 1.png (31.2 KB) - added by Mooash 3 years ago.
First Screenshot
screenshot 2.png (84.1 KB) - added by Mooash 3 years ago.
Second Screenshot

Download all attachments as: .zip

Change History (33)

Changed 3 years ago by Mooash

First Screenshot

Changed 3 years ago by Mooash

Second Screenshot

comment:1 Changed 3 years ago by JulienM (JulienMoumne)

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

comment:2 Changed 3 years ago by vipsoft (robocoder)

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

comment:3 Changed 3 years ago by 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

comment:4 Changed 3 years ago by 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.

comment:5 Changed 3 years ago by matt (mattab)

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)

comment:6 Changed 3 years ago by Mooash

My Piwik is currently set to English.

comment:7 Changed 3 years ago by matt (mattab)

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?

comment:8 Changed 3 years ago by matt (mattab)

  • Milestone changed from 1.x - Piwik 1.x to 1.2 Piwik 1.2

comment:9 Changed 3 years ago by 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?

comment:10 Changed 3 years ago by mjhugo

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!

comment:11 Changed 3 years ago by matt (mattab)

Questions

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


comment:12 Changed 3 years ago by 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.

comment:14 Changed 3 years ago by bolero

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['HTTP_HOST'] later, anyway. So, you always end up with "unknown" or $_SERVER['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?

comment:15 Changed 3 years ago by bolero

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

comment:16 Changed 3 years ago by vipsoft (robocoder)

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

comment:17 Changed 3 years ago by bolero

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

comment:18 Changed 3 years ago by bolero

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.

comment:19 Changed 3 years ago by Mooash

I am so confused right now...

comment:20 Changed 3 years ago by bolero

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?
		}

		...
	}

comment:21 Changed 3 years ago by Mooash

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

comment:22 Changed 3 years ago by matt (mattab)

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

comment:23 Changed 3 years ago by bolero

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.

comment:24 Changed 3 years ago by 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?

comment:25 Changed 3 years ago by bolero

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

comment:26 Changed 3 years ago by Mooash

Do I need to use cron to use it?

comment:27 Changed 3 years ago by bolero

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.

comment:28 Changed 3 years ago by matt (mattab)

  • Resolution set to fixed
  • Status changed from new to closed

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.

comment:29 Changed 3 years ago by matt (mattab)

(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

comment:30 Changed 3 years ago by bolero

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_@…. This would trip off people if there is a problem and the latter syntax would even tell them what to do.

comment:31 Changed 3 years ago by matt (mattab)

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

Note: See TracTickets for help on using tickets.