Activity page icons preview

未关闭 适合新手
#41,982 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
85/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
php
领域
backend

调研方向

从 lib/private/Preview.php 开始,getDimensionsFromFilename() 位于第 656 行附近,这里会把缓存的预览文件夹名拆分为宽度和高度;版本子文件夹只会产生一个分段,因此后续除以零高度会抛出异常。添加 count/zero 防护,使非 W-H 名称返回 [0, 0, 0.0],并让调用方跳过它们。完成标准是:带有旧缓存预览的 txt 文件在 Activity 页面显示其图标,并且 DivisionByZeroError 消失;没有指定测试,因此通过 Web UI 复现。

由索引模型根据 Issue 内容生成。

描述

bug
Steps to reproduce
  1. Create a new txt document -> open -> write and save and close
  2. Go to Activities
  3. File .txt icon shows as broken
Expected behaviour

Should show txt files icon

Actual behaviour

Shows broken icon only on txt files

Server configuration

Operating system: Debian

Web server:

Database:

PHP version: 8.3.36

ownCloud version: 11.1.0

Updated from an older ownCloud or fresh install: Upgrade from 10.16

ERROR

In lib/private/Preview.php, inside getDimensionsFromFilename(), skip names that aren't width-height

The log shows DivisionByZeroError in lib/private/Preview.php, line 656

Who is affected: only files that have previews of old versions cached, which happens after someone opens the Versions tab of an edited text, image or PDF file. Even then, only when a preview size that isn't cached yet is requested.

Recommend patch:
$size = \explode('-', $name);
if (\count($size) < 2 || (int)$size[1] === 0) {
return [0, 0, 0.0]; // not a "W-H" preview (e.g. a version sub-folder) → skipped by the caller
}

主要语言
PHP
星标
8.8k
派生
2.1k
平均合并
19 小时 32 分钟
30 天内合并 PR
56

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

owncloud/core 的其他 Issue

查看 owncloud/core 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。