We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit fea0b761 authored by clint's avatar clint

use a proper transaction block instead of a giant multiple-values insert

parent c5925ec9
......@@ -114,7 +114,7 @@ for($i = 0; $i < count($_POST['a']); $i++) {
if(!$exists) {
// Scrobble!
$rowvalues .= "("
$rowvalues[$actualcount] = "("
. $username . ", "
. $artist . ", "
. $album . ", "
......@@ -130,15 +130,31 @@ for($i = 0; $i < count($_POST['a']); $i++) {
if(($i+1) == count($_POST['a']) && $actualcount>0) {
$mdb2->exec("BEGIN");
for($j = 0; $j <= $actualcount; $j++) {
// Scrobble!
$sql = "INSERT INTO Scrobbles (username, artist, album, track, time, mbid, source, rating, length) VALUES" . $rowvalues;
$sql = "INSERT INTO Scrobbles (username, artist, album, track, time, mbid, source, rating, length) VALUES " . $rowvalues[$j];
$res =& $mdb2->exec($sql);
if(PEAR::isError($res)) {
$msg = $res->getMessage() . " - " . $res->getUserInfo();
$mdb2->exec("ROLLBACK");
reportError($msg, $sql);
die("FAILED " . $msg . "\nError has been reported to site administrators.\n");
die("FAILED " . $msg . "\nError has been reported to site administrators.\n");
}
}
$mdb2->exec("COMMIT");
if(PEAR::isError($res)) {
$msg = $res->getMessage() . " - " . $res->getUserInfo();
$mdb2->exec("ROLLBACK");
reportError($msg, $sql);
die("FAILED " . $msg . "\nError has been reported to site administrators.\n");
}
// Destroy now_playing since it is almost certainly obsolescent
$mdb2->exec("DELETE FROM Now_Playing WHERE sessionid = " . $session_id);
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment