Jump to content
thirty bees forum

Server error on contact-us submit - Need help


Recommended Posts

Posted

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.

Posted (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

image.thumb.png.524c3e18b00fb11599f989e2d9f96352.png

 

Edited by x97wehner
Posted

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.

  • Like 1
Posted

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.

Posted

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
Posted

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.

Posted
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
Posted (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 by x97wehner
Posted
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.

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...