Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
ScriptedImportRevision | |
0.00% |
0 / 11 |
|
0.00% |
0 / 5 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
getText | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getTimestamp | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getAuthor | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getObjectKey | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Flow\Import\LiquidThreadsApi; |
4 | |
5 | use Flow\Import\IImportObject; |
6 | use Flow\Import\IObjectRevision; |
7 | use MediaWiki\User\User; |
8 | |
9 | /* |
10 | * Represents a revision the script makes on its own behalf, using a script user |
11 | */ |
12 | class ScriptedImportRevision implements IObjectRevision { |
13 | /** @var IImportObject */ |
14 | protected $parent; |
15 | |
16 | /** @var User */ |
17 | protected $destinationScriptUser; |
18 | |
19 | /** @var string */ |
20 | protected $revisionText; |
21 | |
22 | /** @var string */ |
23 | protected $timestamp; |
24 | |
25 | /** |
26 | * Creates a ScriptedImportRevision with the given timestamp, given a script user |
27 | * and arbitrary text. |
28 | * |
29 | * @param IImportObject $parentObject Object this is a revision of |
30 | * @param User $destinationScriptUser User that performed this scripted edit |
31 | * @param string $revisionText Text of revision |
32 | * @param IObjectRevision $baseRevision Base revision, used only for timestamp generation |
33 | */ |
34 | public function __construct( IImportObject $parentObject, User $destinationScriptUser, $revisionText, $baseRevision ) { |
35 | $this->parent = $parentObject; |
36 | $this->destinationScriptUser = $destinationScriptUser; |
37 | $this->revisionText = $revisionText; |
38 | |
39 | $baseTimestamp = (int)wfTimestamp( TS_UNIX, $baseRevision->getTimestamp() ); |
40 | |
41 | // Set a minute after. If it uses $baseTimestamp again, there can be time |
42 | // collisions. |
43 | $this->timestamp = wfTimestamp( TS_UNIX, $baseTimestamp + 60 ); |
44 | } |
45 | |
46 | public function getText() { |
47 | return $this->revisionText; |
48 | } |
49 | |
50 | public function getTimestamp() { |
51 | return $this->timestamp; |
52 | } |
53 | |
54 | public function getAuthor() { |
55 | return $this->destinationScriptUser->getName(); |
56 | } |
57 | |
58 | /** |
59 | * XXX: This is called but never used, but if it were, including getText and getAuthor in |
60 | * the key might not be desirable, because we don't necessarily want to re-import |
61 | * the revision when these change. |
62 | * @return string |
63 | */ |
64 | public function getObjectKey() { |
65 | return $this->parent->getObjectKey() . ':rev:scripted:' . md5( |
66 | $this->getText() . $this->getAuthor() |
67 | ); |
68 | } |
69 | } |