From 54be6b1f622cf394f3cb2c7eb5f2c27072018baa Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 17 Jun 2014 22:24:45 +0200 Subject: [ticket/12692] Update the database regularly PHPBB3-12692 --- phpBB/phpbb/console/command/thumbnail/generate.php | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/console/command/thumbnail/generate.php') 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); + } } -- cgit v1.2.1