Author Topic: Creation date lost after translating article  (Read 2292 times)

Peter Pillen

  • Jr. Member
  • **
  • Posts: 223
Creation date lost after translating article
« on: November 28, 2012, 14:55:43 pm »
Joomla 2.5.8
Virtuemart 2.0.14

Situation
I had filled my virtuemart categories with about 300 products. I had the French and English languages all set up beforehand. But after I translated all my articles/products, the creation date was lost. This causes my product ordering by creation date to fail, also the "latest products" module does not display anything.

Proof
I have checked my phpmyadmin tables, and the "created_on" fields of every record (except the products I missed to translate) in the table "virtuemart_products", where set to "0000-00-00 00:00:00". I even did a clean install of virtuemart, but the problem persists.

I will change the cration dates manually in the database with phpadmin now, but if someone can check if this is a bug or not, it would be a great help. I sometimes change code in the core files, but not anything related to these creation dates.

Temporary solution: updating the tables in the database directly with mysql statement after translation

Code: [Select]
UPDATE `database name`.`XXX_virtuemart_products` SET `created_on` = `modified_on`;
this overwrites all the creation dates to the modified dates.

Peter Pillen

  • Jr. Member
  • **
  • Posts: 223
Re: Creation date lost after translating article
« Reply #1 on: November 29, 2012, 09:52:24 am »
* bump *

could anyone check if they have this problem too? If i'm the only one with this problem, I need to check my files again.

Peter Pillen

  • Jr. Member
  • **
  • Posts: 223
Re: Creation date lost after translating article
« Reply #2 on: December 04, 2012, 11:02:35 am »
Is there anyone with the same problem?

Could someone give me some directions to which files could be causing this problem? I know the creation date upon copying a product was fixed in the latest version of virtuemart, but maybe the problem persists in the translation of the products.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9912
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Creation date lost after translating article
« Reply #3 on: December 04, 2012, 13:19:40 pm »
Interesting problem. Maybe it is similar like the copy, yes. If you want to investigate yourself, take a look on vmtables and there the store function. you may learn how to use vmdebug, makes it easier. IF you are fast enough, we can add it to 2.0.16
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Peter Pillen

  • Jr. Member
  • **
  • Posts: 223
Re: Creation date lost after translating article
« Reply #4 on: December 04, 2012, 16:15:42 pm »
I see in VMdebug that the function "bindChecknStoreNoLang" is used to store the new languagevariant. But I don't see any reference to the the date of the product. Probably the date is overwritten in some other manner.

Vm debug shows me thee following message (this is the moment the date is lost)

        vmdebug self::$_jpConfig->lang en_gb
        vmdebug vmTime: loadConfig db no: 0.0041069984436035
        vmdebug bindChecknStoreNoLang my $tblKey virtuemart_product_id 401
        vmdebug self::$_jpConfig->lang nl_nl
        vmdebug vmTime: loadConfig db no: 0.0039050579071045
        vmdebug VirtuemartViewProduct edit

Could it be that the created_on field is set as non loggable? Because the function "store" only uses fields that logged...

file: /administrator/components/com_virtuemart/helpers/vmtable.php

Code: [Select]
function store($updateNulls = false){

$this->setLoggableFieldsForStore(); //<-- only logged fields?

$this->storeParams();

return parent::store($updateNulls);

}
and somewhere up in the document I see
Code: [Select]
public function setLoggable(){
$this->_loggable = true;
$this->created_on = false; //<-- creation date and time is not logged?
$this->created_by = 0;
$this->modified_on = '';
$this->modified_by = 0;
}

I tried different things, but no luck :(

Peter Pillen

  • Jr. Member
  • **
  • Posts: 223
Re: Creation date lost after translating article
« Reply #5 on: December 04, 2012, 22:43:00 pm »
Nope... I can't find the problem. I probably missing but 5 IQ to solve this puzzle, but i'm not getting any smarter.

I can only guess that vmtable.php doesn't take the created_on date along in the function for the first translation in a new language (because when I do a second update of that language, the date does not change).

so unfortunatly... NO solution

Peter Pillen

  • Jr. Member
  • **
  • Posts: 223
Re: Creation date lost after translating article
« Reply #6 on: December 05, 2012, 23:17:51 pm »
Okay... I need some help in solving this problem and I can't imagine no one else is experiencing problems with this ... although most sites only use one language, I don't have that luxury and I need three languages.

This error causes the Latest products module to fail and makes it impossible to sort products on creation date in all multilingual virtuemart sites. Sure this must be important for more users than just me?

lysov

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 105
    • Litera ltd
Re: Creation date lost after translating article
« Reply #7 on: December 06, 2012, 07:30:03 am »
I have the same problem - http://forum.virtuemart.net/index.php?topic=104597.msg347910#msg347910
Empty value number of fields is in many cases, my temporary solution is creating Mysql triggers

Peter Pillen

  • Jr. Member
  • **
  • Posts: 223
Re: Creation date lost after translating article
« Reply #8 on: December 07, 2012, 17:43:44 pm »
Can someone confirm this fix/solution please? Because it seems to work here, although it looks as a caveman fix ... "just hit it"  ;D

file /administrator/components/com_virtuemart/helpers/vmtable.php

I added a check for an empty created_on field in the function setLoggableFieldsForStore() and if so, re-use the variable $this->$today

Code: [Select]
if($this->created_on=="0000-00-00 00:00:00"){
$this->created_on = $this->$today;
}

it is placed @line 265 (see below)

Code: [Select]
if(!class_exists('Permissions')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'permissions.php');
$admin = Permissions::getInstance()->check('admin');
if($admin){
if(empty($this->$pkey) and empty($this->created_on)){
$this->created_on = $today;
}
if(empty($this->$pkey) and empty($this->created_by)){
$this->created_by = $user->id;
}
} else {
if(empty($this->$pkey)){
$this->created_on = $today;
$this->created_by = $user->id;
}
}
//ADDED BY P2 PETER
if($this->created_on=="0000-00-00 00:00:00"){
$this->created_on = $this->$today;
}
//END ADD
$this->modified_on = $today;
$this->modified_by = $user->id;

of course this means that somewhere the created_on variable is set to zero, what remains a mistery  :-\

Peter Pillen

  • Jr. Member
  • **
  • Posts: 223
Re: Creation date lost after translating article
« Reply #9 on: December 08, 2012, 23:16:50 pm »
I just noticed that the created_on dates of the manufacturers is also 0000-00-00 00:00:00 over all of them. Not that it has any function, but it all points to one bigger problem.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9912
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Creation date lost after translating article
« Reply #10 on: December 16, 2012, 20:23:32 pm »
Good idea. Added.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

crocodesign

  • Beginner
  • *
  • Posts: 2
Re: Creation date lost after translating article
« Reply #11 on: July 20, 2013, 14:40:25 pm »
What is the status of this problem ?
I'm still seeing this problem with a site on version 2.0.20b

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9912
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Creation date lost after translating article
« Reply #12 on: July 22, 2013, 14:06:26 pm »
and 2.0.22a? in general it is considered as fixed.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Peter Pillen

  • Jr. Member
  • **
  • Posts: 223
Re: Creation date lost after translating article
« Reply #13 on: November 24, 2013, 14:13:39 pm »
Think I found it

file: administrator\components\com_virtuemart\helpers\vmtable.php

in the function setLoggableFieldsForStore() @ line382


search for...

$this->created_on = null;

This line is written there three times in this function and replace it with

unset($this->created_on);

Because the comment line says "If nothing is there, dont update it" but saying $this->created_on = null to achieve that, does not eliminate the variable ... it just changes it into "0000-00-00 00:00:00". In that function the're still a couple more lines like that.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9912
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Creation date lost after translating article
« Reply #14 on: November 24, 2013, 19:29:51 pm »
sounds good, thanks.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/