"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "system/src/Grav/Framework/Form/FormFlash.php" between
grav-v1.7.17.zip and grav-v1.7.18.zip

About: Grav is a fast, simple, and flexible flat-file based CMS platform (using YAML and PHP). Contents are just simple markdown files in folders with optional extensions via API and hooks.

FormFlash.php  (grav-v1.7.17):FormFlash.php  (grav-v1.7.18)
skipping to change at line 123 skipping to change at line 123
} }
/** /**
* Load raw flex flash data from the filesystem. * Load raw flex flash data from the filesystem.
* *
* @return array|null * @return array|null
*/ */
protected function loadStoredForm(): ?array protected function loadStoredForm(): ?array
{ {
$file = $this->getTmpIndex(); $file = $this->getTmpIndex();
$exists = $file->exists(); $exists = $file && $file->exists();
$data = null; $data = null;
if ($exists) { if ($exists) {
try { try {
$data = (array)$file->content(); $data = (array)$file->content();
} catch (Exception $e) { } catch (Exception $e) {
} }
} }
return $data; return $data;
skipping to change at line 247 skipping to change at line 247
*/ */
public function save(bool $force = false) public function save(bool $force = false)
{ {
if (!($this->folder && $this->uniqueId)) { if (!($this->folder && $this->uniqueId)) {
return $this; return $this;
} }
if ($force || $this->data || $this->files) { if ($force || $this->data || $this->files) {
// Only save if there is data or files to be saved. // Only save if there is data or files to be saved.
$file = $this->getTmpIndex(); $file = $this->getTmpIndex();
$file->save($this->jsonSerialize()); if ($file) {
$this->exists = true; $file->save($this->jsonSerialize());
$this->exists = true;
}
} elseif ($this->exists) { } elseif ($this->exists) {
// Delete empty form flash if it exists (it carries no information). // Delete empty form flash if it exists (it carries no information).
return $this->delete(); return $this->delete();
} }
return $this; return $this;
} }
/** /**
* @inheritDoc * @inheritDoc
skipping to change at line 477 skipping to change at line 479
/** /**
* @return string * @return string
*/ */
public function getTmpDir(): string public function getTmpDir(): string
{ {
return $this->folder && $this->uniqueId ? "{$this->folder}/{$this->uniqu eId}" : ''; return $this->folder && $this->uniqueId ? "{$this->folder}/{$this->uniqu eId}" : '';
} }
/** /**
* @return YamlFile * @return ?YamlFile
*/ */
protected function getTmpIndex(): YamlFile protected function getTmpIndex(): ?YamlFile
{ {
$tmpDir = $this->getTmpDir();
// Do not use CompiledYamlFile as the file can change multiple times per second. // Do not use CompiledYamlFile as the file can change multiple times per second.
return YamlFile::instance($this->getTmpDir() . '/index.yaml'); return $tmpDir ? YamlFile::instance($tmpDir . '/index.yaml') : null;
} }
/** /**
* @param string $name * @param string $name
*/ */
protected function removeTmpFile(string $name): void protected function removeTmpFile(string $name): void
{ {
$tmpDir = $this->getTmpDir(); $tmpDir = $this->getTmpDir();
$filename = $tmpDir ? $tmpDir . '/' . $name : ''; $filename = $tmpDir ? $tmpDir . '/' . $name : '';
if ($name && $filename && is_file($filename)) { if ($name && $filename && is_file($filename)) {
skipping to change at line 504 skipping to change at line 508
} }
} }
/** /**
* @return void * @return void
*/ */
protected function removeTmpDir(): void protected function removeTmpDir(): void
{ {
// Make sure that index file cache gets always cleared. // Make sure that index file cache gets always cleared.
$file = $this->getTmpIndex(); $file = $this->getTmpIndex();
$file->free(); if ($file) {
$file->free();
}
$tmpDir = $this->getTmpDir(); $tmpDir = $this->getTmpDir();
if ($tmpDir && file_exists($tmpDir)) { if ($tmpDir && file_exists($tmpDir)) {
Folder::delete($tmpDir); Folder::delete($tmpDir);
} }
} }
/** /**
* @param string|null $field * @param string|null $field
* @param string $name * @param string $name
 End of changes. 7 change blocks. 
7 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)