[wp-trac] [WordPress Trac] #6775: Post Revisions
WordPress Trac
wp-trac at lists.automattic.com
Fri Apr 18 22:40:26 GMT 2008
#6775: Post Revisions
-------------------------+--------------------------------------------------
Reporter: mdawaffe | Owner: anonymous
Type: enhancement | Status: new
Priority: normal | Milestone: 2.6
Component: General | Version: 2.5.1
Severity: normal | Keywords: revision needs-testing
-------------------------+--------------------------------------------------
== Overview ==
Attached is a first pass at adding basic versioning/revisioning to
WordPress.
What it does:
1. Saves a copy of a post every time you edit it.
2. Allows you to view (not edit) each of those copies (revisions).
3. Shows diffs between any two revisions. Forward (in time) diffs only.
What it doesn't do:
1. You cannot have a live-revision and a working revision to be pushed
live later. I'm not sure if that feature would be useful to our core
audience or not. At any rate, it's a little tricky to get working
correctly.
== How it works ==
Posts are copied into a new row in the posts table on the
{{{pre_post_update}}} hook. Only certain (configurable by plugin) fields
are saved (title, content, author, excerpt). The rest are either used
internally by WP somewhere or I felt weren't useful to save.
Posts can be restored from an older revision either in full or field by
field (not chunk by chunk).
The Diff engine is an extension of the
[http://pear.php.net/package/Text_Diff PEAR Text_Diff] package (which I
believe to be the descendent of the MediaWiki Diff engine). The
generation of the diff output is fully pluggable via the new
{{{wp_text_diff()}}} pluggable function.
The provided function shows diffs "side by side" and with both line and
word highlighting (trac style). The old content is on the left, and the
new content is on the right. This presentation allows you to ignore all
the color highlighting and plusses and minuses and just read either side
from top to bottom to see what the post looked like in that revision.
Functions provided:
* {{{wp_text_diff( $left_string, $right_string, $args = null )}}}
* {{{wp_save_revision( $post_id )}}}
* {{{wp_get_revision(&$post, $output = OBJECT, $filter = 'raw')}}}
* {{{wp_restore_revision( $revision_id, $fields = null )}}}
* {{{wp_delete_revision( $revision_id )}}}
* {{{wp_get_post_revisions( $post_id = 0 )}}}
* {{{wp_list_post_revisions( $post_id = 0, $args = null )}}}
== TODO ==
1. Open up revisions for pages as well. That's where they'll be most
useful.
2. Rework Autosave to store its data as a special post revision. Then
we'll be able to autosave *all* posts/pages (not just drafts) and have
recovery messages like "WordPress found an autosaved copy of this post
that's more recent than your version, would you like to see it?"
3. Review caps/permissions. Do we need any new ones like
{{{current_user_can( 'view_revision', $id )}}}?
4. Display revisions and/or diffs in front end?
5. Decide how many revisions to store for each post. Right now it stores
an arbitrary number. Should it be capped?
== Prior work and idea sources ==
1. http://wordpress.org/extend/plugins/post-revisions/ (me)
2. http://wordpress.org/extend/plugins/blicki/ (Ryan)
3. http://comox.textdrive.com/pipermail/wp-hackers/2008-March/018689.html
(Paul Menard)
Committer:
{{{
svn add wp-includes/Text
svn add wp-incledes/wp-diff.php
svn add wp-admin/revision.php
}}}
--
Ticket URL: <http://trac.wordpress.org/ticket/6775>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list