19 declare(strict_types=1);
50 return self::NUMBER_OF_STEPS;
63 $this->prepared_statement = $this->db->prepareManip(
64 'UPDATE il_cert_user_cert SET certificate_id = ?, template_values = ? WHERE id = ?',
72 $this->uuid_factory =
new Factory();
81 $this->db->setLimit(self::NUMBER_OF_CERTS_PER_STEP);
82 $result = $this->db->query(
83 'SELECT id, template_values FROM il_cert_user_cert WHERE certificate_id = ' .
87 while ($row = $this->db->fetchAssoc($result)) {
89 $template_values = json_decode(
90 $row[
'template_values'] ?? json_encode([], JSON_THROW_ON_ERROR),
96 $template_values = [];
98 $certificate_id = $this->uuid_factory->uuid4AsString();
100 $template_values[
'CERTIFICATE_ID'] = $certificate_id;
102 $this->db->execute($this->prepared_statement, [
104 json_encode($template_values, JSON_THROW_ON_ERROR),
115 $this->db->addUniqueConstraint(
'il_cert_user_cert', [
'certificate_id'],
'c1');
123 $result = $this->db->query(
124 'SELECT COUNT(id) AS missing_cert_id FROM il_cert_user_cert WHERE certificate_id = ' .
127 $row = $this->db->fetchAssoc($result);
129 $remaining_certs = (
int) $row[
'missing_cert_id'];
130 if ($remaining_certs === 0) {
134 return (
int) ceil($remaining_certs / self::NUMBER_OF_CERTS_PER_STEP);
prepare(Environment $environment)
Prepare the migration by means of some environment.
A migration is a potentially long lasting operation that can be broken into discrete steps...
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
getPreconditions(Environment $environment)
Objectives the migration depend on.
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
const NUMBER_OF_CERTS_PER_STEP
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
An environment holds resources to be used in the setup process.
ilDBStatement $prepared_statement
step(Environment $environment)