diff --git a/misc/update_scripts/update_binaries.php b/misc/update_scripts/update_binaries.php index 0046e5a60..9273f525d 100644 --- a/misc/update_scripts/update_binaries.php +++ b/misc/update_scripts/update_binaries.php @@ -6,22 +6,26 @@ use newznab\db\Settings; $pdo = new Settings(); +$maxHeaders = $pdo->getSetting('max.headers.iteration') ?: 1000000; + // Create the connection here and pass $nntp = new \NNTP(['Settings' => $pdo]); if ($nntp->doConnect() !== true) { exit($pdo->log->error("Unable to connect to usenet.")); } -$binaries = new \Binaries(['NNTP' => $nntp, 'Settings' => $pdo]); +$binaries = new Binaries(['NNTP' => $nntp, 'Settings' => $pdo]); if (isset($argv[1]) && !is_numeric($argv[1])) { $groupName = $argv[1]; echo $pdo->log->header("Updating group: $groupName"); - $grp = new \Groups(['Settings' => $pdo]); + $grp = new Groups(['Settings' => $pdo]); $group = $grp->getByName($groupName); if (is_array($group)) { - $binaries->updateGroup($group, (isset($argv[2]) && is_numeric($argv[2]) && $argv[2] > 0 ? $argv[2] : 0)); + $binaries->updateGroup($group, + (isset($argv[2]) && is_numeric($argv[2]) && $argv[2] > 0 ? $argv[2] : $maxHeaders)); } } else { - $binaries->updateAllGroups((isset($argv[1]) && is_numeric($argv[1]) && $argv[1] > 0 ? $argv[1] : 0)); + $binaries->updateAllGroups((isset($argv[1]) && is_numeric($argv[1]) && $argv[1] > 0 ? $argv[1] : + $maxHeaders)); } \ No newline at end of file diff --git a/newznab/build/newznab.xml b/newznab/build/newznab.xml index 822db5676..f7a4bce8b 100644 --- a/newznab/build/newznab.xml +++ b/newznab/build/newznab.xml @@ -2,8 +2,8 @@ - 157 - 157 + 158 + 158 0.4.1 diff --git a/newznab/controllers/Tmux.php b/newznab/controllers/Tmux.php index 912557fef..acaf384af 100644 --- a/newznab/controllers/Tmux.php +++ b/newznab/controllers/Tmux.php @@ -460,7 +460,7 @@ class Tmux public function stopIfRunning() { if ($this->isRunning() == 1) { - $this->pdo->queryExec("UPDATE tmux SET value = '0' WHERE setting = 'RUNNING'"); + $this->pdo->queryExec("UPDATE tmux SET value = '0' WHERE setting = 'running'"); $sleep = $this->get()->monitor_delay; echo $this->pdo->log->header("Stopping tmux scripts and waiting $sleep seconds for all panes to shutdown"); sleep($sleep); @@ -472,7 +472,7 @@ class Tmux public function startRunning() { if (!$this->isRunning()) { - return $this->pdo->queryExec("UPDATE tmux SET value = '1' WHERE setting = 'RUNNING'"); + return $this->pdo->queryExec("UPDATE tmux SET value = '1' WHERE setting = 'running'"); } return true; } diff --git a/newznab/libraries/Cache.php b/newznab/libraries/Cache.php index ada237079..d1263e123 100644 --- a/newznab/libraries/Cache.php +++ b/newznab/libraries/Cache.php @@ -36,12 +36,6 @@ class Cache */ private $socketFile; - /** - * Does the user have igBinary support and wants to use it? - * @var bool - */ - private $IgBinarySupport = false; - /** * Store data on the cache server. * @@ -55,7 +49,6 @@ class Cache public function set($key, $data, $expiration) { if ($this->ping()) { - $this->serializeData($data); switch (NN_CACHE_TYPE) { case self::TYPE_REDIS: case self::TYPE_MEMCACHED: @@ -67,30 +60,6 @@ class Cache return false; } - /** - * Serialize data, or not based on admin setting. - * - * @param string|array $data - */ - private function serializeData(&$data) - { - switch (NN_CACHE_SERIALIZER) { - case self::SERIALIZER_IGBINARY: - if ($this->IgBinarySupport) { - $data = igbinary_serialize($data); - } else { - $data = serialize($data); - } - break; - case self::SERIALIZER_PHP: - $data = serialize($data); - break; - case self::SERIALIZER_NONE: - default: - break; - } - } - /** * Attempt to retrieve a value from the cache server, if not set it. * @@ -112,36 +81,11 @@ class Cache $data = apc_fetch($key); break; } - $this->unserializeData($data); return $data; } return false; } - /** - * Un-serialize data, or not based on admin setting. - * - * @param string $data - */ - private function unserializeData(&$data) - { - switch (NN_CACHE_SERIALIZER) { - case self::SERIALIZER_IGBINARY: - if ($this->IgBinarySupport) { - $data = igbinary_unserialize($data); - } else { - $data = unserialize($data); - } - break; - case self::SERIALIZER_PHP: - $data = unserialize($data); - break; - case self::SERIALIZER_NONE: - default: - break; - } - } - /** * Delete data tied to a key on the cache server. * @@ -272,8 +216,9 @@ class Cache break; case self::TYPE_APC: - if (!function_exists('apc_set')) { - throw new CacheException('The APC extension is not loaded!'); + // Faster than checking if apcu or apc is loaded. + if (!function_exists('apc_add')) { + throw new CacheException('The APCu extension is not loaded or enabled!'); } $this->connect(); break; @@ -395,14 +340,17 @@ class Cache switch (NN_CACHE_TYPE) { case self::TYPE_REDIS: - // No way to check since phpredis has no constants or functions for this. + // If this is not defined, it means phpredis was not compiled with --enable-redis-igbinary + if (!defined('\Redis::SERIALIZER_IGBINARY')) { + throw new CacheException('Error: phpredis was not compiled with igbinary support!'); + } return \Redis::SERIALIZER_IGBINARY; case self::TYPE_MEMCACHED: if (\Memcached::HAVE_IGBINARY > 0) { return \Memcached::SERIALIZER_IGBINARY; } throw new CacheException('Error: You have not compiled Memcached with igbinary support!'); - case self::TYPE_APC: // No way to check, since apc.serializer can not be fetched using ini_get. + case self::TYPE_APC: // Ignore - set by apc.serializer setting. default: return null; } diff --git a/resources/db/patches/0158~settings.sql b/resources/db/patches/0158~settings.sql new file mode 100644 index 000000000..cfaf66dda --- /dev/null +++ b/resources/db/patches/0158~settings.sql @@ -0,0 +1,9 @@ +INSERT IGNORE INTO settings (section, subsection, name, value, hint, setting) +VALUES ( +'max', +'headers', +'iteration', +1000000, +'The maximum number of headers that update binaries sees as the total range. This ensure that a total of no more than this is attempted to be downloaded at one time per group.', +'max.headers.iteration' +); \ No newline at end of file