Author Topic: Virtuemart exchange rates file /cache/daily.xml is not overwritten  (Read 3732 times)

gand

  • Beginner
  • *
  • Posts: 4
Dear Friends,

File /cache/daily.xml is not overwritten when downloaded.
If I erase daily.xml from the /cache folder and then I use the currency module, the daily.xml is normally downloaded from ecb and written into the /cach folder,
but if there is already a daily.xml file (e.g. yesterday's version) into the cache folder and I use the currency module at the frontend, then it is not replaced/overwritten by the latest version.

I have tried all possible permissions combinations (644, 777 to the daily.xml file and the /cache folder) and ownership combinations (root, ftp user to the daily.xml file) bu to no avail. It did not help.  :'(

I have run out of ideas.

Any help or suggestion would be appreciated.

P.S. Using Joomla 1.5.23 and Virtuemart 1.1.9

Yorgos

gand

  • Beginner
  • *
  • Posts: 4
Re: Virtuemart exchange rates file /cache/daily.xml is not overwritten
« Reply #1 on: December 06, 2011, 10:46:06 am »
Found the solution!!!!!.... there is a BUG in the if() statement of convertECB.php

In file administrator/components/com_virtuemart/classes/currency/convertECB.php
changed line 29 to:
var $document_address = 'http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml';

and the if() statement in line 65 to:
         if(file_exists($archivefile_name) && filesize( $archivefile_name ) > 0 ) {
              // timestamp for the Filename
              $file_datestamp = date('Ymd', filemtime($archivefile_name));

                // check if today is a weekday - no updates on weekends
                if( (date( 'w' ) > 0 && date( 'w' ) < 6)
                   // compare filedate and actual date
                   && ($file_datestamp != $date_now_local
                   // if localtime is greater then ecb-update-time go on to update and write files
                   || (($file_datestamp == $date_now_local
                      && $time_now_local > $time_ecb_update))))
                {
                   $curr_filename = $ecb_filename;   
                }
                else {
               $curr_filename = $archivefile_name;
                   $this->last_updated = $file_datestamp;
               $this->archive = false;
                }
         }
         else {
            $curr_filename = $ecb_filename;
         }

I hope that this helps someone...

Yorgos

kleinbaas

  • Beginner
  • *
  • Posts: 34
This worked perfectly for me. Thanks gand.