ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
i have seen this problem on a few clients sites.... just to be clear, i have now updated:
includes/classes/db/mysql/query_factory.php
to the latest version. and have modified the _sess_write function in:
includes/functions/sessions.php
to such:
i'll see if this resolves the error.... i did see that the stringIgnoreNull as part of the bindVars in the query_factory.Code:$sql = $db->bindVars($sql, ':zvalue', $val, 'stringIgnoreNull');
best.
That should correct the issue, @carlwhat, providing the same functionality (without the debug-log) as the original code.
Update: I just had a drink of coffee and reread your post. To which version of Zen Cart did you "back-port" the query_factory.php class-file?
My guidance to store owners receiving this error where their store's query_factory.php doesn't include the stringIgnoreNull handling would be to simply cast the value to a string prior to the database update rather than copying the entire class-file.
Last edited by lat9; 19 Jan 2017 at 01:48 PM. Reason: Added update
@lat9
re-reading my posts? sorry, i try to make things as clear and simple as possible...
my clients sites are at v1.5.5; i have not done any of the updates to a-b-c or d.... the differences in the class file were small; and in fact look solely related to the stringIgnoreNull situation. the date differences were as such:
(not sure why the new versioning removed the year, the timestamp i can do without...)Code:- * @version $Id: Author: DrByte Sun Feb 14 17:28:50 2016 -0500 Modified in v1.5.5 $ + * @version $Id: Author: zcwuilt Fri Apr 15 Modified in v1.5.5 $
frankly, it really was a minor annoyance; but i do like to address all debug logs. it's one of those things that the client never says anything about it.
so far so good.... if i see new errors related to this fix, i will post here in this thread.
thanks again.
@carlwhat, I was only saying that my coffee-level (or lack thereof) caused me to mis-read your post initially.
Migrating the most recent query_factory.php to an earlier ZC 1.5.5 releases should be A-OK; I was just concerned that moving the 1.5.5d version of the module to a site using an earlier Zen Cart version could be problematic.
I have recently begun running into this issue myself. I tried the solution suggested in post #34 above but that doesn't seen to be taking care of it. I'm posting one of the error logs below. I truncated the value of the session key because it was insanely long. I'm running version 1.5.5e of Zen Cart. Any advice is welcome.
This is what my includes\functions\sessions.php file looks like for the session write function. Did I miss something or do something incorrectly?Code:[16-Oct-2017 14:41:43 America/New_York] Request URI: /catalog/metal-wine-racks-c-34_41/?zenid=2ebs3mmgmrqas9h520lq6enla1UNIONALLSELECTNULL--mXuy, IP address: 91.247.38.57 #1 trigger_error() called at [/XXX/XXX/XXX/public_html/XXX/catalog/includes/classes/db/mysql/query_factory.php:167] #2 queryFactory->show_error() called at [/XXX/XXX/XXX/public_html/XXX/catalog/includes/classes/db/mysql/query_factory.php:139] #3 queryFactory->set_error() called at [/XXX/XXX/XXX/public_html/XXX/catalog/includes/classes/db/mysql/query_factory.php:266] #4 queryFactory->Execute() called at [/XXX/XXX/XXX/public_html/XXX/catalog/includes/functions/sessions.php:70] #5 _sess_write() #6 session_write_close() called at [/XXX/XXX/XXX/public_html/XXX/catalog/includes/application_bottom.php:16] #7 require(/XXX/XXX/XXX/public_html/XXX/catalog/includes/application_bottom.php) called at [/XXX/XXX/XXX/public_html/XXX/catalog/index.php:105] [16-Oct-2017 14:41:43 America/New_York] PHP Fatal error: 1048:Column 'sesskey' cannot be null :: insert into sessions (sesskey, expiry, `value`) values (null, 1508180743, 'c2VjdXJpdHlUb2tlbnxzOjMyOiJiMjYwOGQ4ZmIyNDgxMzhhMTE2Mjk3MGJkY2YwNzI1MyI7Y3VzdG9tZXJzX2hvc3RfYWRk') ON DUPLICATE KEY UPDATE `value`='c2VjdXJpdHlUb2tlbnxzOjMyOiJiMjYwOGQ4ZmIyNDgxMzhhMTE2Mjk3MGJkY2YwNzI1MyI7Y3VzdG9tZXJzX2hvc3RfYWRk', expiry=1508180743 ==> (as called by) /XXX/XXX/XXX/public_html/XXX/catalog/includes/functions/sessions.php on line 70 <== in /XXX/XXX/XXX/public_html/XXX/catalog/includes/classes/db/mysql/query_factory.php on line 167
Code:function _sess_write($key, $val) { global $db; if (!is_object($db)) return; $val = base64_encode($val); global $SESS_LIFE; $expiry = time() + $SESS_LIFE; $sql = "insert into " . TABLE_SESSIONS . " (sesskey, expiry, `value`) values (:zkey, :zexpiry, :zvalue) ON DUPLICATE KEY UPDATE `value`=:zvalue, expiry=:zexpiry"; $sql = $db->bindVars($sql, ':zkey', $key, 'string'); $sql = $db->bindVars($sql, ':zexpiry', $expiry, 'integer'); //$sql = $db->bindVars($sql, ':zvalue', $val, 'string'); $sql = $db->bindVars($sql, ':zvalue', $val, 'stringIgnoreNull'); $result = $db->Execute($sql); return (!empty($result) && !empty($result->resource)); }
Last edited by gwynwyffar; 17 Oct 2017 at 09:40 PM.
Perhaps could identify how your store is different from a default store... plugins, customizations, etc... as well as the other information recommended in the posting tips that wasn't yet covered.
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
WOW! great catch @lat9!
there is nothing the store owner can do to prevent this.
the store is in the NY state area. the IP address is from ukraine. it looks like someone is trying to do evil via a SQL injection.
the question exists whether this sort of attempt should generate a log in ZC or not. as there is nothing the store owner can do to prevent someone from manually manipulating the URL.
its funny, i have modified my function to handle issues like this. i did not post it earlier, as i can not remember why i did it. no doubt i did it to handle issues like this. here is my code. the section in red is the added part, and it certainly would address the error. feel free to use at your own discretion.
Code:function _sess_write($key, $val) { global $db; if (!is_object($db)) return; $val = base64_encode($val); global $SESS_LIFE; $expiry = time() + $SESS_LIFE; $sql = "insert into " . TABLE_SESSIONS . " (sesskey, expiry, `value`) values (:zkey, :zexpiry, :zvalue) ON DUPLICATE KEY UPDATE `value`=:zvalue, expiry=:zexpiry"; $sql = $db->bindVars($sql, ':zkey', $key, 'string'); $sql = $db->bindVars($sql, ':zexpiry', $expiry, 'integer'); $sql = $db->bindVars($sql, ':zvalue', $val, 'stringIgnoreNull'); if ($key != null) { $result = $db->Execute($sql); } return (!empty($result) && !empty($result->resource)); }