Jump to content

Birthday problem in account creation


Recommended Posts

I already posted this problem here: http://www.prestashop.com/forums/topic/203286-ps-152-problem-with-account-authentication-new-account-only/

 

But since I didn't get any further respons from Benjamin or anyone else, I did some further research myself. I have downloaded the latest stable 1.5.2 version and installed it with the default database items for testing.

 

Then I set: define('_PS_MODE_DEV_', true);

And then without making any further changes I tried to register a new account with a date of birth set to august 3rd 2011. That resulted in this error:

 

[PrestaShopException]

 

Property Customer->birthday is not valid

at line 790 in file classes/ObjectModel.php

 

784.

785. $message = $this->validateField($field, $this->$field);

786. if ($message !== true)

787. {

788. if ($die)

789. throw new PrestaShopException($message);

790. return $error_return ? $message : false;

791. }

792. }

793.

794. return true;

 

It's exactly the same behaviour on 2 different servers.

Server A:

- Apache/2

- PHP 5.2.17

- MySQL 5.0.67

 

Server B:

- Apache/2

- PHP 5.3.17

- MySQL 5.0.91

 

Hope you can solve this.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Because Benjamin mentioned that this problem wasn't reproducable by him, I downloaded the PS software from this website again on november 19th and installed it on my test server on the 20th. This test setup has the exact same problem.

 

So either the "final" version you are referring to is not the version in the link on the main page of this website, or a new final version has been posted after november 20th, or there is something else causing this problem.

 

However, if you know for sure that this problem did occur in the development version but has been solved in the final version, there clearly must be one or more files that have been changed to fix this problem. So why not tell me where to look (which file & line number) so I can check if I am on the correct version.

 

Just assuming we are all on development versions is not very helpfull at all.

Link to comment
Share on other sites

@SQS, I am using version 1.5.2.

 

@Toareg, agree, I am not using dev versions.

Is strange, im using 1.5.2 official and not have problem with date, but i tested development version 6 days ago and have same problem, im not sure if development version at day now have the error, maybe you can test it, you can download in https://github.com/PrestaShop/PrestaShop/tree/development

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...

Someone was being a real genius there.

Validate.php:493

Replace

if ($birth_date[1] > date('Y') || $birth_date[2] > date('m') || $birth_date[3] > date('d')) {

With

if ($birth_date[1] > date('Y') && $birth_date[2] > date('m') && $birth_date[3] > date('d')) {

Link to comment
Share on other sites

Thanks for trying to help, but that code line is not from version 1.5.2 which we are discussing here.

In version 1.5.2 this function is used:

 

public static function isBirthDate($date)
{
 if (empty($date) || $date == '0000-00-00')
  return true;
 if (preg_match('/^([0-9]{4})-((0?[1-9])|(1[0-2]))-((0?[1-9])|([1-2][0-9])|(3[01]))( [0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $date, $birth_date))
 {
  if ($birth_date[1] >= date('Y') - 9)
return false;
  return true;
 }
 return false;
}

Edited by Toeareg (see edit history)
Link to comment
Share on other sites

i sloved this by changing function dateYears() in tools.php, so now it is showing only allowed years for registration, like it was in previous versions of presta

 

in classes/tools.php

replace this one:

 

 

 

public static function dateYears()
{
 $tab = array();
 for ($i = date('Y'); $i >= 1900; $i--)
  $tab[] = $i;
 return $tab;
}

 

with this one:

 

public static function dateYears()
{
 $tab = array();
 for ($i = date('Y') - 10; $i >= 1900; $i--)
  $tab[] = $i;
 return $tab;
}

Link to comment
Share on other sites

That's an option too of course, and it looks like an elegant one even.

Nevertheless I would be much happier with a solution for the problem than a quick fix to circomvent the problem-trigger.

 

It bothers me that errors can result in a completely blank page. No clue whatsoever what has gone wrong.

That's annoying and it simply shouldn't be happening!

Link to comment
Share on other sites

I did some further research and found some inconsistent behaviour it seems.

 

First I changed the default for $die from true to false (ObjectModel.php line 776):

 

    public function validateFields($die = false, $error_return = false)

 

Now I can register with an invalid birth date. It will accept that without problems.

Then I log in and go to my account settings and try to change the date to another invalid date.

Now I get a proper warning that the date is not valid!!!

That is how the error handling should work: a message instead of a blank screen.

 

Would be nice if someone with more knowledge of the structure of the software could help out with this.

Link to comment
Share on other sites

  • 2 months later...

PS v1.5.3

also have a look at authentification.tpl

 

in my theme they forgot to add {$year} in the lines (2x) that generate the dropdown for years.

 

so:

 

<option value="" {if ($sl_year == $year)} selected="selected"{/if}>{$year}  </option>

becomes:

<option value="{$year}" {if ($sl_year == $year)} selected="selected"{/if}>{$year}  </option>

 

Theme: "Trendy" from themeforest.com (its only one bug among many others..)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...