Jump to content

Bug Report about ContactController


JasonWang

Recommended Posts

Problem:

Submit a question on /contact-us page, which invokes the ContactController. The result says it's been sent successfully. In fact, the actual result is that the message has not been stored in the DB table "ps_customer_message". And no email was sent to anyone in the table "ps_contact".

 

Why:

On the line 152, this method returns false.

if (!$cm->add())

So, there will be one error in $this->errors.

And One the line 205, 

if (count($this->errors) > 1)
array_unique($this->errors);
else
$this->context->smarty->assign('confirmation', 1);

I couldn't believe my eyes. Even with one error, the $confirmation is still 1.

I think this should be 

if(count($this->errors) > 0)

Why add() returned false?

I tried everything to make this work out. I found if I modify the field "date_upd" in the table "ps_customer_message", to either cancel the "not null" property or set default value to 0, could make the add() return true.

 

I think it probably has something to do with the configuration of mysql. But I can't figure out what config should I change.

 

Anyone knows about this? Thanks in advance.

 

 

Link to comment
Share on other sites

Just a 'lucky guess', but can you try this:

 

in /classes/CustomerMessage, change the date_add validity check a little (add red code):

 

public static $definition = array(
'table' => 'customer_message',
'primary' => 'id_customer_message',
'fields' => array(
'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_customer_thread' => array('type' => self::TYPE_INT),
'ip_address' => array('type' => self::TYPE_STRING, 'validate' => 'isIp2Long', 'size' => 15),
'message' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 65000),
'file_name' => array('type' => self::TYPE_STRING),
'user_agent' => array('type' => self::TYPE_STRING),
'private' => array('type' => self::TYPE_INT),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'),
'read' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool')
),
);
 
 
Didn't check it myself, so please let us know if it does anything.
 
pascal.
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...