interface.jetpack-sync-replicastore.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. /**
  3. * Sync architecture prototype
  4. * @author Dan Walmsley
  5. * To run tests: phpunit --testsuite sync --filter New_Sync
  6. */
  7. /**
  8. * A high-level interface for objects that store synced WordPress data
  9. * Useful for ensuring that different storage mechanisms implement the
  10. * required semantics for storing all the data that we sync
  11. */
  12. interface iJetpack_Sync_Replicastore {
  13. // remove all data
  14. public function reset();
  15. // trigger setup for sync start/end
  16. public function full_sync_start( $config );
  17. public function full_sync_end( $checksum );
  18. // posts
  19. public function post_count( $status = null, $min_id = null, $max_id = null );
  20. public function get_posts( $status = null, $min_id = null, $max_id = null );
  21. public function get_post( $id );
  22. public function upsert_post( $post, $silent = false );
  23. public function delete_post( $post_id );
  24. public function posts_checksum( $min_id = null, $max_id = null );
  25. public function post_meta_checksum( $min_id = null, $max_id = null );
  26. // comments
  27. public function comment_count( $status = null, $min_id = null, $max_id = null );
  28. public function get_comments( $status = null, $min_id = null, $max_id = null );
  29. public function get_comment( $id );
  30. public function upsert_comment( $comment );
  31. public function trash_comment( $comment_id );
  32. public function spam_comment( $comment_id );
  33. public function delete_comment( $comment_id );
  34. public function trashed_post_comments( $post_id, $statuses );
  35. public function untrashed_post_comments( $post_id );
  36. public function comments_checksum( $min_id = null, $max_id = null );
  37. public function comment_meta_checksum( $min_id = null, $max_id = null );
  38. // options
  39. public function update_option( $option, $value );
  40. public function get_option( $option, $default = false );
  41. public function delete_option( $option );
  42. // themes
  43. public function set_theme_support( $theme_support );
  44. public function current_theme_supports( $feature );
  45. // meta
  46. public function get_metadata( $type, $object_id, $meta_key = '', $single = false );
  47. public function upsert_metadata( $type, $object_id, $meta_key, $meta_value, $meta_id );
  48. public function delete_metadata( $type, $object_id, $meta_ids );
  49. public function delete_batch_metadata( $type, $object_ids, $meta_key );
  50. // constants
  51. public function get_constant( $constant );
  52. public function set_constant( $constant, $value );
  53. // updates
  54. public function get_updates( $type );
  55. public function set_updates( $type, $updates );
  56. // functions
  57. public function get_callable( $callable );
  58. public function set_callable( $callable, $value );
  59. // network options
  60. public function get_site_option( $option );
  61. public function update_site_option( $option, $value );
  62. public function delete_site_option( $option );
  63. // terms
  64. public function get_terms( $taxonomy );
  65. public function get_term( $taxonomy, $term_id, $is_term_id = true );
  66. public function update_term( $term_object );
  67. public function delete_term( $term_id, $taxonomy );
  68. public function get_the_terms( $object_id, $taxonomy );
  69. public function update_object_terms( $object_id, $taxonomy, $terms, $append );
  70. public function delete_object_terms( $object_id, $tt_ids );
  71. // users
  72. public function user_count();
  73. public function get_user( $user_id );
  74. public function upsert_user( $user );
  75. public function delete_user( $user_id );
  76. public function upsert_user_locale( $user_id, $locale );
  77. public function delete_user_locale( $user_id );
  78. public function get_user_locale( $user_id );
  79. public function get_allowed_mime_types( $user_id );
  80. // full checksum
  81. public function checksum_all();
  82. // histogram
  83. public function checksum_histogram( $object_type, $buckets, $start_id = null, $end_id = null );
  84. }