Subversion Repositories web.creative

Rev

Details | Last modification | View Log

Rev Author Line No. Line
41 mjordaan 1
<?php namespace ProcessWire;
2
 
3
/**
4
 * Loads file/image fields to ensure their schema is up-to-date and avoid an error message
5
 * 
6
 *
7
 */
8
class SystemUpdate18 extends SystemUpdate {
9
	public function execute() {
10
		$this->wire()->addHookAfter('ProcessWire::ready', $this, 'executeAtReady');
11
		return 0; // indicates we will update system version ourselves when ready
12
	}
13
	public function executeAtReady() {
14
		foreach($this->wire()->fields as $field) {
15
			if($field->type instanceof FieldtypeFile) {
16
				try {
17
					$field->type->getDatabaseSchema($field);
18
				} catch(\Exception $e) { }
19
			}
20
		}
21
		$this->updater->saveSystemVersion(18);
22
	}
23
}
24