diff options
author | Tristan Darricau <github@nicofuma.fr> | 2014-06-17 22:24:45 +0200 |
---|---|---|
committer | Tristan Darricau <tristan.darricau@sensiolabs.com> | 2015-07-09 09:21:51 +0200 |
commit | 54be6b1f622cf394f3cb2c7eb5f2c27072018baa (patch) | |
tree | 292303b30e2ab13ed6d6fd51c02888884fbb85e6 /phpBB/phpbb/console/command/thumbnail/generate.php | |
parent | c96cc2cb05de05c9599ca27241e903ea6fada3a3 (diff) | |
download | forums-54be6b1f622cf394f3cb2c7eb5f2c27072018baa.tar forums-54be6b1f622cf394f3cb2c7eb5f2c27072018baa.tar.gz forums-54be6b1f622cf394f3cb2c7eb5f2c27072018baa.tar.bz2 forums-54be6b1f622cf394f3cb2c7eb5f2c27072018baa.tar.xz forums-54be6b1f622cf394f3cb2c7eb5f2c27072018baa.zip |
[ticket/12692] Update the database regularly
PHPBB3-12692
Diffstat (limited to 'phpBB/phpbb/console/command/thumbnail/generate.php')
-rw-r--r-- | phpBB/phpbb/console/command/thumbnail/generate.php | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/phpBB/phpbb/console/command/thumbnail/generate.php b/phpBB/phpbb/console/command/thumbnail/generate.php index 1070b7b37a..c27d91d4d5 100644 --- a/phpBB/phpbb/console/command/thumbnail/generate.php +++ b/phpBB/phpbb/console/command/thumbnail/generate.php @@ -106,6 +106,13 @@ class generate extends \phpbb\console\command\command if (create_thumbnail($source, $destination, $row['mimetype'])) { $thumbnail_created[] = (int) $row['attach_id']; + + if (sizeof($thumbnail_created) === 250) + { + $this->commit_changes($thumbnail_created); + $thumbnail_created = array(); + } + if ($input->getOption('verbose')) { $output->writeln($this->user->lang('THUMBNAIL_GENERATED', $row['real_filename'], $row['physical_filename'])); @@ -124,12 +131,22 @@ class generate extends \phpbb\console\command\command if (!empty($thumbnail_created)) { - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' - SET thumbnail = 1 - WHERE ' . $this->db->sql_in_set('attach_id', $thumbnail_created); - $this->db->sql_query($sql); + $this->commit_changes($thumbnail_created); } return 0; } + + /** + * Commits the changes to the database + * + * @param array $thumbnail_created + */ + protected function commit_changes(array $thumbnail_created) + { + $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' + SET thumbnail = 1 + WHERE ' . $this->db->sql_in_set('attach_id', $thumbnail_created); + $this->db->sql_query($sql); + } } |