Skip to content

Commit

Permalink
fix: prevent migrating pageclasses twice
Browse files Browse the repository at this point in the history
this happened when using ->migratePageClasses() + MagicPages
  • Loading branch information
BernhardBaumrock committed May 16, 2023
1 parent 9fbaa6d commit b3c9add
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion RockMigrations.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class RockMigrations extends WireData implements Module, ConfigurableModule

private $migrateAll = false;

private $migrated = [];

private $noMigrate = false;

public $noYaml = false;
Expand Down Expand Up @@ -2694,7 +2696,10 @@ public function migratePageClasses($path, $namespace = 'ProcessWire', $tags = ''
$name = pathinfo($file, PATHINFO_FILENAME);
$class = "$namespace\\$name";
$tmp = $this->wire(new $class());
if (method_exists($tmp, "migrate")) $tmp->migrate();
if (method_exists($tmp, "migrate")) {
$tmp->migrate();
$this->migrated[] = $file;
}
}
}

Expand Down Expand Up @@ -2766,6 +2771,10 @@ public function migrateWatchfiles($force = false)
$this->updateLastrun();
foreach ($this->watchlist as $file) {
if (!$file->migrate) continue;
if (in_array($file->path, $this->migrated)) {
$this->log("--- Skipping {$file->path} (already migrated)");
continue;
}
if (!$this->doMigrate($file)) {
$this->log("--- Skipping {$file->path} (no change)");
continue;
Expand Down

0 comments on commit b3c9add

Please sign in to comment.