google-code-export / magento-w2p

Automatically exported from code.google.com/p/magento-w2p
1 stars 1 forks source link

Non-existent ZP ID #804

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The extension should handle a non-existent ZP ID gracefully.

ZP cannot guarantee the user cache will be retained, so at some point an 
ID/Hash request is going to fail.

The extension should handle it gracefully, assume that the user was deleted 
from ZP and try to create it once more. If the creation fails then so be it - 
we have a problem.

Try to make this change so that it can be deployed without an upgrade. Not 
everyone will want to upgrade.

Original issue reported on code.google.com by ad...@zetaprints.com on 15 Jun 2012 at 11:45

GoogleCodeExporter commented 9 years ago
See RT3052 for a test case. 

Original comment by ad...@zetaprints.com on 19 Jun 2012 at 3:19

GoogleCodeExporter commented 9 years ago
We need a detailed blog post about this because many customers will need to 
upgrade.

Original comment by ad...@zetaprints.com on 19 Jun 2012 at 3:22

GoogleCodeExporter commented 9 years ago
Diffs: https://code.google.com/p/magento-w2p/source/detail?r=2002

Customers who don't want to update the extension can copy latest 
'lib/ZetaPrints/zetaprints-api.php' file. The file can be downloaded from 
http://magento-w2p.googlecode.com/svn-history/r2002/trunk/lib/ZetaPrints/zetapri
nts-api.php and should be saved as zetaprints-api.php.

Also they have to add following code to _end_ of 
app/code/community/ZetaPrints/WebToPrint/Helper/Data.php file. Check this file 
in the repo as example.

Code:

function wrong_id_hash_combo_handler ($error) {
  if (isset($error['previous'])
      && $error['previous']['code'] == ZP_ERR_WRONG_ID_HASH_COMBO)
    return false;

  $id = zetaprints_generate_guid();
  $password = zetaprints_generate_password();

  $url = Mage::getStoreConfig('webtoprint/settings/url');
  $key = Mage::getStoreConfig('webtoprint/settings/key');

  if (!zetaprints_register_user($url, $key, $id, $password))
    return false;

  Mage::helper('webtoprint')
    ->set_credentials_to_zp_cookie(compact('id', 'password'));

  $session = Mage::getSingleton('customer/session');

  if ($session->isLoggedIn())
    $session
      ->getCustomer()
      ->setZetaprintsUser($id)
      ->setZetaprintsPassword($password)
      ->save();
  else
    $session
      ->setZetaprintsUser($id)
      ->setZetaprintsPassword($password);

  $post = array(
    'ID' => $id,
    'Hash'=> zetaprints_generate_user_password_hash($password)
  );

  return compact('post');
}

zp_register_error_handler(ZP_ERR_WRONG_ID_HASH_COMBO,
                          'wrong_id_hash_combo_handler');

Please, test it in 2.2.0.0 (alpha 4) release.

Original comment by Anatoly....@gmail.com on 21 Jun 2012 at 1:34

GoogleCodeExporter commented 9 years ago
How do I actually test this? How do I get my ID changed so that I'm not able to 
see products and then try the fix?

Original comment by agur...@gmail.com on 21 Jun 2012 at 1:38

GoogleCodeExporter commented 9 years ago
Log in as a customer and check that product page is working.

Go to the admin interface and change Zetaprints ID or password of your account. 
Go back to the product page and reload it. It should work. You should lost your 
uploaded images.

Do the same on another M. instance. It should work and you will get error on 
page update.

Original comment by Anatoly....@gmail.com on 22 Jun 2012 at 2:45

GoogleCodeExporter commented 9 years ago
Use current ID to preserve user's cache and uploaded images.

Diff: http://code.google.com/p/magento-w2p/source/detail?r=2003

Original comment by Anatoly....@gmail.com on 22 Jun 2012 at 7:35

GoogleCodeExporter commented 9 years ago
Atanas, please test different aspects of the extension. Use latest beta 
(2.1.3.0.2).

Original comment by Anatoly....@gmail.com on 23 Jun 2012 at 1:01

GoogleCodeExporter commented 9 years ago
Just give it a bash here and there. Nothing formal.

Original comment by ad...@zetaprints.com on 24 Jun 2012 at 1:43

GoogleCodeExporter commented 9 years ago
Tested on /mageimage/

Replicated the issue using release 2.1.2.0.5 (beta). Got the err (There has 
been an error processing your request).

Updated the extension to 
web_to_print_store_incl_theme 2.1.3.0.2 (beta)
the fix works as long as there's only 1 or 2 characters changed in the User ID. 
Anything more than that and the old error comes up again.

If this is how it should be - mark it Test OK
If I found a bug - More Work

Note. My uploaded images are retained.

Original comment by agur...@gmail.com on 25 Jun 2012 at 12:13

GoogleCodeExporter commented 9 years ago
We need this finished asap.
Dependent on my previous comment... if it is how it should be, release a new 
stable with this fix right away, Anatoly.

Original comment by agur...@gmail.com on 2 Jul 2012 at 11:04

GoogleCodeExporter commented 9 years ago
Uploaded as 2.1.3.0 release.

Original comment by Anatoly....@gmail.com on 4 Jul 2012 at 11:56

GoogleCodeExporter commented 9 years ago
Tested on /mageimage/
web_to_print_store_incl_theme   2.1.3.0 (stable)

Original comment by agur...@gmail.com on 4 Jul 2012 at 2:45

GoogleCodeExporter commented 9 years ago

Original comment by ad...@zetaprints.com on 13 Jul 2012 at 9:11

GoogleCodeExporter commented 9 years ago

Original comment by ad...@zetaprints.com on 27 Jul 2012 at 2:11