logging: Start using LinkTarget & UserIdentity in ManualLogEntry
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Tue, 8 Jan 2019 16:05:05 +0000 (17:05 +0100)
committerThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Tue, 8 Jan 2019 16:11:05 +0000 (17:11 +0100)
This is a first, very small migration step. This is entirely
non-breaking, as all objects passed to these two functions already
matched the interfaces that are now required.

For the setTarget() method it's most obvious it really just needs a
LinkTarget value object, but not the entirety of the Title class
with all it's helper methods. Same for the performer. A ManualLogEntry
does not need to interact with the performer, just needs to know him.

This small change allows to slowly migrate away from code depending on
the User and Title classes.

Note this code currently does not have any test coverage, and I do not
plan to change this within this patch. I just don't have the time.

https://doc.wikimedia.org/cover/mediawiki-core/includes/logging/LogEntry.php.html

Change-Id: Id551f066ab02d5ca14346a39a55af4e7b6e4e042

includes/logging/LogEntry.php

index 5706f2d..7807e4c 100644 (file)
@@ -28,6 +28,8 @@
  * @since 1.19
  */
 
+use MediaWiki\Linker\LinkTarget;
+use MediaWiki\User\UserIdentity;
 use Wikimedia\Rdbms\IDatabase;
 
 /**
@@ -527,20 +529,20 @@ class ManualLogEntry extends LogEntryBase {
         * Set the user that performed the action being logged.
         *
         * @since 1.19
-        * @param User $performer
+        * @param UserIdentity $performer
         */
-       public function setPerformer( User $performer ) {
-               $this->performer = $performer;
+       public function setPerformer( UserIdentity $performer ) {
+               $this->performer = User::newFromIdentity( $performer );
        }
 
        /**
         * Set the title of the object changed.
         *
         * @since 1.19
-        * @param Title $target
+        * @param LinkTarget $target
         */
-       public function setTarget( Title $target ) {
-               $this->target = $target;
+       public function setTarget( LinkTarget $target ) {
+               $this->target = Title::newFromLinkTarget( $target );
        }
 
        /**