ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilCourseCleanupActivationMigration Class Reference
+ Inheritance diagram for ilCourseCleanupActivationMigration:
+ Collaboration diagram for ilCourseCleanupActivationMigration:

Public Member Functions

 getLabel ()
 
 getDefaultAmountOfStepsPerRun ()
 Tell the default amount of steps to be executed for one run of the migration. More...
 
 getPreconditions (Environment $environment)
 Objectives the migration depend on. More...
 
 prepare (Environment $environment)
 Prepare the migration by means of some environment. More...
 
 step (Environment $environment)
 Run one step of the migration. More...
 
 getRemainingAmountOfSteps ()
 Count up how many "things" need to be migrated. More...
 
 getLabel ()
 
 getDefaultAmountOfStepsPerRun ()
 Tell the default amount of steps to be executed for one run of the migration. More...
 
 getPreconditions (Environment $environment)
 Objectives the migration depend on. More...
 
 prepare (Environment $environment)
 Prepare the migration by means of some environment. More...
 
 step (Environment $environment)
 Run one step of the migration. More...
 
 getRemainingAmountOfSteps ()
 Count up how many "things" need to be migrated. More...
 

Private Attributes

ilDBInterface $db
 

Additional Inherited Members

- Data Fields inherited from ILIAS\Setup\Migration
const INFINITE = -1
 

Detailed Description

Definition at line 24 of file ilCourseCleanupActivationMigration.php.

Member Function Documentation

◆ getDefaultAmountOfStepsPerRun()

ilCourseCleanupActivationMigration::getDefaultAmountOfStepsPerRun ( )

Tell the default amount of steps to be executed for one run of the migration.

Return Migration::INFINITE if all units should be migrated at once.

Implements ILIAS\Setup\Migration.

Definition at line 33 of file ilCourseCleanupActivationMigration.php.

33 : int
34 {
35 return 10000;
36 }

◆ getLabel()

ilCourseCleanupActivationMigration::getLabel ( )
Returns
string - a meaningful and concise description for your migration.

Implements ILIAS\Setup\Migration.

Definition at line 28 of file ilCourseCleanupActivationMigration.php.

28 : string
29 {
30 return "Remove Duplicate Rows In Activation Table";
31 }

◆ getPreconditions()

ilCourseCleanupActivationMigration::getPreconditions ( Environment  $environment)

Objectives the migration depend on.

Exceptions
UnachievableExceptionif the objective is not achievable
Returns
Objective[]

Implements ILIAS\Setup\Migration.

Definition at line 38 of file ilCourseCleanupActivationMigration.php.

38 : array
39 {
40 return \ilResourceStorageMigrationHelper::getPreconditions();
41 }

◆ getRemainingAmountOfSteps()

ilCourseCleanupActivationMigration::getRemainingAmountOfSteps ( )

Count up how many "things" need to be migrated.

This helps the admin to decide how big he can create the steps and also how long a migration takes

Implements ILIAS\Setup\Migration.

Definition at line 85 of file ilCourseCleanupActivationMigration.php.

85 : int
86 {
87 return $this->db->numRows(
88 $this->db->query(
89 'SELECT obj_id, parent_id FROM crs_items GROUP BY obj_id HAVING COUNT(*) > 1'
90 )
91 );
92 }

◆ prepare()

ilCourseCleanupActivationMigration::prepare ( Environment  $environment)

Prepare the migration by means of some environment.

This is not supposed to modify the environment, but will be run to prime the migration object to run step and getRemainingAmountOfSteps afterwards.

Implements ILIAS\Setup\Migration.

Definition at line 43 of file ilCourseCleanupActivationMigration.php.

43 : void
44 {
45 $this->db = $environment->getResource(Environment::RESOURCE_DATABASE);
46 }
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.

References ILIAS\Setup\Environment\getResource().

+ Here is the call graph for this function:

◆ step()

ilCourseCleanupActivationMigration::step ( Environment  $environment)

Run one step of the migration.

Implements ILIAS\Setup\Migration.

Definition at line 48 of file ilCourseCleanupActivationMigration.php.

48 : void
49 {
50 $activation_data = $this->db->fetchObject(
51 $this->db->query(
52 'SELECT obj_id FROM crs_items' . PHP_EOL
53 . 'GROUP BY obj_id HAVING COUNT(*) > 1 LIMIT 1'
54 )
55 );
56
57 if ($activation_data === null) {
58 return;
59 }
60
61 $parent_data = $this->db->fetchObject(
62 $this->db->queryF(
63 'SELECT parent FROM tree WHERE child=%s',
65 [$activation_data->obj_id]
66 )
67 );
68
69 if ($parent_data === null) {
70 $this->db->manipulateF(
71 'DELETE FROM crs_items WHERE obj_id = %s',
73 [$activation_data->obj_id]
74 );
75 return;
76 }
77
78 $this->db->manipulateF(
79 'DELETE FROM crs_items WHERE obj_id = %s AND parent_id != %s',
81 [$activation_data->obj_id, $parent_data->parent]
82 );
83 }

References ilDBConstants\T_INTEGER.

Field Documentation

◆ $db

ilDBInterface ilCourseCleanupActivationMigration::$db
private

Definition at line 26 of file ilCourseCleanupActivationMigration.php.


The documentation for this class was generated from the following file: