ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.LSOMigratePageIdsExtro.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
23
25{
26 private const DEFAULT_AMOUNT_OF_STEPS = 1000;
27 private const QUERY = "SELECT page_id, parent_id, parent_type, count(page_id) AS cnt" . PHP_EOL
28 . "FROM page_object" . PHP_EOL
29 . "WHERE page_id = (parent_id * -2)" . PHP_EOL
30 . "AND parent_type = 'cont'";
31
33
34 public function getLabel(): string
35 {
36 return "Update IDs of extro pages";
37 }
38
40 {
42 }
43
44 public function getPreconditions(Environment $environment): array
45 {
46 return [
48 ];
49 }
50
51 public function prepare(Environment $environment): void
52 {
53 $this->db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
54 }
55
59 public function step(Environment $environment): void
60 {
61 $result = $this->db->query(self::QUERY . ' LIMIT 1');
62 $row = $this->db->fetchAssoc($result);
63 $query = 'UPDATE page_object' . PHP_EOL
64 . "SET page_id = parent_id, parent_type = 'lsoe'" . PHP_EOL
65 . "WHERE page_id = " . $row['page_id'] . PHP_EOL
66 . "AND parent_id = " . $row['parent_id'] . PHP_EOL
67 . "AND parent_type = " . $this->db->quote($row['parent_type'], 'text');
68 $this->db->manipulate($query);
69 }
70
71 public function getRemainingAmountOfSteps(): int
72 {
73 $result = $this->db->query(self::QUERY);
74 $row = $this->db->fetchAssoc($result);
75
76 return (int) $row['cnt'];
77 }
78}
step(Environment $environment)
prepare(Environment $environment)
getPreconditions(Environment $environment)
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
A migration is a potentially long lasting operation that can be broken into discrete steps.
Definition: Migration.php:29
Interface ilDBInterface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...