The function _stormproject_beforesave checks if datebegin/dateend is an array oder a string and then converts the date to a timestamp.

But if I load a stormproject node object with $node = node_load($projectnid), I get a timestamp in $node->datebegin/$node->dateend;
If I only want to change a few values and then save the node again with node_save, the beforesave-function converts the timestamp with strtotime to a timestamp which results in 0.
Now I have to convert the timestamp to a date string, every time i change a stormproject in my code.

I propose the following bugfix.

In stormproject.module on line 658 change this code:

<?php
 
if (is_array($node->datebegin)) {
     
$node->datebegin = _storm_date_to_gmtimestamp($node->datebegin);
  }
  else {
     
$node->datebegin = strtotime($node->datebegin);
  }

  if (
is_array($node->dateend)) {
     
$node->dateend = _storm_date_to_gmtimestamp($node->dateend);
  }
  else {
     
$node->dateend = strtotime($node->dateend);
  }
?>

To this:

<?php
 
if (is_array($node->datebegin)) {
     
$node->datebegin = _storm_date_to_gmtimestamp($node->datebegin);
  }
  elseif (
is_string($node->datebegin)) {
     
$node->datebegin = strtotime($node->datebegin);
  }

  if (
is_array($node->dateend)) {
     
$node->dateend = _storm_date_to_gmtimestamp($node->dateend);
  }
  elseif (
is_string($node->dateend)) {
     
$node->dateend = strtotime($node->dateend);
  }
?>
Files: 
CommentFileSizeAuthor
#2 stormproject_bevoresave.patch700 bytesRaphael Dürst
PASSED: [[SimpleTest]]: [MySQL] 2,614 pass(es).
[ View ]

Comments

juliangb’s picture

Status:Active» Needs work

Please could you post as a patch so that we can follow the process for testing and reviewing?

Thanks!

Raphael Dürst’s picture

Status:Needs work» Patch (to be ported)
StatusFileSize
new700 bytes
PASSED: [[SimpleTest]]: [MySQL] 2,614 pass(es).
[ View ]

Sure.

juliangb’s picture

Version:6.x-2.0» 6.x-2.x-dev
Status:Patch (to be ported)» Needs review

Thanks, marking needs review so that the patch is tested.

juliangb’s picture

Sounds like a sensible change, but would good to have someone else test the patch and mark rtbc if happy.

juliangb’s picture

#2: stormproject_bevoresave.patch queued for re-testing.

juliangb’s picture

Status:Needs review» Fixed

Committed to 6.x-2.x and 7.x-1.x branches, thanks!

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.