Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unable to delete attachment from filesystem #1695

Closed
wants to merge 1 commit into from

Conversation

libxzr
Copy link
Contributor

@libxzr libxzr commented Jan 8, 2024

Fix #1694

问题根因

$row = $this->db->fetchRow($this->select()
    ->where('table.contents.type = ?', 'attachment')
    ->where('table.contents.cid = ?', $post)
    ->limit(1), [$this, 'push']);

if ($this->isWriteable(clone $condition) && $this->delete($condition)) {
    /** 删除文件 */
    Upload::deleteHandle($row);

删除文件时,传入给 deleteHandle() 的是数据库的原始信息。
我们应该按照数据库的格式去解包这些信息,即:

image

也就是把 text 列解析为 json 对象后,取其中的 path 值。
先前的取 path 方式和实际对象结构不匹配,造成 path 未能被正常取出,进而造成文件无法删除。

Test:
分别从“管理文件”和编辑文章页面删除文件,确认文件从文件系统上消失。

@joyqi
Copy link
Member

joyqi commented Jan 8, 2024

确实有问题,但是这里的修复可能还不够,我提了个新的 pr #1696

@libxzr
Copy link
Contributor Author

libxzr commented Jan 8, 2024

ok

@libxzr libxzr closed this Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v1.3.0-alpha 无法从文件系统中删除文件
2 participants