Jump to content
thirty bees forum

Server error on contact-us submit - Need help


x97wehner

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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

  • Thanks 1
Link to comment
Share on other sites

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 by x97wehner
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...