Merge pull request #5951 from WoltLab/upload-form-field-v2
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / worker / MediaRebuildDataWorker.class.php
1 <?php
2
3 namespace wcf\system\worker;
4
5 use wcf\data\media\MediaAction;
6 use wcf\data\media\MediaList;
7 use wcf\system\exception\SystemException;
8
9 /**
10 * Worker implementation for updating media thumbnails.
11 *
12 * @author Alexander Ebert
13 * @copyright 2001-2019 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 *
16 * @method MediaList getObjectList()
17 */
18 class MediaRebuildDataWorker extends AbstractRebuildDataWorker
19 {
20 /**
21 * @inheritDoc
22 */
23 protected $objectListClassName = MediaList::class;
24
25 /**
26 * @inheritDoc
27 */
28 protected $limit = 10;
29
30 /**
31 * @inheritDoc
32 */
33 protected function initObjectList()
34 {
35 parent::initObjectList();
36
37 $this->objectList->sqlOrderBy = 'media.mediaID';
38 $this->objectList->getConditionBuilder()->add('media.isImage = ?', [1]);
39 }
40
41 /**
42 * @inheritDoc
43 */
44 public function execute()
45 {
46 parent::execute();
47
48 foreach ($this->objectList as $media) {
49 try {
50 (new MediaAction([$media], 'generateThumbnails'))->executeAction();
51 } catch (SystemException $e) {
52 }
53 }
54 }
55 }