x97wehner Posted October 14, 2019 Posted October 14, 2019 Getting a 500 error when customer tries to submit the contact-us page. Console shows these two errors: Unable to get property 'SavePersonalAndPaymentData' of undefined or null reference Autoformfill_ContentScript.js (1,20660) HTTP500: SERVER ERROR - The server encountered an unexpected condition that prevented it from fulfilling the request. POST - <domain>/contact-us Can someone advise how to possibly resolve this? Not had this come up prior.
x97wehner Posted October 14, 2019 Author Posted October 14, 2019 (edited) in debug mode I get this error: "Property CustomerMessage->user_agent length (129) must be between 0 and 128 in file classes/ObjectModel.php at line 1058" - Not sure how to fix. Please help Edited October 14, 2019 by x97wehner
x97wehner Posted October 14, 2019 Author Posted October 14, 2019 Note: I rolled back to stable 1.1 and the issue is gone. Tested in a vanilla OOB and my live site. Seems to be something in one of the subsequent patches in the bleeding edge versioning that is causing the issue. 1
yaniv14 Posted October 15, 2019 Posted October 15, 2019 I don't think there should be a limit of 128 chars for user agent. But you can truncate the user agent to 128 chars like this: substr($_SERVER['HTTP_USER_AGENT'], 0, 128). Anyway I don't think that this kind of information is valuable to you because you probably use GA or other tools to collect this data.
datakick Posted October 15, 2019 Posted October 15, 2019 This error occurs because your browser user User Agent string is too large (129 characters) and database column can store only 128 characters. Current version of thirtybees silently ignores this, and database automatically truncate the string to 128 chars. In this particular case it's not really important, because who uses this field, right? But in general, this silent truncation is a bad thing, because it can lead to unwanted data loss. The question is what the right fix should look like we can increase column size for this field in CustomerMessage object model we can do explicit truncation as @yaniv14 suggested (probably better to use multibyte version of substr function) or we could introduce some new Object Model Field meta information to inform core that it's OK to automatically truncate the field, something like 'user_agent' => ['type' => self::TYPE_STRING, 'size' => 128, 'truncate' => true], I personally think #3 solution should be implemented. 1
x97wehner Posted October 15, 2019 Author Posted October 15, 2019 I don't have a good answer for how it should be. But I know that I've had multiple customers not be able to submit the contact-us form over the past couple days because of this error, so it certainly needs a timely resolution. Thanks.
musicmaster Posted October 15, 2019 Posted October 15, 2019 46 minutes ago, x97wehner said: I don't have a good answer for how it should be. But I know that I've had multiple customers not be able to submit the contact-us form over the past couple days because of this error, so it certainly needs a timely resolution. Thanks. Actually, if you followed the discussion there was a solution. You should replace the line $cm->user_agent = $_SERVER['HTTP_USER_AGENT']; with $cm->user_agent = substr($_SERVER['HTTP_USER_AGENT'],0,128); on line 178 in ContactController.php 1
x97wehner Posted October 15, 2019 Author Posted October 15, 2019 (edited) 17 minutes ago, musicmaster said: Actually, if you followed the discussion there was a solution. You should replace the line $cm->user_agent = $_SERVER['HTTP_USER_AGENT']; with $cm->user_agent = substr($_SERVER['HTTP_USER_AGENT'],0,128); on line 178 in ContactController.php Thanks, but was referring to @datakick's question as to which way is best for a TB dev to resolve it. Edited October 15, 2019 by x97wehner
musicmaster Posted October 15, 2019 Posted October 15, 2019 18 minutes ago, x97wehner said: Thanks, but was referring to @datakick's question as to which way is best for a TB dev to resolve it. @datakick was thinking aloud how this should be solved in the next TB release. That has limited relevance for the average maintainer of a TB shop.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now