Browse Source

Mitigate $TorrentID = 0 bug on some uploads

pjc 5 years ago
parent
commit
4c4818c213
1 changed files with 14 additions and 6 deletions
  1. 14
    6
      sections/upload/upload_handle.php

+ 14
- 6
sections/upload/upload_handle.php View File

@@ -546,12 +546,20 @@ $Cache->increment('stats_torrent_count');
546 546
 $TorrentID = $DB->inserted_id();
547 547
 $Tor->Dec['comment'] = 'https://'.SITE_DOMAIN.'/torrents.php?torrentid='.$TorrentID;
548 548
 
549
-Tracker::update_tracker('add_torrent', [
550
-  'id'          => $TorrentID,
551
-  'info_hash'   => rawurlencode($InfoHash),
552
-  'freetorrent' => $T['FreeTorrent']
553
-]);
554
-$Debug->set_flag('upload: ocelot updated');
549
+# Mitigate $TorrentID = 0 bug on some uploads
550
+# @todo Investigate this further and properly fix
551
+if ($TorrentID !== 0) {
552
+  Tracker::update_tracker('add_torrent', [
553
+    'id'          => $TorrentID,
554
+    'info_hash'   => rawurlencode($InfoHash),
555
+    'freetorrent' => $T['FreeTorrent']
556
+  ]);
557
+  $Debug->set_flag('upload: ocelot updated');
558
+} else {
559
+  $TorrentID_debug = $DB->query = "SELECT MAX(ID) FROM torrents" + 1;
560
+  var_dump($TorrentID_debug);
561
+  error(0);
562
+}
555 563
 
556 564
 // Prevent deletion of this torrent until the rest of the upload process is done
557 565
 // (expire the key after 10 minutes to prevent locking it for too long in case there's a fatal error below)

Loading…
Cancel
Save