WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/13/2018 06:13:27 AM (16 months ago)
Author:
pento
Message:

REST API: Expose revision count and last revision ID on Post response

So that REST API clients can show appropriate UI for a post's revisions, it needs to know how many revisions the post has, and what the latest revision ID is.

Merge of [43439] and [43441] to the 4.9 branch.

Props kadamwhite, danielbachhuber, birgire, TimothyBlynJacobs, pento.
Fixes #44321.

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/tests/phpunit/tests/rest-api/rest-schema-setup.php

    r41678 r43442  
    426426        'oembeds.author_url' => 'http://example.org',
    427427        'oembeds.html' => '<blockquote class="wp-embedded-content">...</blockquote>...',
    428         'PostsCollection.0.id' => 3,
    429         'PostsCollection.0.guid.rendered' => 'http://example.org/?p=3',
    430         'PostsCollection.0.link' => 'http://example.org/?p=3',
    431         'PostsCollection.0._links.self.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/posts/3',
     428        'PostsCollection.0.id' => 4,
     429        'PostsCollection.0.guid.rendered' => 'http://example.org/?p=4',
     430        'PostsCollection.0.link' => 'http://example.org/?p=4',
     431        'PostsCollection.0._links.self.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/posts/4',
    432432        'PostsCollection.0._links.collection.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/posts',
    433433        'PostsCollection.0._links.about.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/types/post',
    434         'PostsCollection.0._links.replies.0.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3',
    435         'PostsCollection.0._links.version-history.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/posts/3/revisions',
    436         'PostsCollection.0._links.wp:attachment.0.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3',
    437         'PostsCollection.0._links.wp:term.0.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3',
    438         'PostsCollection.0._links.wp:term.1.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3',
    439         'PostModel.id' => 3,
    440         'PostModel.guid.rendered' => 'http://example.org/?p=3',
    441         'PostModel.link' => 'http://example.org/?p=3',
     434        'PostsCollection.0._links.replies.0.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4',
     435        'PostsCollection.0._links.version-history.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/posts/4/revisions',
     436        'PostsCollection.0._links.predecessor-version.0.id' => 5,
     437        'PostsCollection.0._links.predecessor-version.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/posts/4/revisions/5',
     438        'PostsCollection.0._links.wp:attachment.0.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4',
     439        'PostsCollection.0._links.wp:term.0.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4',
     440        'PostsCollection.0._links.wp:term.1.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4',
     441        'PostModel.id' => 4,
     442        'PostModel.guid.rendered' => 'http://example.org/?p=4',
     443        'PostModel.link' => 'http://example.org/?p=4',
    442444        'postRevisions.0.author' => 2,
    443         'postRevisions.0.id' => 4,
    444         'postRevisions.0.parent' => 3,
    445         'postRevisions.0.slug' => '3-revision-v1',
    446         'postRevisions.0.guid.rendered' => 'http://example.org/?p=4',
    447         'postRevisions.0._links.parent.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/posts/3',
     445        'postRevisions.0.id' => 5,
     446        'postRevisions.0.parent' => 4,
     447        'postRevisions.0.slug' => '4-revision-v1',
     448        'postRevisions.0.guid.rendered' => 'http://example.org/?p=5',
     449        'postRevisions.0._links.parent.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/posts/4',
    448450        'revision.author' => 2,
    449         'revision.id' => 4,
    450         'revision.parent' => 3,
    451         'revision.slug' => '3-revision-v1',
    452         'revision.guid.rendered' => 'http://example.org/?p=4',
    453         'PagesCollection.0.id' => 5,
    454         'PagesCollection.0.guid.rendered' => 'http://example.org/?page_id=5',
    455         'PagesCollection.0.link' => 'http://example.org/?page_id=5',
    456         'PagesCollection.0._links.self.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/pages/5',
     451        'revision.id' => 5,
     452        'revision.parent' => 4,
     453        'revision.slug' => '4-revision-v1',
     454        'revision.guid.rendered' => 'http://example.org/?p=5',
     455        'PagesCollection.0.id' => 6,
     456        'PagesCollection.0.guid.rendered' => 'http://example.org/?page_id=6',
     457        'PagesCollection.0.link' => 'http://example.org/?page_id=6',
     458        'PagesCollection.0._links.self.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/pages/6',
    457459        'PagesCollection.0._links.collection.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/pages',
    458460        'PagesCollection.0._links.about.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/types/page',
    459         'PagesCollection.0._links.replies.0.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5',
    460         'PagesCollection.0._links.version-history.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/pages/5/revisions',
    461         'PagesCollection.0._links.wp:attachment.0.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5',
    462         'PageModel.id' => 5,
    463         'PageModel.guid.rendered' => 'http://example.org/?page_id=5',
    464         'PageModel.link' => 'http://example.org/?page_id=5',
     461        'PagesCollection.0._links.replies.0.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6',
     462        'PagesCollection.0._links.version-history.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/pages/6/revisions',
     463        'PagesCollection.0._links.predecessor-version.0.id' => 7,
     464        'PagesCollection.0._links.predecessor-version.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/pages/6/revisions/7',
     465        'PagesCollection.0._links.wp:attachment.0.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6',
     466        'PageModel.id' => 6,
     467        'PageModel.guid.rendered' => 'http://example.org/?page_id=6',
     468        'PageModel.link' => 'http://example.org/?page_id=6',
    465469        'pageRevisions.0.author' => 2,
    466         'pageRevisions.0.id' => 6,
    467         'pageRevisions.0.parent' => 5,
    468         'pageRevisions.0.slug' => '5-revision-v1',
    469         'pageRevisions.0.guid.rendered' => 'http://example.org/?p=6',
    470         'pageRevisions.0._links.parent.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/pages/5',
     470        'pageRevisions.0.id' => 7,
     471        'pageRevisions.0.parent' => 6,
     472        'pageRevisions.0.slug' => '6-revision-v1',
     473        'pageRevisions.0.guid.rendered' => 'http://example.org/?p=7',
     474        'pageRevisions.0._links.parent.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/pages/6',
    471475        'pageRevision.author' => 2,
    472         'pageRevision.id' => 6,
    473         'pageRevision.parent' => 5,
    474         'pageRevision.slug' => '5-revision-v1',
    475         'pageRevision.guid.rendered' => 'http://example.org/?p=6',
    476         'MediaCollection.0.id' => 7,
    477         'MediaCollection.0.guid.rendered' => 'http://example.org/?attachment_id=7',
    478         'MediaCollection.0.link' => 'http://example.org/?attachment_id=7',
     476        'pageRevision.id' => 7,
     477        'pageRevision.parent' => 6,
     478        'pageRevision.slug' => '6-revision-v1',
     479        'pageRevision.guid.rendered' => 'http://example.org/?p=7',
     480        'MediaCollection.0.id' => 8,
     481        'MediaCollection.0.guid.rendered' => 'http://example.org/?attachment_id=8',
     482        'MediaCollection.0.link' => 'http://example.org/?attachment_id=8',
    479483        'MediaCollection.0.description.rendered' => '<p class="attachment"><!-- <a...><img.../></a> --></p>',
    480484        'MediaCollection.0.source_url' => 'http://example.org/wp-content/uploads//tmp/canola.jpg',
    481         'MediaCollection.0._links.self.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/media/7',
     485        'MediaCollection.0._links.self.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/media/8',
    482486        'MediaCollection.0._links.collection.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/media',
    483487        'MediaCollection.0._links.about.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/types/attachment',
    484         'MediaCollection.0._links.replies.0.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7',
    485         'MediaModel.id' => 7,
    486         'MediaModel.guid.rendered' => 'http://example.org/?attachment_id=7',
    487         'MediaModel.link' => 'http://example.org/?attachment_id=7',
     488        'MediaCollection.0._links.replies.0.href' => 'http://example.org/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8',
     489        'MediaModel.id' => 8,
     490        'MediaModel.guid.rendered' => 'http://example.org/?attachment_id=8',
     491        'MediaModel.link' => 'http://example.org/?attachment_id=8',
    488492        'MediaModel.description.rendered' => '<p class="attachment"><!-- <a...><img.../></a> --></p>',
    489493        'MediaModel.source_url' => 'http://example.org/wp-content/uploads//tmp/canola.jpg',
     
    533537        'me.link' => 'http://example.org/?author=2',
    534538        'CommentsCollection.0.id' => 2,
    535         'CommentsCollection.0.post' => 3,
    536         'CommentsCollection.0.link' => 'http://example.org/?p=3#comment-2',
     539        'CommentsCollection.0.post' => 4,
     540        'CommentsCollection.0.link' => 'http://example.org/?p=4#comment-2',
    537541        'CommentsCollection.0._links.self.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/comments/2',
    538542        'CommentsCollection.0._links.collection.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/comments',
    539         'CommentsCollection.0._links.up.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/posts/3',
     543        'CommentsCollection.0._links.up.0.href' => 'http://example.org/index.php?rest_route=/wp/v2/posts/4',
    540544        'CommentModel.id' => 2,
    541         'CommentModel.post' => 3,
    542         'CommentModel.link' => 'http://example.org/?p=3#comment-2',
     545        'CommentModel.post' => 4,
     546        'CommentModel.link' => 'http://example.org/?p=4#comment-2',
    543547        'settings.title' => 'Test Blog',
    544548        'settings.url' => 'http://example.org',
Note: See TracChangeset for help on using the changeset viewer.