19 declare(strict_types=1);
31 return 'Migration of Files in Forum Posts to the Resource Storage Service.';
54 $r = $this->helper->getDatabase()->query(
56 frm_posts.pos_pk AS posting_id, 57 frm_posts.pos_author_id AS owner_id, 58 frm_data.top_frm_fk AS object_id 60 JOIN frm_data ON frm_posts.pos_top_fk = frm_data.top_pk 61 WHERE frm_posts.rcid IS NULL OR frm_posts.rcid = '' 65 $d = $this->helper->getDatabase()->fetchObject(
$r);
70 $posting_id = (
int)
$d->posting_id;
71 $object_id = (
int)
$d->object_id;
72 $resource_owner_id = (
int)
$d->owner_id;
74 $base_path = $this->buildBasePath();
75 $filename_pattern =
'/^' . $object_id .
'\_' . $posting_id .
'\_(.*)/m';
76 $pattern =
'/.*\/' . $object_id .
'\_' . $posting_id .
'\_(.*)/m';
78 if (is_dir($base_path) && count(scandir($base_path)) > 2) {
79 $collection_id = $this->helper->moveFilesOfPatternToCollection(
83 ResourceCollection::NO_SPECIFIC_OWNER,
88 $save_colletion_id = $collection_id === null ?
'-' : $collection_id->serialize();
89 $this->helper->getDatabase()->update(
91 [
'rcid' => [
'text', $save_colletion_id]],
92 [
'pos_pk' => [
'integer', $posting_id],]
95 $this->helper->getDatabase()->update(
97 [
'rcid' => [
'text',
'-']],
98 [
'pos_pk' => [
'integer', $posting_id],]
105 $r = $this->helper->getDatabase()->query(
107 count(frm_posts.pos_pk) AS amount 109 JOIN frm_data ON frm_posts.pos_top_fk = frm_data.top_pk 110 WHERE frm_posts.rcid IS NULL OR frm_posts.rcid = '';" 112 $d = $this->helper->getDatabase()->fetchObject(
$r);
114 return (
int)
$d->amount;
124 return static function (
string $file_name) use ($pattern):
string {
125 if (preg_match($pattern, $file_name, $matches)) {
126 return $matches[1] ?? $file_name;
134 return static function (
string $file_name):
string {
135 return md5($file_name);
A migration is a potentially long lasting operation that can be broken into discrete steps...
prepare(Environment $environment)
Prepare the migration by means of some environment.
step(Environment $environment)
Run one step of the migration.
getPreconditions(Environment $environment)
Objectives the migration depend on.
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
getRevisionNameCallback()
ilResourceStorageMigrationHelper $helper
getFileNameCallback(string $pattern)
An environment holds resources to be used in the setup process.
static getPreconditions()