Overview
Comment:Fix path/parent rename when changing parent URI
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | stable
Files: files | file ages | folders
SHA3-256: bcab29e5188c14a886f7f936e96ac6ad3bd75bea52b358e6bb6538e6da17e9bb
User & Date: bohwaz on 2021-06-03 22:01:52
Other Links: manifest | tags
Context
2021-06-03
22:23
Fix breadcrumbs urls check-in: 50cef412b0 user: bohwaz tags: trunk, stable
22:01
Fix path/parent rename when changing parent URI check-in: bcab29e518 user: bohwaz tags: trunk, stable
19:44
Hide button if site is disabled check-in: 6c86198c3d user: bohwaz tags: trunk, stable
Changes

Modified src/include/lib/Garradin/Entities/Web/Page.php from [0f694d7210] to [67cb9d89e8].

193
194
195
196
197
198
199


200
201

202
203
204
205
206










207
208
209
210
211
212
213
	{
		$content = $this->format == self::FORMAT_ENCRYPTED ? null : strip_tags($this->render());
		$this->file()->indexForSearch(null, $content, $this->title);
	}

	public function save(): bool
	{


		if (isset($this->_modified['uri']) || isset($this->_modified['path'])) {
			$this->set('file_path', $this->filepath(false));

		}

		$current_path = $this->_modified['file_path'] ?? $this->file_path;
		parent::save();
		$this->syncFile($current_path);











		return true;
	}

	public function delete(): bool
	{
		Files::get(Utils::dirname($this->file_path))->delete();







>
>


>





>
>
>
>
>
>
>
>
>
>







193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
	{
		$content = $this->format == self::FORMAT_ENCRYPTED ? null : strip_tags($this->render());
		$this->file()->indexForSearch(null, $content, $this->title);
	}

	public function save(): bool
	{
		$change_parent = null;

		if (isset($this->_modified['uri']) || isset($this->_modified['path'])) {
			$this->set('file_path', $this->filepath(false));
			$change_parent = $this->_modified['path'];
		}

		$current_path = $this->_modified['file_path'] ?? $this->file_path;
		parent::save();
		$this->syncFile($current_path);

		// Rename/move children
		if ($change_parent) {
			$db = DB::getInstance();
			$sql = sprintf('UPDATE web_pages
				SET path = %s || substr(path, %d), parent = %1$s || substr(parent, %2$d)
				WHERE parent LIKE %s;',
				$db->quote($this->path), strlen($change_parent) + 1, $db->quote($change_parent . '/%'));
			$db->exec($sql);
		}

		return true;
	}

	public function delete(): bool
	{
		Files::get(Utils::dirname($this->file_path))->delete();