Category Archives: Uncategorized

AbleCommerce unable to process payment after initial rejection

If a payment for an anonymous order does not go through the first time for whatever reason (invalid card number, payment gateway timeout, etc.) subsequent attempts to submit a payment for that order will fail with the error:

Value cannot be null. Parameter name: request.Payment.Order.User

This is due to a bug in AbleCommerce that causes the user ID associated with the order to be removed. This is the correct action for anonymous orders that have been completed, but in this case order processing is not yet complete.

To work around the issue you have to dive into the database and add the anonymous user’s ID back to the order record. After this step has been done the next attempt to process a payment should proceed normally. This has to be done after each payment failure.

PHP’s built-in validation/sanitation … who knew?

So apparently PHP has built-in validation/sanitation? How come nobody ever told me?! And why are so many people writing email validation regex? Find a sample email validation in the PHP docs.

That being said, the built-in validation isn’t perfect. Run the outlier cases cited in Phil Haack’s email RFC article to see the few instances where PHP fails. Are you likely to run into these outliers in the wild? No, but it’d still be nice to have completely accurate validation. We may not produce perfect code, but we should at least strive for that.

You can test PHP’s built-in validation on functions-online. Compare how it does against Cal Henderson’s RFC822 Email Address Parser.

Keeping the OpenSUSE messages log tidy

Our linux server, an OpenSUSE 11 box, uses syslog-ng to capture log messages. By default syslog-ng is set up to report statistics every hour. Our servers, however, aren’t intended to be used as logging servers so the message handling statistics aren’t very useful. Plus, the statistics messages end up flooding the system log, making it difficult to parse the log for more relevant messages. To rectify the situation I disabled the stats messages by editing /etc/syslog-ng/syslog-ng.conf so that the global options read:

options { long_hostnames(off); sync(0); perm(0640); stats(0); };

The relevant option is stats(). The numerical value is based on seconds and so the default is 3600 (or once an hour). By setting the option to 0 no statistical message should be logged.