PHPackages                             piwind/flarum-diff - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. piwind/flarum-diff

ActiveFlarum-extension[Logging &amp; Monitoring](/categories/logging)

piwind/flarum-diff
==================

View post edit histories.

v1.2.1(11mo ago)1126MITPHP

Since May 27Pushed 11mo agoCompare

[ Source](https://github.com/piwind/flarum-diff)[ Packagist](https://packagist.org/packages/piwind/flarum-diff)[ RSS](/packages/piwind-flarum-diff/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

Diff for Flarum
===============

[](#diff-for-flarum)

[![MIT license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/piwind/flarum-diff/blob/master/LICENSE) [![Latest Stable Version](https://camo.githubusercontent.com/19e022372c0ff4064819ce71d3f7333175129f4a43840b78329c9b59e8612f6f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706977696e642f666c6172756d2d646966662e737667)](https://packagist.org/packages/piwind/flarum-diff) [![Total Downloads](https://camo.githubusercontent.com/858abea6d4b53dbfef0471b0f206effa9a6f3500e5ed38a112dc36b7c35128f5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706977696e642f666c6172756d2d646966662e737667)](https://packagist.org/packages/piwind/flarum-diff)

This extension adds a "post revision history" feature to your [Flarum](https://github.com/flarum) forum.

About This Fork
---------------

[](#about-this-fork)

This repository is a fork of [hasan-ozbey/flarum-diff](https://github.com/hasan-ozbey/flarum-diff). Refer to the changelog at the end for detailed modifications.

**目前版本（Diff 1.1.2）存在严重BUG：**

插件初次安装完毕，并开启后，论坛系统会立马崩溃，在日志中看到如下：

```
[2025-05-26 14:37:35] flarum.ERROR: ReflectionException: Class "TheTurk\Diff\Listeners\PostActions" does not exist in /opt/flarum/vendor/illuminate/container/Container.php:877

Next Illuminate\Contracts\Container\BindingResolutionException: Target class [TheTurk\Diff\Listeners\PostActions] does not exist. in /opt/flarum/vendor/illuminate/container/Container.php:879

```

该问题的核心是`TheTurk\Diff\Listeners\PostActions`这个类无法被正确加载，但是查看源码没有发现明显的问题

\*\*解决办法：\*\*Flarum 可能缓存了错误的类信息，清理缓存以解决：

```
php flarum cache:clear
```

Features
--------

[](#features)

- Based on [jfcherng/php-diff](https://github.com/jfcherng/php-diff) repository (this one is forked from [chrisboulton/php-diff](https://github.com/chrisboulton/php-diff) since it's no longer maintained).
- Option for **line**, **word** and **char** (default) level diffs.
- Three render modes including "Inline", "Side By Side" &amp; "Combined".
- Archive old revisions using cron jobs or manually.
- Delete revisions or rollback to certain revision.
- Supports `fof/nightmode`, `the-turk/flarum-quiet-edits`.
- Supports all browsers which are supporting [css-grid](https://caniuse.com/#feat=css-grid).

Also, it won't load (and cache) anything until you click the "Edited" button so no need to worry about loading times.

Requirements
------------

[](#requirements)

[![php](https://camo.githubusercontent.com/8981c64d351803a750026885c8947656d0ece473ff79eeb27d7d357b7c418e80/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d254532253839254135372e342e302d626c75653f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/8981c64d351803a750026885c8947656d0ece473ff79eeb27d7d357b7c418e80/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d254532253839254135372e342e302d626c75653f7374796c653d666c61742d737175617265) [![ext-iconv](https://camo.githubusercontent.com/9b62dc2b788d4a71cbbcf8abdfac07be8d19a76f19394e4c1dce5551a827b49f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6578742d69636f6e762d627269676874677265656e3f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/9b62dc2b788d4a71cbbcf8abdfac07be8d19a76f19394e4c1dce5551a827b49f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6578742d69636f6e762d627269676874677265656e3f7374796c653d666c61742d737175617265)

You can check your php version by running `php -v` and check if `iconv` is installed by running `php --ri iconv` (which should display `iconv support => enabled`).

Installation &amp; Updating
---------------------------

[](#installation--updating)

Install with composer:

```
composer require piwind/flarum-diff
```

Updating:

```
composer update piwind/flarum-diff
php flarum migrate
php flarum cache:clear
```

Usage
-----

[](#usage)

Enable the extension and set the permissions. You're ready to go!

### Archive Old Revisions

[](#archive-old-revisions)

If **x ≥ A** (where the **x** is post's revision count), first **y=mx+b** revisions for the post can be stored as merged &amp; compressed `BLOB` in a new table (which is called `post_edit_histories_archive`). Specify the **A**, **m** and **b** from the settings modal. Float values of **y** will be rounded to the next lowest integer value. It's recommended to archive old revisions if you want to save storage volume but ***not recommended if you don't want to***.

If you want to archive old revisions, please consider enabling *cron job option* from the settings modal. I set a weekly cron job which is working on sundays at 02:00 AM (nothing special) using `diff:archive` command\*\*. Otherwise, it'll try to find &amp; archive old revisions for the post as soon as `Post\Revised` event fires or wait for your `php flarum diff:archive` command. See [this discussion](https://discuss.flarum.org/d/24118-setup-the-flarum-scheduler-using-cron) for setting up the scheduler.

### 插件兼容问题

[](#插件兼容问题)

**受影响的插件：**

- 原生的Likes插件：[flarum/likes](https://github.com/flarum/framework/tree/main/extensions/likes)
- 赞同、反对、点赞数排名：[fof/gamification](https://github.com/FriendsOfFlarum/gamification)
- BBCode More：[piwind/flarum-more-bbcode](https://github.com/piwind/flarum-more-bbcode)
- 帖子编辑记录：[piwind/flarum-diff](https://github.com/piwind/flarum-diff)

**建议的配置和效果：**

- flarum/likes：关闭插件

    fof/gamification：开启

    piwind/flarum-more-bbcode：关闭reply, like的功能，也就是关闭回复可见、点赞可见的功能，因此访问限制只有一个登录可见功能

    piwind/flarum-diff：权限"查看编辑记录"，设置为"注册用户"，这样的话bbcode中的登录可见是不受影响的，因为只有注册用户才能看到编辑记录，也就只有登录才能看到登录可见
- 用fof/gamification来替代flarum/likes，会导致基于flarum/likes的插件功能存在故障，比如piwind/flarum-more-bbcode中的点赞可见标签，会直接失效，所有人都可以看
- flarum-diff的编辑记录，会在编辑记录的原始文本和预览中泄露所有bbcode预期的访问限制的内容，截图见下面
- 如有需要（例如回复可见），可以将piwind/flarum-diff的"查看编辑记录"，设置为"管理组"，除了管理之外的用户看不了编辑记录，也就让访问限制按预期工作了
- 观点：回复可见、点赞可见这类在当前互联网背景下已经不推荐用了，没有强烈需要按建议关闭即可。

Screenshots
-----------

[](#screenshots)

[![Diff Collage](https://camo.githubusercontent.com/98fae941c11f19d4bf9968b140a54ca35798c3cb6f7761d93b710302ce1355cd/68747470733a2f2f692e6962622e636f2f464a7977484b6e2f72737a2d646966662d636f6c6c6167652e706e67)](https://camo.githubusercontent.com/98fae941c11f19d4bf9968b140a54ca35798c3cb6f7761d93b710302ce1355cd/68747470733a2f2f692e6962622e636f2f464a7977484b6e2f72737a2d646966662d636f6c6c6167652e706e67)

[![Post-Stream Item](https://camo.githubusercontent.com/06a72463d3c5c98adc4ce7ec339492a19c01cd49ece13b0f9436cbca0f2d0eb0/68747470733a2f2f692e6962622e636f2f346d3231706e4d2f706f73742d53747265616d2d4974656d2e706e67)](https://camo.githubusercontent.com/06a72463d3c5c98adc4ce7ec339492a19c01cd49ece13b0f9436cbca0f2d0eb0/68747470733a2f2f692e6962622e636f2f346d3231706e4d2f706f73742d53747265616d2d4974656d2e706e67)

[![Dropdown List](https://camo.githubusercontent.com/9890a653eceb4c4f346680f0b55af01e8cea3cccbd9caffedeb441b6b095a66a/68747470733a2f2f692e6962622e636f2f505454635743772f64726f70646f776e2d4c6973742e706e67)](https://camo.githubusercontent.com/9890a653eceb4c4f346680f0b55af01e8cea3cccbd9caffedeb441b6b095a66a/68747470733a2f2f692e6962622e636f2f505454635743772f64726f70646f776e2d4c6973742e706e67)

[![image-20250528131350282](_MARKDOWN_ASSETS/README.assets/image-20250528131350282.png)](_MARKDOWN_ASSETS/README.assets/image-20250528131350282.png)

改动说明
----

[](#改动说明)

- 删掉了原项目中的土耳其语tr，Sorry因为我个人看不懂
- 添加了中文翻译
- 【已解决】已编辑这个按钮的位置很偏（button元素的padding导致的）
- 【已解决】margin-top: -2px; 才是对的 不应该是-4
- 【TODO】插件重置存在故障

    ```
    flarum.ERROR: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails in /opt/flarum/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:117

    Next Doctrine\DBAL\Driver\PDO\Exception: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails in /opt/flarum/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18

    Next Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (SQL: drop table if exists `flarum_post_edit_histories_archive`) in /opt/flarum/vendor/illuminate/database/Connection.php:712

    ```
- 【已解决】该插件会和Piwind\\MoreBBCode插件存在冲突：

    ```
    flarum.ERROR: TypeError: Piwind\MoreBBCode\Rendering::reply2seeProcess(): Argument #3 ($discussion) must be of type Flarum\Discussion\Discussion, null given, called in /opt/flarum/vendor/piwind/flarum-more-bbcode/src/Rendering.php on line 46 and defined in /opt/flarum/vendor/piwind/flarum-more-bbcode/src/Rendering.php:75

    ```
- 【已解决】`@username`的元素没有被正确渲染，而是显示`@[已注销]`

    ```
    问题的关键在于：Mentions插件返回的值是core.lib.username.deleted_text
    最后检查下来是：$this->commentPost->getFormatter()->render()的传参故障

    ```
- 修改了默认设置

Links
-----

[](#links)

- [Source code on GitHub](https://github.com/piwind/flarum-diff)
- [Report an issue](https://github.com/piwind/flarum-diff/issues)
- [Download via Packagist](https://packagist.org/packages/piwind/flarum-diff)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance50

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

356d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a0576f6449488040ef35236381afdb1fe3669a74b4b7a5cd66ea67c74ebdcd7?d=identicon)[piwind](/maintainers/piwind)

---

Top Contributors

[![hasan-ozbey](https://avatars.githubusercontent.com/u/48382593?v=4)](https://github.com/hasan-ozbey "hasan-ozbey (21 commits)")[![piwind](https://avatars.githubusercontent.com/u/45837397?v=4)](https://github.com/piwind "piwind (15 commits)")[![flarum-bot](https://avatars.githubusercontent.com/u/39334649?v=4)](https://github.com/flarum-bot "flarum-bot (5 commits)")[![imorland](https://avatars.githubusercontent.com/u/16573496?v=4)](https://github.com/imorland "imorland (5 commits)")[![rob006](https://avatars.githubusercontent.com/u/5972388?v=4)](https://github.com/rob006 "rob006 (2 commits)")[![Csineneo](https://avatars.githubusercontent.com/u/1370009?v=4)](https://github.com/Csineneo "Csineneo (1 commits)")[![askvortsov1](https://avatars.githubusercontent.com/u/38059171?v=4)](https://github.com/askvortsov1 "askvortsov1 (1 commits)")

---

Tags

diffhistoryloggerflarumtrackeredit

### Embed Badge

![Health badge](/badges/piwind-flarum-diff/health.svg)

```
[![Health](https://phpackages.com/badges/piwind-flarum-diff/health.svg)](https://phpackages.com/packages/piwind-flarum-diff)
```

###  Alternatives

[apix/log

Minimalist, thin and fast PSR-3 compliant (multi-bucket) logger.

511.0M18](/packages/apix-log)[bonny/wordpress-simple-history

View recent changes made within WordPress, directly on your dashboard or on a separate page.

3156.9k](/packages/bonny-wordpress-simple-history)[amphp/log

Non-blocking logging for PHP based on Amp, Revolt, and Monolog.

402.6M70](/packages/amphp-log)[logtail/monolog-logtail

Logtail handler for Monolog

233.2M3](/packages/logtail-monolog-logtail)[bref/logger

All you need to log with Bref on AWS Lambda

331.5M8](/packages/bref-logger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
