You are here:  » Fetch just one day old


Fetch just one day old

Submitted by geizzer on Mon, 2014-02-10 18:20 in

Hi David,

Is there any option to fetch only one day and older files with the cron.php? Because when i get an error, i have to reload the site and than they will start fetch and all?

Best Regards

Toby

Submitted by support on Mon, 2014-02-10 18:28

Hello Toby,

Sure, in scripts/cron.php you will find the following code at line 61:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."jobs` ORDER BY filename";

...you could REPLACE this with:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."jobs` WHERE lastrun < ".(time()-86400)." ORDER BY filename";

And then the only Automation Tool jobs processed by cron.php will be those that have not successfully run within the last 24 hours.

But of course, I would like to help you with any error that you experiencing running cron.php, so if you can let me know any more details, any error messages displayed, or if it is just a server or PHP imposed timeout, let me know...

Cheers,
David.
--
PriceTapestry.com

Submitted by geizzer on Mon, 2014-02-10 18:54

Hi David,

Thanks, but they dosn't work. I get the following error and no files are downloaded:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /kunden/329879_8302/webseiten/geizzer_de/includes/database.php on line 27

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /kunden/329879_8302/webseiten/geizzer_de/includes/database.php on line 32

Best regards

Toby

Submitted by support on Mon, 2014-02-10 19:02

Hi Toby,

Replacement code should have been:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."jobs` WHERE lastrun < ".(time()-86400)." ORDER BY filename";

(corrected above)

Cheers,
David.
--
PriceTapestry.com

Submitted by geizzer on Mon, 2014-02-10 19:29

Hi,

Thanks now works great. When i fetch large files, i always get this error:

Gateway Time-out

The gateway did not receive a timely response from the upstream server or application.

But i think, this error is not from my server? Because i set the time-out 0?

Submitted by support on Tue, 2014-02-11 08:55

Hi Toby,

You're correct - a gateway timeout is most likely a proxy server between your workstation and your web server, such as one operated by your ISP. As it stands, when the script is fetching a large feed, it is not generating any output, and the proxy server is timing out on the connection whilst waiting for it. I've just checked the CURL documentation, and it includes support for a "progress" callback so we can use this feature to make cron.php continually generate output as the transfer progresses.

The first thing to do, if not using CURL already is edit config.advanced.php and look for the following code at line 43:

  $config_automationHandler = "php";

...and REPLACE with;

  $config_automationHandler = "curl";

Next, edit includes/automation.php and look for the following code at line 124:

    curl_setopt($ch,CURLOPT_FOLLOWLOCATION,TRUE);

...and REPLACE with;

    curl_setopt($ch,CURLOPT_FOLLOWLOCATION,TRUE);
    curl_setopt($ch,CURLOPT_NOPROGRESS,FALSE);
    curl_setopt($ch,CURLOPT_PROGRESSFUNCTION,"automation_handler_curl_progress");

Finally, add the following NEW code at the end of the file, just before the closing PHP tag:

  function automation_handler_curl_progress($ch,$dl_exp,$dl_prog,$ul_exp,$ul_prog)
  {
    print (isset($_SERVER["HTTP_USER_AGENT"])?"<br />":"\n");
    print "[".$dl_prog."/".$dl_exp."]";
  }

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by geizzer on Tue, 2014-02-11 17:19

Hi David,

In my cron.php i have only lines between 0 and 116 and i don't can find the curl_setopt($ch,CURLOPT_FOLLOWLOCATION,TRUE); line?

Best regards

Toby

Submitted by support on Tue, 2014-02-11 17:42

My apologies Toby, the script to edit is includes/automation.php (corrected above)...

Cheers,
David.
--
PriceTapestry.com

Submitted by geizzer on Wed, 2014-02-12 17:46

Hi David,

But now, i get the following error:

[0/34829]
Warning: Missing argument 5 for automation_handler_curl_progress() in /kunden/329879_8302/webseiten/geizzer_de/includes/automation.php on line 186

[0/34829]
Warning: Cannot modify header information - headers already sent by (output started at /kunden/329879_8302/webseiten/geizzer_de/includes/automation.php:186) in /kunden/329879_8302/webseiten/geizzer_de/admin13031988/automation_tool_run.php on line 18

Best regards

Toby

Submitted by support on Wed, 2014-02-12 18:00

Hi Toby,

That sounds like a version difference in the number of parameters being used in the call to the callback function from CURL. What should remove the warning is making all the parameter optional - so as an alternative version of the new automation_handler_curl_progress() function added to includes/automation.php have a go with the following:

  function automation_handler_curl_progress($ch,$dl_exp="",$dl_prog="",$ul_exp="",$ul_prog="")
  {
    print (isset($_SERVER["HTTP_USER_AGENT"])?"<br />":"\n");
    print "[".$dl_prog."/".$dl_exp."]";
  }

If the same warning occurs, let me know and I'll check it out further of course - but the good news is that given that it was generating output anyway (by virture of the warning messages) this will solve your gateway problem!

Cheers,
David.
--
PriceTapestry.com

Submitted by geizzer on Wed, 2014-02-12 18:30

Hi David,

I think they down't work correct. First they give some out put, but in the end i get this error:

Warning: Cannot modify header information - headers already sent by (output started at /kunden/329879_8302/webseiten/geizzer_de/includes/automation.php:188) in /kunden/329879_8302/webseiten/geizzer_de/admin13031988/automation_tool_run.php on line 18

And i have only a tmp file in the folder..?

Best regards

Submitted by support on Wed, 2014-02-12 18:44

Hi Toby,

Ah - having made the changes to the fetch process to continually generate output, a different method to redirect back to the Automation Tool home page will need to be used, as is indicated in the warning header() cannot be use once output has begun.

An HTTP meta refresh can be used instead, so in admin/automation_tool_run.php look for the following code at line 18:

  header("Location: automation_tool.php");

...and REPLACE with:

  print "<meta http-equiv='refresh' content='0;url=automation_tool.php' />";

The fetch process, with continuous output, should now work fine for both CRON and manually invoked operations...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by geizzer on Wed, 2014-02-12 19:10

Hi,

I don't know... I have ERROR - TRANSFER FAILED and the xml file in the feed ordner is only 34 KB. But the fetch needs 10 Minutes.

Best Regards

Submitted by support on Wed, 2014-02-12 19:19

Hi Toby,

I'll follow up by email first thing and check this out on your server with you if that would be OK...

Thanks.
David.
--
PriceTapestry.com

Submitted by support on Wed, 2014-02-12 19:45

Hi Toby,

Have just sent an email to your registered email address - if not receiving at all let me know through the forum...

Cheers,
David.
--
PriceTapestry.com