19 declare(strict_types=1);
31 return 'Migration of Files in Forum Drafts to the Resource Storage Service.';
54 $r = $this->helper->getDatabase()->query(
56 frm_posts_drafts.draft_id AS draft_id, 57 frm_posts_drafts.post_author_id AS owner_id 59 JOIN frm_data ON frm_posts_drafts.forum_id = frm_data.top_pk 60 WHERE frm_posts_drafts.rcid IS NULL OR frm_posts_drafts.rcid = '' 64 $d = $this->helper->getDatabase()->fetchObject(
$r);
69 $draft_id = (
int)
$d->draft_id;
70 $resource_owner_id = (
int)
$d->owner_id;
75 if (is_dir($base_path) && count(scandir($base_path)) > 2) {
76 $collection_id = $this->helper->moveFilesOfPatternToCollection(
80 ResourceCollection::NO_SPECIFIC_OWNER,
85 $save_colletion_id = $collection_id === null ?
'-' : $collection_id->serialize();
86 $this->helper->getDatabase()->update(
88 [
'rcid' => [
'text', $save_colletion_id]],
89 [
'draft_id' => [
'integer', $draft_id]]
92 $this->helper->getDatabase()->update(
94 [
'rcid' => [
'text',
'-']],
95 [
'draft_id' => [
'integer', $draft_id]]
102 $r = $this->helper->getDatabase()->query(
104 count(frm_posts_drafts.draft_id) AS amount 105 FROM frm_posts_drafts 106 JOIN frm_data ON frm_posts_drafts.forum_id = frm_data.top_pk 107 WHERE frm_posts_drafts.rcid IS NULL OR frm_posts_drafts.rcid = '';" 109 $d = $this->helper->getDatabase()->fetchObject(
$r);
111 return (
int)
$d->amount;
121 return static function (
string $file_name) use ($pattern):
string {
122 if (preg_match($pattern, $file_name, $matches)) {
123 return $matches[1] ?? $file_name;
131 return static function (
string $file_name):
string {
132 return md5($file_name);
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
step(Environment $environment)
Run one step of the migration.
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.
getPreconditions(Environment $environment)
Objectives the migration depend on.
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
getRevisionNameCallback()
getFileNameCallback(string $pattern)
An environment holds resources to be used in the setup process.
static getPreconditions()
ilResourceStorageMigrationHelper $helper