RCDatabaseLogEntry.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * Contains a class for dealing with recent changes database log entries
  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. * @author Niklas Laxström
  22. * @license GPL-2.0-or-later
  23. * @since 1.19
  24. */
  25. /**
  26. * A subclass of DatabaseLogEntry for objects constructed from entries in the
  27. * recentchanges table (rather than the logging table).
  28. */
  29. class RCDatabaseLogEntry extends DatabaseLogEntry {
  30. public function getId() {
  31. return $this->row->rc_logid;
  32. }
  33. protected function getRawParameters() {
  34. return $this->row->rc_params;
  35. }
  36. public function getAssociatedRevId() {
  37. return $this->row->rc_this_oldid;
  38. }
  39. public function getType() {
  40. return $this->row->rc_log_type;
  41. }
  42. public function getSubtype() {
  43. return $this->row->rc_log_action;
  44. }
  45. public function getPerformer() {
  46. if ( !$this->performer ) {
  47. $actorId = isset( $this->row->rc_actor ) ? (int)$this->row->rc_actor : 0;
  48. $userId = (int)$this->row->rc_user;
  49. if ( $actorId !== 0 ) {
  50. $this->performer = User::newFromActorId( $actorId );
  51. } elseif ( $userId !== 0 ) {
  52. $this->performer = User::newFromId( $userId );
  53. } else {
  54. $userText = $this->row->rc_user_text;
  55. // Might be an IP, don't validate the username
  56. $this->performer = User::newFromName( $userText, false );
  57. }
  58. }
  59. return $this->performer;
  60. }
  61. public function getTarget() {
  62. $namespace = $this->row->rc_namespace;
  63. $page = $this->row->rc_title;
  64. return Title::makeTitle( $namespace, $page );
  65. }
  66. public function getTimestamp() {
  67. return wfTimestamp( TS_MW, $this->row->rc_timestamp );
  68. }
  69. public function getComment() {
  70. return CommentStore::getStore()
  71. // Legacy because the row may have used RecentChange::selectFields()
  72. ->getCommentLegacy( wfGetDB( DB_REPLICA ), 'rc_comment', $this->row )->text;
  73. }
  74. public function getDeleted() {
  75. return $this->row->rc_deleted;
  76. }
  77. }