bsmither Posted November 19, 2013 Share Posted November 19, 2013 I need someone to report on the arrangement of data in the CubeCart_downloads table. Specifically, I need this scenario: An order was placed with a digital download item in a CC4 store (make note of the cart_order_id) The CC4 store was upgraded to CC5 That downloadable item still exists in CC5's Cubecart_downloads table (scan for the cart_order_id) The exact question is: When examining the contents of the CubeCart_downloads table, at the record that has that digital item, is there a value in the 'order_inv_id' column? Quote Link to comment Share on other sites More sharing options...
Al Brookbanks Posted November 20, 2013 Share Posted November 20, 2013 From what I can see `order_inv_id` is relied on heavily in v5 and not present in v4. I don't see any code in the upgrade to give values to this column which means (I expect) that digital downloads after upgrade will fail in v5 from v4. I haven't seen this come up before as I think most store owners have the donwload link set for a few days only and most customers would download it instantly. There may be resultant issues with resetting downloads etc so this is likely to cause problems. I think some code is going to be needed during upgrade to try and populate that column. Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 20, 2013 Author Share Posted November 20, 2013 I have a patch that will add a tab to Maintenance, which will list the records needing repair and code to do the repair, but I need to know the exact (wrong) value that is in this column. The patch, as it is currently coded, looks for null in that column. But as that column is an UNSIGNED INT NOT NULL with no default, I'm fairly certain the result from the upgrade will have a zero (for a not strict-mode database). But I would like to know for sure. Quote Link to comment Share on other sites More sharing options...
Al Brookbanks Posted November 20, 2013 Share Posted November 20, 2013 Well it needs to have the value of the corresponding line item from the order_inventory table. I suppose this can be done by searching against the product name although this won't work if the name has changed over time or if there are more than one product with the same name. I can't think of a better way to do this than that. I hope I understood you correctly. Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 20, 2013 Author Share Posted November 20, 2013 Something got lost in the translation. I need to know the exact (wrong) value that is in the 'order_inv_id' column for a digital download that was sold when the database was at the CC4 schema, then the database was updated to the CC5 schema. As you pointed out, there is no explicit action (during upgrade) that puts a value in this new column. But that column will end up having something in it! I need to know what - exactly. My patch relies on that something being a null. But that's just a guess. Using that guess of null, my patch updates only those records (not the entire recordset) by finding the appropriate value and updating the record. The relevant query is: select('CubeCart_order_inventory', array('id'), array('cart_order_id' => $to_be_repaired['cart_order_id'],'product_id' => $to_be_repaired['product_id'])); Unless there exists the possibility of more than one "same item" digital product in an order (different options???), the cart_order_id - product_id combo should suffice. Quote Link to comment Share on other sites More sharing options...
Al Brookbanks Posted November 20, 2013 Share Posted November 20, 2013 I see now. I created a v4 table with sample data in one column. After running the v5 upgrade SQL this column got a default value of zero. Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 20, 2013 Author Share Posted November 20, 2013 Zero. Good to know. Quote Link to comment Share on other sites More sharing options...
Al Brookbanks Posted November 20, 2013 Share Posted November 20, 2013 Yup. Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 20, 2013 Author Share Posted November 20, 2013 I have submitted a free mod to cubecartforums.org: http://www.cubecartforums.org/index.php?showtopic=18357 Quote Link to comment Share on other sites More sharing options...
Al Brookbanks Posted November 20, 2013 Share Posted November 20, 2013 Ah wonderful. Do you mind if we tweak it for the upgrade process? Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 20, 2013 Author Share Posted November 20, 2013 Feel free, always. Quote Link to comment Share on other sites More sharing options...
Al Brookbanks Posted November 21, 2013 Share Posted November 21, 2013 Thanks Brian. Thanks, a github issue has been created to get this done. Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 27, 2013 Author Share Posted November 27, 2013 You should now, if testing hasn't already found it, the query needs fixing. Find:$GLOBALS['main']->addTabControl("Special 2", 'special2'); $database_download_repairs = $GLOBALS['db']->select('CubeCart_downloads', array('digital_id','cart_order_id','product_id'), array('order_inv_id' => "NULL") ); Change to:$GLOBALS['main']->addTabControl("Special 2", 'special2'); $database_download_repairs = $GLOBALS['db']->select('CubeCart_downloads', array('digital_id','cart_order_id','product_id'), array('order_inv_id' => 0) ); Quote Link to comment Share on other sites More sharing options...
Al Brookbanks Posted November 28, 2013 Share Posted November 28, 2013 Hi Brian, I didn't make a maintenance tab. Instead I added the tweaked code to the upgrade script. I still need to test it. Quote Link to comment Share on other sites More sharing options...
bsmither Posted November 28, 2013 Author Share Posted November 28, 2013 And another technical edit. Change:$download_repaired = $GLOBALS['db']->update('CubeCart_downloads', array('order_inv_id' => $database_order_inventory_id[0]), array('digital_id' => $repair['digital_id']));to$download_repaired = $GLOBALS['db']->update('CubeCart_downloads', array('order_inv_id' => $database_order_inventory_id[0]['id']), array('digital_id' => $repair['digital_id'])); Quote Link to comment Share on other sites More sharing options...
Al Brookbanks Posted November 29, 2013 Share Posted November 29, 2013 Thanks Brian, I've made that change. I still need to test. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.