From eae392798b07e981b344816b5c3f7b1268276836 Mon Sep 17 00:00:00 2001
From: Graham Cole <chckens@sucs.org>
Date: Sat, 26 Jan 2008 18:04:36 +0000
Subject: [PATCH] remove buggy method for obtaining ID of just-pasted item.
 closes #55

---
 components/pastebin.php | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/components/pastebin.php b/components/pastebin.php
index 6cdb785..dbf9154 100755
--- a/components/pastebin.php
+++ b/components/pastebin.php
@@ -163,12 +163,11 @@ if (isset($_POST['code'])) {
 		} else {
 			// Additional user validation needed here
 			//$retainTil = date('Y/m/d H:i:s', time() + $retain);
+			$id = $DB->GetOne("SELECT nextval('pastebin_id_seq'::regclass)");
 			$DB->Execute(
-				'INSERT INTO ' . _TABLE_NAME . ' ( code, username, retain_til, language) ' .
-				'VALUES (?, ?, ?, ?)', 
-				array( $code, $session->username, $retainTil, $pblang));
-			//$id = $DB->Insert_ID();
-			$id = $DB->GetOne('SELECT id FROM ' . _TABLE_NAME . ' WHERE code = ? AND username = ? AND retain_til = ?', array($code,$session->username,$retainTil));
+				'INSERT INTO ' . _TABLE_NAME . ' ( id, code, username, retain_til, language) ' .
+				'VALUES (?, ?, ?, ?, ?)', 
+				array( $id, $code, $session->username, $retainTil, $pblang));
 			$userInfo = 'Created By ' . $session->username . ' at ' . date('Y/m/d H:i');
 			$smarty->assign('id', $id);
 			$smarty->assign('userInfo', $userInfo);
-- 
GitLab