Jump to content

Big bug in customers database when an address is modified


Ventanazos

Recommended Posts

Description: When a customer creates a new customer account and adds an address, even two different addresses, everything works fine, but if this same customer makes any change on any of those addresses he has created before, the modification process from his customer account panel works fine, the address is modified correctly,  nevertheless if you wish to see the customer’s new address from the backoffice, the database gets corrupted and this error is prompted:

 

[PrestaShopException]

Invalid address #265
at line 401 in file classes/Address.php

 

 

396.   // if an id_address has been specified retrieve the address
397.   if ($id_address) {
398.       $address = new Address((int)$id_address);
399.
400.       if (!Validate::isLoadedObject($address)) {
401. throw new PrestaShopException('Invalid address
#'.(int)$id_address);
402.       }
403.   } elseif ($with_geoloc && isset($context->customer->geoloc_id_country)) {
404.       $address   = new Address();
405.       $address->id_country = (int)$context->customer->geoloc_id_country;
406.       $address->id_state   = (int)$context->customer->id_state;
 
 

If you try to go to abandoned carts you’ll get the same issue and the same screen shows up.  Actually in some other forums they said a solution is to trunk the abandoned carts database, but of course this is not an option since you’ll trunk and loose the updates to their addresses your customers have done before.

 

I can’t tell the origin of this error but I have two hypotheses:

1- There’s a bug that corrupts o produces the database issue when a modification to a customer address is performed.

2. When the number of abandoned carts in database reaches a limit, PS is unable to manage the surpassed limit.

 

 

Solution: I don’t have it and I need it urgently please, thanks in advance to anyone with a real solution. 

Link to comment
Share on other sites

@musicmaster I did what you say, actually I found that address #265 doesn't exist, in ps_address there’s a 264 and a 266, but not a 265.  So I think this is the bug, for any unknown (at least for me) reason, continuity in ps_address key field gets broken, an entry (or several) gets lost, before consecutive counting is resumed.

 

Then I went to ps_customer to see if this missing address was assigned to any customer, and in fact, it was assigned to the last customer that has made a change to his address from his account panel, exactly that whose record was not accessible from my backoffice.

 

So the next step was to see on ps_cart which cart has assigned to that invalid address, once I found this cart I made a change directly on the BD through phpmyadmin changing the id_address, instead of the 265 writing 264, which previously I checked it is a valid address an it`s assigned to the same customer. 

 

Notice: I had have to repeat several times the process with some other customers, including a fake customer I’ve created since the very beginning of my store installation intended to be used for tests and “experimentation” which actually had 15 or so invalid addresses assigned.

 

This solved the symptoms, but it’s far from a complete solution, because once every invalid address is turned into a valid one, I can access from back office all those pages, abandoned carts, active carts, and customer profiles which have had invalid addresses.

 

Despite that, the origin of the problem has not been touched at all, so the problem could, and I’m sure, it would appear once again at any unexpected time.  Maybe when a customer needs to make a change or an updating to his address or every time the event that provokes the breaking out of the consecutive increment of the key field in ps_address appears again.  So  this is what makes me concern about it, and not a temporary solution which I already have achieved.

Link to comment
Share on other sites

The error that you report is a symptom. The real problem of course is that somehow this address entry is deleted while it stays in other tables.

 

The first step to analyze what goes wrong would be to have a look at your server's error log. There are two that are interesting: Apache's error.log and PHP's php_error_log (they may have different names on your system and are not always both there). Can you look in them to see whether there is anything suspicious in them? You could also look into the activity logs to see if you can find when the address was deleted.

 

If you can reproduce the bug you might also try to run it with Firebug active and look for javascript errors.

 

The only idea that you could try at the moment to solve the problem is exporting the ps_address table, delete it and then re-import it. This should be preceded by exporting the whole database.

Edited by musicmaster (see edit history)
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...