Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Join Date
    Jun 2012
    Posts
    228
    Plugin Contributions
    0

    Default zen_address_label returns old address after address change

    Following an address book update by editing a default address in My Account, the function zen_address_label returns the old address, even though the address book table is updated. The new address was correctly displayed after submitting the address change. Consider the following code fragment located after the address book table is updated with the new address:
    Code:
    $new_address = zen_address_label($cID, $default_address_id);
    $address_query = "select entry_firstname as firstname, entry_lastname as lastname,
        entry_company as company, entry_street_address as street_address,
        entry_suburb as suburb, entry_city as city, entry_postcode as postcode,
        entry_state as state, entry_zone_id as zone_id,
        entry_country_id as country_id
        from " . TABLE_ADDRESS_BOOK . "
        where customers_id = " . (int)$cID . "
        and address_book_id = " . (int)$default_address_id;
    
    $address = $db->Execute($address_query);
    var_dump($address);
    die ($new_address);
    Line 1 gets the formatted address for the given customers id and address book id. The following query is the same query as in the function. Finally, I dump the results of the query, and show what the function returns.

    This code outputs the following:
    object(queryFactoryResult)#77 (10) { ["EOF"]=> bool(false) ["cursor"]=> int(0) ["fields"]=> array(10) { ["firstname"]=> string(2) "My" ["lastname"]=> string(4) "Name" ["company"]=> NULL ["street_address"]=> string(14) "230 Bernard St" ["suburb"]=> string(0) "" ["city"]=> string(8) "Westmead" ["postcode"]=> string(8) "DN18 4HU" ["state"]=> string(12) "Lincolnshire" ["zone_id"]=> string(1) "0" ["country_id"]=> string(3) "222" } ["is_cached"]=> bool(false) ["result"]=> array(0) { } ["result_random"]=> NULL ["limit"]=> NULL ["resource"]=> object(mysqli_result)#78 (5) { ["current_field"]=> int(0) ["field_count"]=> int(10) ["lengths"]=> array(10) { [0]=> int(2) [1]=> int(4) [2]=> int(0) [3]=> int(14) [4]=> int(0) [5]=> int(8) [6]=> int(8) [7]=> int(12) [8]=> int(1) [9]=> int(3) } ["num_rows"]=> int(1) ["type"]=> int(0) } ["link"]=> object(mysqli)#8 (19) { ["affected_rows"]=> int(1) ["client_info"]=> string(79) "mysqlnd 5.0.12-dev - 20150407 - $Id: 38fea24f2847fa7519001be390c98ae0acafe387 $" ["client_version"]=> int(50012) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["field_count"]=> int(10) ["host_info"]=> string(25) "Localhost via UNIX socket" ["info"]=> NULL ["insert_id"]=> int(0) ["server_info"]=> string(6) "5.7.26" ["server_version"]=> int(50726) ["stat"]=> string(141) "Uptime: 273991 Threads: 1 Questions: 120525 Slow queries: 0 Opens: 46874 Flush tables: 1 Open tables: 64 Queries per second avg: 0.439" ["sqlstate"]=> string(5) "00000" ["protocol_version"]=> int(10) ["thread_id"]=> int(7951) ["warning_count"]=> int(0) } ["sql_query"]=> string(378) "select entry_firstname as firstname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_suburb as suburb, entry_city as city, entry_postcode as postcode, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from address_book where customers_id = 472 and address_book_id = 684" } My Name 430 Bernard St Westmead Lincolnshire DN18 4HU United Kingdom

    The first highlighted portion shows the result of the query showing the new street address. The second highlighted portion shows zen_address_label returns the old street number.

    Version 1.5.6c code for the function is the same except some notifiers were added. So I would expect the same behavior in that version.
    I hope someone can replicate this error.

    Dave
    zc v155f, lots of addons and custom code, php 7.1.xx

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    9,818
    Plugin Contributions
    73

    Default Re: zen_address_label returns old address after address change

    Dave, that could be the result of the database caching. If the same query is run when the 'old' address-information is gathered, then re-running that same query via $db->Execute with no additional parameters returns the cached result (i.e. prior to the address change). Try using $db->ExecuteNoCache instead.

    That's kind of like pressing Ctrl+F5 to force a browser to gather information from the server instead of the browser cache.

  3. #3
    Join Date
    Jun 2012
    Posts
    228
    Plugin Contributions
    0

    Default Re: zen_address_label returns old address after address change

    Hi lat9,
    Thank you. Using NoCache in my query did not change anything. It was returning the correct address anyway. Changing the function query did the trick. Whatever query precedes the function's query causes the problem. A change is needed in core code I think.
    Dave

  4. #4
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    7,467
    Plugin Contributions
    101

    Default Re: zen_address_label returns old address after address change

    Can you provide the filename and line number where you are making the change please
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.

  5. #5
    Join Date
    Jun 2012
    Posts
    228
    Plugin Contributions
    0

    Default Re: zen_address_label returns old address after address change

    Sure. Filename is includes/functions/functions_customers.php
    v155f: line 132
    v156c: line 137
    v157: line 138
    Change:
    Code:
    $address = $db->Execute($address_query);
    to:
    Code:
    $address = $db->ExecuteNoCache($address_query);
    Dave
    Last edited by Dave224; 12 Sep 2020 at 12:04 AM.

  6. #6
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    7,467
    Plugin Contributions
    101

    Default Re: zen_address_label returns old address after address change

    Quote Originally Posted by Dave224 View Post
    Change:
    Code:
    $address = $db->Execute($address_query);
    to:
    Code:
    $address = $db->ExecuteNoCache($address_query);
    Dave
    That's probably a good fix. You are welcome to submit a PR.

    But:
    If you have caching turned on you should disable it. We're not there yet.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.

  7. #7
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    9,818
    Plugin Contributions
    73

    Default Re: zen_address_label returns old address after address change

    Quote Originally Posted by swguy View Post
    That's probably a good fix. You are welcome to submit a PR.

    But:
    If you have caching turned on you should disable it. We're not there yet.
    Huh? Query-Cache has been in-core since zc151.

  8. #8
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    7,467
    Plugin Contributions
    101

    Default Re: zen_address_label returns old address after address change

    Except it doesn't really work. A ton of things that should be cached are not. Things that should not be cached are.

    It would be great if it did work; that's why I opened PR #3755. But we're not there yet.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.

  9. #9
    Join Date
    Jan 2004
    Posts
    65,660
    Blog Entries
    7
    Plugin Contributions
    240

    Default Re: zen_address_label returns old address after address change

    Let's not get derailed by ideas, opinions and status of #3755. That's an entirely different matter. No discussion about it here will help the OP.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  10. #10
    Join Date
    Jan 2004
    Posts
    65,660
    Blog Entries
    7
    Plugin Contributions
    240

    Default Re: zen_address_label returns old address after address change

    @Dave another test for caching issues: now, almost a day later, what's it showing? (If it's still old, that's very alarming unless it matches the db)
    Is there any chance you checked multiple times in the hours after the change to discern when the change suddenly "showed"? (curious here whether a cache expiry actually was a contributing factor)
    Did logout/login make any difference? (lots of things reset and reload during login, mostly in PHP memory)
    Did the wrong address still show if you opened the account in another browser (or incognito private browsing tab)? (starting a session in another browser without cookies can help rule out whether something amuck was stored in the session, which is yet another memory storage area)
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 9
    Last Post: 7 May 2016, 06:39 PM
  2. Replies: 6
    Last Post: 8 Mar 2012, 06:36 PM
  3. Change Email Address on old customer order
    By ricangem in forum Managing Customers and Orders
    Replies: 3
    Last Post: 17 Oct 2011, 04:26 AM
  4. Forwarding to Select shipping address after logging in or creating new address
    By bindaaz in forum All Other Contributions/Addons
    Replies: 5
    Last Post: 28 Jan 2011, 12:54 PM
  5. Blank Page after clicking change address
    By Kinjal in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 3 Jun 2008, 09:43 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR