Forums / General Questions / Problem or not? Incorrect integer value for column customer_notified

Problem or not? Incorrect integer value for column customer_notified

Views: 4,312

Results 1 to 19 of 19
12 Mar 2015, 4:14 AM
#1
robax avatar

robax

Zen Follower

Join Date:
Mar 2006
Posts:
187
Plugin Contributions:
0

Problem or not? Incorrect integer value for column customer_notified

Hello chaps

I'm trying to figure out if the following error in the debug log is a fault that I need to fix, or if I can ignore it.

[12-Mar-2015 14:11:06 Australia/Sydney] PHP Fatal error: 1366:Incorrect integer value: '' for column 'customer_notified' at row 1 ::
INSERT INTO orders_status_history (orders_id, orders_status_id, date_added, comments, customer_notified)
VALUES ('4286', '1', now(), 'PayPal status: Refunded @ 21:17:30 Mar 09, 2015 PDT Parent Trans ID:xxxxxxxxxxxxxx Trans ID:xxxxxxxxxxxxxx Amount: -161.75 AUD', '')
in C:\inetpub\wwwroot\xxxxxxxxxxxxxx\includes\classes\db\mysql\query_factory.php on line 120

It looks like it doesn't like the value to be empty, but I'm no PHP/MySQL expert so I don't really know.

I can't see any issues in the store admin. I only noticed this one in the logs. It appears to be a PayPal refund. Is this likely to be a problem or can I safely ignore it?

Thanks for any advice on this.
Rob

These are the details of my website:

Zen Cart 1.5.1
Database Patch Level: 1.5.1
v1.5.1 [2013-10-25 16:43:45] (Version Update 1.5.0->1.5.1)
v1.5.0 [2013-10-25 16:43:45] (Version Update 1.3.9->1.5.0)
v1.3.9b [2010-05-18 18:34:34] (Version Update 1.3.8->1.3.9b)
v1.3.8 [2008-07-30 02:07:56] (Fresh Installation)

It uses the PayPal Express checkout and has some unrelated plugins such as the one for image resizing and OZPost for shipping.

Other info that may or may not matter:
Server Host: xxxxxxxx Database Host: 127.0.0.1 (127.0.0.1)
Server OS: Windows NT SV8774 6.2 build 9200 (Unknow Windows version Standard Edition) i586 Database: MySQL 5.5.42
HTTP Server: Microsoft-IIS/8.5
PHP Version: 5.3.28 (Zend: 2.3.0) PHP Memory Limit: 128M PHP Safe Mode: Off
PHP File Uploads: On Max Size: 2M POST Max Size: 8M
Database Data Size: 73,089 kB Database Index Size: 3,227 kB

12 Mar 2015, 8:26 AM
#2
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Problem or not? Incorrect integer value for column customer_notified

robax:

I'm trying to figure out if the following error in the debug log is a fault that I need to fix, or if I can ignore it.

This one shouldn't be ignored because it means you'll be losing some valuable information from your orders history.

Do you want the good news or the bad news first?

OK, the good news. This problem isn't unique to you. I've experienced (and fixed) the exact same issue.

The bad news. I can't find or recall exactly what I did to fix it. I've searched my code to see if I can see any changes I made for this, but didn't find anything (it may be one of those rare times I forgot to leave myself any comments in the code), but on the other hand, I think I may have fixed it by modifying the orders_status_history table structure so that it allows NULLS.

I have verified that this is indeed how my database is configured, but I don't know if that is/was the default setting, or the setting I ended up changing.

Hopefully someone else that has come across this issue has a more definitive answer.

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

12 Mar 2015, 11:33 AM
#3
robax avatar

robax

Zen Follower

Join Date:
Mar 2006
Posts:
187
Plugin Contributions:
0

Re: Problem or not? Incorrect integer value for column customer_notified

Hi Rod

Yes, that makes good sense.

I've checked that table here in MySQL Workbench and can see the information in the screenshot for the column.

Strangely it says 'Yes' in the Nullable column. Do you recall if yours looks like this?

Regards
Rob

12 Mar 2015, 12:01 PM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,725
Plugin Contributions:
56

Re: Problem or not? Incorrect integer value for column customer_notified

Right before the insert, do something like this:

if ($customer_notified === '') { 
   $customer_notified = -1;
}

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

12 Mar 2015, 5:02 PM
#5
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Problem or not? Incorrect integer value for column customer_notified

robax:

I've checked that table here in MySQL Workbench and can see the information in the screenshot for the column.
Strangely it says 'Yes' in the Nullable column. Do you recall if yours looks like this?

Yes, that is identical to mine. (So much for that idea).

I've also checked to see if my fix was the same as that mentioned by swguy (which seems to ring a bell, and even looks like it would be the same kind of fix I'd apply myself), but I've done another search of my code and can't find anything along those lines either.

It was my intent to identify a similar change in my own code so that I could tell you exactly which file & place you need to add this fix. Alas, I can't even do that. :-(

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

13 Mar 2015, 11:04 AM
#6
robax avatar

robax

Zen Follower

Join Date:
Mar 2006
Posts:
187
Plugin Contributions:
0

Re: Problem or not? Incorrect integer value for column customer_notified

swguy:

Right before the insert, do something like this:

if ($customer_notified === '') {
$customer_notified = -1;
}



Thanks for this SWGuy

I've taken a wild guess after searching via the developer tools at where to put this and have inserted it in:
\admin\orders.php at line 175

That makes it look like this:


	  if ($customer_notified === '') { 
	  $customer_notified = -1;
	  }

      $db->Execute("insert into " . TABLE_ORDERS_STATUS_HISTORY . "
                  (orders_id, orders_status_id, date_added, customer_notified, comments)
                  values ('" . (int)$oID . "',
                  '" . zen_db_input($status) . "',
                  now(),
                  '" . zen_db_input($customer_notified) . "',
                  '" . zen_db_input($comments)  . "')");
      $order_updated = true;
    }


Does that look about right?

Thanks for a look!
Regards
Rob
13 Mar 2015, 11:07 AM
#7
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,725
Plugin Contributions:
56

Re: Problem or not? Incorrect integer value for column customer_notified

You betcha! Give it a whirl!

(My guess wrt the root cause of this issue would be a failed merge of a mod to the admin/orders.php file - this doesn't happen in a new download. But this workaround should suffice for now.)

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

13 Mar 2015, 11:10 AM
#8
robax avatar

robax

Zen Follower

Join Date:
Mar 2006
Posts:
187
Plugin Contributions:
0

Re: Problem or not? Incorrect integer value for column customer_notified

Excellent.. I'll make a note to watch this file on the next upgrade.
Thanks heaps for this!

And thanks for your comments too Rod.
Rob

20 Mar 2015, 2:22 AM
#9
robax avatar

robax

Zen Follower

Join Date:
Mar 2006
Posts:
187
Plugin Contributions:
0

Re: Problem or not? Incorrect integer value for column customer_notified

hmm poop

I'm still seeing this error in the logs. It seems to be related to PayPal refunds.

[20-Mar-2015 12:33:42 Australia/Sydney] PHP Fatal error: 1366:Incorrect integer value: '' for column 'customer_notified' at row 1 :: INSERT INTO orders_status_history (orders_id, orders_status_id, date_added, comments, customer_notified) VALUES ('4125', '1', now(), 'PayPal status: Refunded @ 18:32:39 Mar 19, 2015 PDT
Parent Trans ID:xxxxxxxxxxxxxxxx
Trans ID:xxxxxxxxxxxxxxxxxxxx
Amount: -9.25 AUD', '') in C:...............\includes\classes\db\mysql\query_factory.php on line 120

It looks like the error is recorded a number of times in a day and then it stops. Like it's on a schedule.

In fact, I can see rows on the PayPal IPN tab within Zen Cart that correspond to the errors.

It looks like there are about 16 entries for each refund. I would guess that PayPal limits the number of times it sends these.

It does look like the refunds work at PayPal, but are not recorded in the cart because I can't see any notes on the order saying so.

This store has been running for several years and the owner (my sister) has never said anything is wrong, but she might not know, and if the refunds are going back to the customer then that's fine.

So this time I downloaded a fresh ZC 1.5.1 zip and compared the file system. Everything appears to be intact, with only the OZPost module and various language changes showing up in WinMerge.

It is the case that my db is upgraded from as early as ZC 1.3.8.

So.. could this be something to do with upgrades over time, or possibly a PayPal configuration issue? I'm assuming that if it records the error as above, then it must be coming back to the right place from PayPal.. otherwise it'd record nothing at all.

Any idea are appreciated.
Regards
Rob

20 Mar 2015, 4:30 PM
#10
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Problem or not? Incorrect integer value for column customer_notified

robax:

hmm poop
I'm still seeing this error in the logs. It seems to be related to PayPal refunds.

That 'fix' that swguy gave... You'll need to apply the same fix to other parts of the code that contain the

$db->Execute("insert into " . TABLE_ORDERS_STATUS_HISTORY
``` code call. 

> **robax:**
>
> It looks like the error is recorded a number of times in a day and then it stops. Like it's on a schedule. 

Just to be perfectly clear here, are you saying that these events DO NOT coincide with you (the store admin) submitting a PayPal Refund request?   

> **robax:**
>
> It looks like there are about 16 entries for each refund. I would guess that PayPal limits the number of times it sends these.
> 
> It does look like the refunds work at PayPal, but are not recorded in the cart because I can't see any notes on the order saying so.

If you don't know anything about trying to provide PayPal refunds, this is starting to now look like you are seeing a possible hack/exploit attempt. 

> **robax:**
>
> This store has been running for several years and the owner (my sister) has never said anything is wrong, but she might not know, and if the refunds are going back to the customer then that's fine.

But if those refunds shouldn't be going to *any* customer, then that's not fine.  

> **robax:**
>
> So this time I downloaded a fresh ZC 1.5.1 zip and compared the file system. Everything appears to be intact, with only the OZPost module and various language changes showing up in WinMerge.

This will be the case if the V1.5.1 code has this bug/problem (which may or may not be fixed in V1.5.4) 

> **robax:**
>
> It is the case that my db is upgraded from as early as ZC 1.3.8.
> 
> So.. could this be something to do with upgrades over time,

No. 

> **robax:**
>
> or possibly a PayPal configuration issue?

No. 

> **robax:**
>
> I'm assuming that if it records the error as above, then it must be coming back to the right place from PayPal.. otherwise it'd record nothing at all.

I had initially assumed that the events being logged would coincide with PP refunds being given, but based on these latest comments I'm assuming that this is probably some kind of exploit attempt, and for me, that changes things a lot.  So much so that it is theoretically possible you may not even **want** to fix this bug on the basis that the fix may turn the failed exploit into a successful one. 

As for the error being triggered and logged, my thoughts are that this is caused with one of the PHP/MySQL updates that have become a lot more restrictive in what rules can be 'broken' with no ill effect (such as the ability to use a NULL where an INT is expected).  IOW, developers now need to take a little bit more care about validating user inputs before using them.  

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

20 Mar 2015, 9:03 PM
#11
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Problem or not? Incorrect integer value for column customer_notified

RodG:

That 'fix' that swguy gave... You'll need to apply the same fix to other parts of the code that contain the

$db->Execute("insert into " . TABLE_ORDERS_STATUS_HISTORY

> 
>  
> 
> Just to be perfectly clear here, are you saying that these events DO NOT coincide with you (the store admin) submitting a PayPal Refund request?   
> 
> 
> 
> If you don't know anything about trying to provide PayPal refunds, this is starting to now look like you are seeing a possible hack/exploit attempt. 
> 
> 
> 
> But if those refunds shouldn't be going to *any* customer, then that's not fine.  
> 
> 
> 
> This will be the case if the V1.5.1 code has this bug/problem (which may or may not be fixed in V1.5.4) 
> 
> 
> 
> No. 
> 
> 
> 
> No. 
> 
> 
> 
> I had initially assumed that the events being logged would coincide with PP refunds being given, but based on these latest comments I'm assuming that this is probably some kind of exploit attempt, and for me, that changes things a lot.  So much so that it is theoretically possible you may not even **want** to fix this bug on the basis that the fix may turn the failed exploit into a successful one. 
> 
> As for the error being triggered and logged, my thoughts are that this is caused with one of the PHP/MySQL updates that have become a lot more restrictive in what rules can be 'broken' with no ill effect (such as the ability to use a NULL where an INT is expected).  IOW, developers now need to take a little bit more care about validating user inputs before using them.  
> 
> Cheers
> RodG

I was thinking that perhaps the "16" reoccurrences were like ipn updates that were failing and therefore notification of the initial refund was being tried again. But as well, can see the concern that possibly it is an attempted exploit... Maybe a way to filter to allow just one of the notifications to go through (small price or something) by some unique identifier to see the total result?

Or better yet, try installing lat9s mydebug backtrace plugin... The error messages should provide much more granularity of what section(s) of code are causing the error by identifying where the sql is that is "not correct".

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

21 Mar 2015, 9:57 AM
#12
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Problem or not? Incorrect integer value for column customer_notified

mc12345678:

I was thinking that perhaps the "16" reoccurrences were like ipn updates that were failing and therefore notification of the initial refund was being tried again.

You're probably right about the retries. but regardless of whether it was just one failed refund update or a hundred of them, the fact that they are occurring at all (and are not being instigated by the store owner) is cause for concern in this instance 'cos if it is an exploit attempt (and I'm a long way from being convinced it is) the error log would suggest that they had far more access to the DB than a hacker should have gotten.

Cheers
Rod.

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

24 Mar 2015, 7:45 AM
#13
robax avatar

robax

Zen Follower

Join Date:
Mar 2006
Posts:
187
Plugin Contributions:
0

Re: Problem or not? Incorrect integer value for column customer_notified

Thanks for the replies Rod and 'mc'

The refunds do correspond to a refund made by the store operator through the ZC admin. What I'm seeing with the repeated records in the debug logs are IPNs from PayPal telling the cart to record the refund. And it will likely send the IPN for a limited number of times, same as the IPN for payment fail/success is done.

The refund is not recorded in the order in Zen cart, although it does happen at PayPal. I think the error message about the incorrect integer value is probably correct and don't think it's a hack, but then I'm the fix should have worked as well.

I've searched the files for all instances of "TABLE_ORDERS_STATUS_HISTORY" and then looked for any instances associated with inserts into the table. This only exists in the orders.php which is the one I've already edited and then in the authorize.net and linkpoint gateways, which are not enabled and so I haven't edited them.

I don't really know PHP, but I'm going to see if putting '' around the -1 value in swguy's fix will make any difference. I noticed that the same line of code very nearby in orders.php has quotes around the value.

		  if ($customer_notified === '') { 
		  $customer_notified = '-1';
		  }

I'll see what happens.
Regards
ROb

24 Mar 2015, 12:11 PM
#14
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Problem or not? Incorrect integer value for column customer_notified

robax:

The refunds do correspond to a refund made by the store operator through the ZC admin.

<phew> This *is* what I was expecting to be the case though.

robax:

What I'm seeing with the repeated records in the debug logs are IPNs from PayPal telling the cart to record the refund. And it will likely send the IPN for a limited number of times, same as the IPN for payment fail/success is done.

The refund is not recorded in the order in Zen cart,

The refund not being recorded and the repeated attempts are probably both the result of the fatal PHP error.

robax:

I've searched the files for all instances of "TABLE_ORDERS_STATUS_HISTORY" and then looked for any instances associated with inserts into the table. This only exists in the orders.php which is the one I've already edited and then in the authorize.net and linkpoint gateways, which are not enabled and so I haven't edited them.

There are others.
/ipn_main_handler.phpline #344

        zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
        if (MODULE_PAYMENT_PAYPAL_ADDRESS_OVERRIDE == '1') {
          $sql_data_array['comments'] = '**** ADDRESS OVERRIDE ALERT!!! **** CHECK PAYPAL ORDER DETAILS FOR ACTUAL ADDRESS SELECTED BY CUSTOMER!!';
          $sql_data_array['customer_notified'] = -1;
          zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

/includes/modules/payment/paypal/paypal_functions.php
line#643

$sql_data_array = array('orders_id' => (int)$ordersID,
                            'orders_status_id' => (int)$new_status,
                            'date_added' => 'now()',
                            'comments' => 'PayPal status: ' . $_POST['payment_status'] . ' ' . ' @ ' . $_POST['payment_date'] . (($_POST['parent_txn_id'] !='') ? "\n" . ' Parent Trans ID:' . $_POST['parent_txn_id'] : '') . "\n" . ' Trans ID:' . $_POST['txn_id'] . "\n" . ' Amount: ' . $_POST['mc_gross'] . ' ' . $_POST['mc_currency'],
[B]                            'customer_notified' => 0[/B]
                           );
    zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

/includes/modules/payment/paypaldp.php
line# 1344
```
$sql_data_array = array('orders_id' => (int)$oID,
'orders_status_id' => (int)$new_order_status,
'date_added' => 'now()',
'comments' => 'VOIDED. Trans ID: ' . urldecode($response['AUTHORIZATIONID']). $response['PNREF'] . (isset($response['PPREF']) ? "\nPPRef: " . $response['PPREF'] : '') . "\n" . $voidNote,
'customer_notified' => 0
);
zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);


/includes/modules/payment/paypalwpp.php
line#813
       ```
 $sql_data_array = array('orders_id' => $oID,
                                'orders_status_id' => (int)$new_order_status,
                                'date_added' => 'now()',
                                'comments' => 'REFUND INITIATED. Trans ID:' . $response['REFUNDTRANSACTIONID'] . $response['PNREF']. "\n" . /*' Net Refund Amt:' . urldecode($response['NETREFUNDAMT']) . "\n" . ' Fee Refund Amt: ' . urldecode($response['FEEREFUNDAMT']) . "\n" . */' Gross Refund Amt: ' . urldecode($response['GROSSREFUNDAMT']) . (isset($response['PPREF']) ? "\nPPRef: " . $response['PPREF'] : '') . "\n" . $refundNote,
[B]                                'customer_notified' => 0 [/B]
                             );
        zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

I've bolded Two lines in the codes above because I happened to spot that this was different in the code from two different sites. I don't know if this was a change made by the zencart team, or whether its the change I made to resolve the same issue that you are having. In any case, the change was making the '0' into a 'false' (in the 1st instance) and the '0' to a '-1' (in the second instance).
As far as PHP in concerned a 'false' and a -1 are the same value.

robax:

I don't really know PHP, but I'm going to see if putting '' around the -1 value in swguy's fix will make any difference. I noticed that the same line of code very nearby in orders.php has quotes around the value.

      if ($customer_notified === '') { 
      $customer_notified = '-1';
      }
> 
> I'll see what happens.
> Regards
> ROb

Because the database defines the customer_notified field as being an integer then it is best/safer to NOT enclose this data with quotes.  In *most* cases it won't make a difference either way. 

I am a little bit concerned about the if ($customer_notified === '') check though, because the triple === is explicitly checking for an empty string '', which may or may not match if the $customer_notified variable is undefined or a NULL string.  
Since you probably wish to match either/all of these, then a double == would probably be a better option.  

Anyway, based on the error log that you provided earlier, the only place that I can see that would cause this exact error would be via the  /includes/modules/payment/paypal/paypal_functions.php file.  
line#647  'customer_notified' => 0 
change to  'customer_notified' => false

I'm not convinced that this *will* fix your problem (because a 0 should be an acceptable value), but this change has apparently been made (either by myself, or the zencart team, for a reason) and it seems a little bit too coincidental that this is right around the area that you are having a problem. 

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

27 Sep 2015, 3:51 AM
#15
fravac avatar

fravac

New Zenner

Join Date:
Jun 2015
Posts:
42
Plugin Contributions:
0

Re: Problem or not? Incorrect integer value for column customer_notified

I am having the same issue with 1.54.

I'm not php literate but I found this statement in paypal_functions.php

line 647 'customer_notified' => false.

I changed the false to 0, did a quick refund of a penny as a test and now my refund is posting back from paypal.

27 Sep 2015, 5:51 AM
#16
robax avatar

robax

Zen Follower

Join Date:
Mar 2006
Posts:
187
Plugin Contributions:
0

Re: Problem or not? Incorrect integer value for column customer_notified

Thank you for getting stuck into this issue as you have Rod. It slipped down my inbox but came back to me just now when another user fravec replied.

I checked the paypal_functions.php file and mine, like flavec's, had false at line 647 and so I've changed it to 0 to see what happens.

It's possible, as you point out, that you had already fixed the setting on your site and that the zero you have in there is the corrected file.

I'll put a note in my calendar to check again in a few days and report back here what happens.

Thanks heaps, and thanks flavec too for putting your post in.
Regards
ROb

27 Sep 2015, 11:59 AM
#17
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,116
Plugin Contributions:
56

Re: Problem or not? Incorrect integer value for column customer_notified

I'd also suggest installing myDEBUG Backtrace (https://www.zen-cart.com/downloads.php?do=file&id=1879) just in case the issue crops up again. That plugin will enhance the debug-log output to include additional information that will help to determine the source of the issue.

30 Sep 2015, 6:27 AM
#19
robax avatar

robax

Zen Follower

Join Date:
Mar 2006
Posts:
187
Plugin Contributions:
0

Re: Problem or not? Incorrect integer value for column customer_notified

Ok, I see.. this is just some goofy db issue.

Well, I can happily say this it appears to be resolved now. My sister's site is no longer logging any errors after changing the value to 0.

Thanks Rod and everyone for persevering and good to see Dr Byte has changed it in a later release.

Regards
ROb