artabro/wire/modules/System/SystemUpdater/SystemUpdate18.php

25 lines
637 B
PHP
Raw Permalink Normal View History

2024-08-27 11:35:37 +02:00
<?php namespace ProcessWire;
/**
* Loads file/image fields to ensure their schema is up-to-date and avoid an error message
*
*
*/
class SystemUpdate18 extends SystemUpdate {
public function execute() {
$this->wire()->addHookAfter('ProcessWire::ready', $this, 'executeAtReady');
return 0; // indicates we will update system version ourselves when ready
}
public function executeAtReady() {
foreach($this->wire()->fields as $field) {
if($field->type instanceof FieldtypeFile) {
try {
$field->type->getDatabaseSchema($field);
} catch(\Exception $e) { }
}
}
$this->updater->saveSystemVersion(18);
}
}