Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-06-27 10:45:02

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,018
Website GitHub

Anyone using smd_ipn: it needs a patch

Just spotted a problem with smd_ipn: the id column is too small to hold the full transaction ID. Luckily the complete transaction is stashed in the data block so it’s fairly trivial to pull it out and reseed the IDs. If you have a pre-release copy, you would be well advised to:

  1. backup your database (or at least the smd_ipn table)
  2. create a new hidden article in your regular articles section
  3. make sure to set the body to Leave text untouched
  4. paste in the following code
  5. preview the article to run the code; if you see the ‘ok’ message there’s a good chance everything is fine. Look at the Extensions->IPN Manager transaction table to verify that valid Transaction IDs are more than 12 chars long.
  6. delete the article
<txp:php>

// Fix width of id column from 12 to 20 chars
safe_alter('smd_ipn', 'CHANGE id id VARCHAR(20) NOT NULL');

// Fix the txn_id by pulling out the ID from the data blob and
// overwriting the id column

$rs = safe_rows('*', 'smd_ipn', '1=1');

foreach ($rs as $row) {
   $data = unserialize($row['data']);
   $full_txn = doSlash($data['txn_id']);
   $short_txn = doSlash($row['id']);
//   dmp($short_txn, $full_txn);
   safe_update('smd_ipn', "id='$full_txn'", "id='$short_txn'");
}

echo 'ok. smd_ipn patched.';

</txp:php>

The plugin can be fixed for future by changing the id column’s VARCHAR(12) to VARCHAR(20) in the code. It won’t affect plugin operation (the above patch fixes the existing table on-the-fly) but if you intend to uninstall and reinstall it at a later date, you might want to make that change too. Any problems give me a shout.

Thanks, and sorry for the inconvenience.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB