PreparedEdit.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /**
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along
  14. * with this program; if not, write to the Free Software Foundation, Inc.,
  15. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. * http://www.gnu.org/copyleft/gpl.html
  17. *
  18. * @file
  19. */
  20. namespace MediaWiki\Edit;
  21. use Content;
  22. use ParserOptions;
  23. use RuntimeException;
  24. use ParserOutput;
  25. /**
  26. * Represents information returned by WikiPage::prepareContentForEdit()
  27. *
  28. * @deprecated since 1.32, use DerivedPageDataUpdater instead.
  29. *
  30. * @since 1.30
  31. */
  32. class PreparedEdit {
  33. /**
  34. * Time this prepared edit was made
  35. *
  36. * @var string
  37. */
  38. public $timestamp;
  39. /**
  40. * Revision ID
  41. *
  42. * @var int|null
  43. */
  44. public $revid;
  45. /**
  46. * Content after going through pre-save transform
  47. *
  48. * @var Content|null
  49. */
  50. public $pstContent;
  51. /**
  52. * Content format
  53. *
  54. * @var string
  55. */
  56. public $format;
  57. /**
  58. * Parser options used to get parser output
  59. *
  60. * @var ParserOptions
  61. */
  62. public $popts;
  63. /**
  64. * Parser output
  65. *
  66. * @var ParserOutput|null
  67. */
  68. private $canonicalOutput;
  69. /**
  70. * Content that is being saved (before PST)
  71. *
  72. * @var Content
  73. */
  74. public $newContent;
  75. /**
  76. * Current content of the page, if any
  77. *
  78. * @var Content|null
  79. */
  80. public $oldContent;
  81. /**
  82. * Lazy-loading callback to get canonical ParserOutput object
  83. *
  84. * @var callable
  85. */
  86. public $parserOutputCallback;
  87. /**
  88. * @return ParserOutput Canonical parser output
  89. */
  90. public function getOutput() {
  91. if ( !$this->canonicalOutput ) {
  92. $this->canonicalOutput = call_user_func( $this->parserOutputCallback );
  93. }
  94. return $this->canonicalOutput;
  95. }
  96. /**
  97. * Fetch the ParserOutput via a lazy-loaded callback (for backwards compatibility).
  98. *
  99. * @deprecated since 1.33
  100. * @param string $name
  101. * @return mixed
  102. */
  103. function __get( $name ) {
  104. if ( $name === 'output' ) {
  105. return $this->getOutput();
  106. }
  107. throw new RuntimeException( "Undefined field $name." );
  108. }
  109. }