RevisionFactory.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * Service for constructing revision objects.
  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 MWException;
  24. use Title;
  25. /**
  26. * Service for constructing revision objects.
  27. *
  28. * @since 1.31
  29. * @since 1.32 Renamed from MediaWiki\Storage\RevisionFactory
  30. *
  31. * @note This was written to act as a drop-in replacement for the corresponding
  32. * static methods in Revision.
  33. */
  34. interface RevisionFactory {
  35. /**
  36. * Constructs a new RevisionRecord based on the given associative array following the MW1.29
  37. * database convention for the Revision constructor.
  38. *
  39. * MCR migration note: this replaces Revision::newFromRow
  40. *
  41. * @deprecated since 1.31. Use a MutableRevisionRecord instead.
  42. *
  43. * @param array $fields
  44. * @param int $queryFlags Flags for lazy loading behavior, see IDBAccessObject::READ_XXX.
  45. * @param Title|null $title
  46. *
  47. * @return MutableRevisionRecord
  48. * @throws MWException
  49. */
  50. public function newMutableRevisionFromArray( array $fields, $queryFlags = 0, Title $title = null );
  51. /**
  52. * Constructs a RevisionRecord given a database row and content slots.
  53. *
  54. * MCR migration note: this replaces Revision::newFromRow for rows based on the
  55. * revision, slot, and content tables defined for MCR since MW1.31.
  56. *
  57. * @param object $row A query result row as a raw object.
  58. * Use RevisionStore::getQueryInfo() to build a query that yields the required fields.
  59. * @param int $queryFlags Flags for lazy loading behavior, see IDBAccessObject::READ_XXX.
  60. * @param Title|null $title
  61. *
  62. * @return RevisionRecord
  63. */
  64. public function newRevisionFromRow( $row, $queryFlags = 0, Title $title = null );
  65. /**
  66. * Make a fake revision object from an archive table row. This is queried
  67. * for permissions or even inserted (as in Special:Undelete)
  68. *
  69. * MCR migration note: this replaces Revision::newFromArchiveRow
  70. *
  71. * @param object $row A query result row as a raw object.
  72. * Use RevisionStore::getArchiveQueryInfo() to build a query that yields the
  73. * required fields.
  74. * @param int $queryFlags Flags for lazy loading behavior, see IDBAccessObject::READ_XXX.
  75. * @param Title|null $title
  76. * @param array $overrides An associative array that allows fields in $row to be overwritten.
  77. * Keys in this array correspond to field names in $row without the "ar_" prefix, so
  78. * $overrides['user'] will override $row->ar_user, etc.
  79. *
  80. * @return RevisionRecord
  81. */
  82. public function newRevisionFromArchiveRow(
  83. $row,
  84. $queryFlags = 0,
  85. Title $title = null,
  86. array $overrides = []
  87. );
  88. }
  89. /**
  90. * Retain the old class name for backwards compatibility.
  91. * @deprecated since 1.32
  92. */
  93. class_alias( RevisionFactory::class, 'MediaWiki\Storage\RevisionFactory' );