RevisionLookup.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. /**
  3. * Service for looking up page revisions.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. * http://www.gnu.org/copyleft/gpl.html
  19. *
  20. * @file
  21. */
  22. namespace MediaWiki\Revision;
  23. use IDBAccessObject;
  24. use MediaWiki\Linker\LinkTarget;
  25. use Title;
  26. /**
  27. * Service for looking up page revisions.
  28. *
  29. * @note This was written to act as a drop-in replacement for the corresponding
  30. * static methods in Revision.
  31. *
  32. * @since 1.31
  33. * @since 1.32 Renamed from MediaWiki\Storage\RevisionLookup
  34. */
  35. interface RevisionLookup extends IDBAccessObject {
  36. /**
  37. * Load a page revision from a given revision ID number.
  38. * Returns null if no such revision can be found.
  39. *
  40. * MCR migration note: this replaces Revision::newFromId
  41. *
  42. * $flags include:
  43. *
  44. * @param int $id
  45. * @param int $flags bit field, see IDBAccessObject::READ_XXX
  46. * @return RevisionRecord|null
  47. */
  48. public function getRevisionById( $id, $flags = 0 );
  49. /**
  50. * Load either the current, or a specified, revision
  51. * that's attached to a given link target. If not attached
  52. * to that link target, will return null.
  53. *
  54. * MCR migration note: this replaces Revision::newFromTitle
  55. *
  56. * @param LinkTarget $linkTarget
  57. * @param int $revId (optional)
  58. * @param int $flags bit field, see IDBAccessObject::READ_XXX
  59. * @return RevisionRecord|null
  60. */
  61. public function getRevisionByTitle( LinkTarget $linkTarget, $revId = 0, $flags = 0 );
  62. /**
  63. * Load either the current, or a specified, revision
  64. * that's attached to a given page ID.
  65. * Returns null if no such revision can be found.
  66. *
  67. * MCR migration note: this replaces Revision::newFromPageId
  68. *
  69. * @param int $pageId
  70. * @param int $revId (optional)
  71. * @param int $flags bit field, see IDBAccessObject::READ_XXX
  72. * @return RevisionRecord|null
  73. */
  74. public function getRevisionByPageId( $pageId, $revId = 0, $flags = 0 );
  75. /**
  76. * Get previous revision for this title
  77. *
  78. * MCR migration note: this replaces Revision::getPrevious
  79. *
  80. * @param RevisionRecord $rev
  81. * @param int $flags (optional) $flags include:
  82. * IDBAccessObject::READ_LATEST: Select the data from the master
  83. *
  84. * @return RevisionRecord|null
  85. */
  86. public function getPreviousRevision( RevisionRecord $rev, $flags = 0 );
  87. /**
  88. * Get next revision for this title
  89. *
  90. * MCR migration note: this replaces Revision::getNext
  91. *
  92. * @param RevisionRecord $rev
  93. * @param int $flags (optional) $flags include:
  94. * IDBAccessObject::READ_LATEST: Select the data from the master
  95. *
  96. * @return RevisionRecord|null
  97. */
  98. public function getNextRevision( RevisionRecord $rev, $flags = 0 );
  99. /**
  100. * Get rev_timestamp from rev_id, without loading the rest of the row.
  101. *
  102. * MCR migration note: this replaces Revision::getTimestampFromId
  103. *
  104. * @param int $id
  105. * @param int $flags
  106. * @return string|bool False if not found
  107. * @since 1.34 (present earlier in RevisionStore)
  108. */
  109. public function getTimestampFromId( $id, $flags = 0 );
  110. /**
  111. * Load a revision based on a known page ID and current revision ID from the DB
  112. *
  113. * This method allows for the use of caching, though accessing anything that normally
  114. * requires permission checks (aside from the text) will trigger a small DB lookup.
  115. *
  116. * MCR migration note: this replaces Revision::newKnownCurrent
  117. *
  118. * @param Title $title the associated page title
  119. * @param int $revId current revision of this page
  120. *
  121. * @return RevisionRecord|bool Returns false if missing
  122. */
  123. public function getKnownCurrentRevision( Title $title, $revId );
  124. }
  125. /**
  126. * Retain the old class name for backwards compatibility.
  127. * @deprecated since 1.32
  128. */
  129. class_alias( RevisionLookup::class, 'MediaWiki\Storage\RevisionLookup' );