This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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 | * @ingroup Watchlist |
||
20 | */ |
||
21 | use MediaWiki\MediaWikiServices; |
||
22 | use MediaWiki\Linker\LinkTarget; |
||
23 | |||
24 | /** |
||
25 | * Representation of a pair of user and title for watchlist entries. |
||
26 | * |
||
27 | * @author Tim Starling |
||
28 | * @author Addshore |
||
29 | * |
||
30 | * @ingroup Watchlist |
||
31 | */ |
||
32 | class WatchedItem { |
||
33 | |||
34 | /** |
||
35 | * @deprecated since 1.27, see User::IGNORE_USER_RIGHTS |
||
36 | */ |
||
37 | const IGNORE_USER_RIGHTS = User::IGNORE_USER_RIGHTS; |
||
38 | |||
39 | /** |
||
40 | * @deprecated since 1.27, see User::CHECK_USER_RIGHTS |
||
41 | */ |
||
42 | const CHECK_USER_RIGHTS = User::CHECK_USER_RIGHTS; |
||
43 | |||
44 | /** |
||
45 | * @deprecated Internal class use only |
||
46 | */ |
||
47 | const DEPRECATED_USAGE_TIMESTAMP = -100; |
||
48 | |||
49 | /** |
||
50 | * @var bool |
||
51 | * @deprecated Internal class use only |
||
52 | */ |
||
53 | public $checkRights = User::CHECK_USER_RIGHTS; |
||
54 | |||
55 | /** |
||
56 | * @var Title |
||
57 | * @deprecated Internal class use only |
||
58 | */ |
||
59 | private $title; |
||
60 | |||
61 | /** |
||
62 | * @var LinkTarget |
||
63 | */ |
||
64 | private $linkTarget; |
||
65 | |||
66 | /** |
||
67 | * @var User |
||
68 | */ |
||
69 | private $user; |
||
70 | |||
71 | /** |
||
72 | * @var null|string the value of the wl_notificationtimestamp field |
||
73 | */ |
||
74 | private $notificationTimestamp; |
||
75 | |||
76 | /** |
||
77 | * @param User $user |
||
78 | * @param LinkTarget $linkTarget |
||
79 | * @param null|string $notificationTimestamp the value of the wl_notificationtimestamp field |
||
80 | * @param bool|null $checkRights DO NOT USE - used internally for backward compatibility |
||
81 | */ |
||
82 | public function __construct( |
||
83 | User $user, |
||
84 | LinkTarget $linkTarget, |
||
85 | $notificationTimestamp, |
||
86 | $checkRights = null |
||
87 | ) { |
||
88 | $this->user = $user; |
||
89 | $this->linkTarget = $linkTarget; |
||
90 | $this->notificationTimestamp = $notificationTimestamp; |
||
91 | if ( $checkRights !== null ) { |
||
92 | $this->checkRights = $checkRights; |
||
0 ignored issues
–
show
|
|||
93 | } |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * @return User |
||
98 | */ |
||
99 | public function getUser() { |
||
100 | return $this->user; |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * @return LinkTarget |
||
105 | */ |
||
106 | public function getLinkTarget() { |
||
107 | return $this->linkTarget; |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * Get the notification timestamp of this entry. |
||
112 | * |
||
113 | * @return bool|null|string |
||
114 | */ |
||
115 | public function getNotificationTimestamp() { |
||
116 | // Back compat for objects constructed using self::fromUserTitle |
||
117 | if ( $this->notificationTimestamp === self::DEPRECATED_USAGE_TIMESTAMP ) { |
||
0 ignored issues
–
show
The constant
WatchedItem::DEPRECATED_USAGE_TIMESTAMP has been deprecated with message: Internal class use only
This class constant has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead. ![]() |
|||
118 | // wfDeprecated( __METHOD__, '1.27' ); |
||
119 | if ( $this->checkRights && !$this->user->isAllowed( 'viewmywatchlist' ) ) { |
||
0 ignored issues
–
show
The property
WatchedItem::$checkRights has been deprecated with message: Internal class use only
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. ![]() |
|||
120 | return false; |
||
121 | } |
||
122 | $item = MediaWikiServices::getInstance()->getWatchedItemStore() |
||
123 | ->loadWatchedItem( $this->user, $this->linkTarget ); |
||
124 | if ( $item ) { |
||
125 | $this->notificationTimestamp = $item->getNotificationTimestamp(); |
||
0 ignored issues
–
show
It seems like
$item->getNotificationTimestamp() can also be of type boolean . However, the property $notificationTimestamp is declared as type null|string . Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
![]() |
|||
126 | } else { |
||
127 | $this->notificationTimestamp = false; |
||
0 ignored issues
–
show
It seems like
false of type false is incompatible with the declared type null|string of property $notificationTimestamp .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
128 | } |
||
129 | } |
||
130 | return $this->notificationTimestamp; |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * Back compat pre 1.27 with the WatchedItemStore introduction |
||
135 | * @todo remove in 1.28/9 |
||
136 | * ------------------------------------------------- |
||
137 | */ |
||
138 | |||
139 | /** |
||
140 | * @return Title |
||
141 | * @deprecated Internal class use only |
||
142 | */ |
||
143 | public function getTitle() { |
||
144 | if ( !$this->title ) { |
||
0 ignored issues
–
show
The property
WatchedItem::$title has been deprecated with message: Internal class use only
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. ![]() |
|||
145 | $this->title = Title::newFromLinkTarget( $this->linkTarget ); |
||
0 ignored issues
–
show
The property
WatchedItem::$title has been deprecated with message: Internal class use only
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. ![]() |
|||
146 | } |
||
147 | return $this->title; |
||
0 ignored issues
–
show
The property
WatchedItem::$title has been deprecated with message: Internal class use only
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. ![]() |
|||
148 | } |
||
149 | |||
150 | /** |
||
151 | * @deprecated since 1.27 Use the constructor, WatchedItemStore::getWatchedItem() |
||
152 | * or WatchedItemStore::loadWatchedItem() |
||
153 | */ |
||
154 | public static function fromUserTitle( $user, $title, $checkRights = User::CHECK_USER_RIGHTS ) { |
||
155 | wfDeprecated( __METHOD__, '1.27' ); |
||
156 | return new self( $user, $title, self::DEPRECATED_USAGE_TIMESTAMP, (bool)$checkRights ); |
||
0 ignored issues
–
show
The constant
WatchedItem::DEPRECATED_USAGE_TIMESTAMP has been deprecated with message: Internal class use only
This class constant has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead. ![]() |
|||
157 | } |
||
158 | |||
159 | /** |
||
160 | * @deprecated since 1.27 Use User::addWatch() |
||
161 | * @return bool |
||
162 | */ |
||
163 | public function addWatch() { |
||
164 | wfDeprecated( __METHOD__, '1.27' ); |
||
165 | $this->user->addWatch( $this->getTitle(), $this->checkRights ); |
||
0 ignored issues
–
show
The property
WatchedItem::$checkRights has been deprecated with message: Internal class use only
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. ![]() |
|||
166 | return true; |
||
167 | } |
||
168 | |||
169 | /** |
||
170 | * @deprecated since 1.27 Use User::removeWatch() |
||
171 | * @return bool |
||
172 | */ |
||
173 | public function removeWatch() { |
||
174 | wfDeprecated( __METHOD__, '1.27' ); |
||
175 | if ( $this->checkRights && !$this->user->isAllowed( 'editmywatchlist' ) ) { |
||
0 ignored issues
–
show
The property
WatchedItem::$checkRights has been deprecated with message: Internal class use only
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. ![]() |
|||
176 | return false; |
||
177 | } |
||
178 | $this->user->removeWatch( $this->getTitle(), $this->checkRights ); |
||
0 ignored issues
–
show
The property
WatchedItem::$checkRights has been deprecated with message: Internal class use only
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. ![]() |
|||
179 | return true; |
||
180 | } |
||
181 | |||
182 | /** |
||
183 | * @deprecated since 1.27 Use User::isWatched() |
||
184 | * @return bool |
||
185 | */ |
||
186 | public function isWatched() { |
||
187 | wfDeprecated( __METHOD__, '1.27' ); |
||
188 | return $this->user->isWatched( $this->getTitle(), $this->checkRights ); |
||
0 ignored issues
–
show
The property
WatchedItem::$checkRights has been deprecated with message: Internal class use only
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. ![]() |
|||
189 | } |
||
190 | |||
191 | /** |
||
192 | * @deprecated since 1.27 Use WatchedItemStore::duplicateAllAssociatedEntries() |
||
193 | */ |
||
194 | public static function duplicateEntries( Title $oldTitle, Title $newTitle ) { |
||
195 | wfDeprecated( __METHOD__, '1.27' ); |
||
196 | $store = MediaWikiServices::getInstance()->getWatchedItemStore(); |
||
197 | $store->duplicateAllAssociatedEntries( $oldTitle, $newTitle ); |
||
198 | } |
||
199 | |||
200 | } |
||
201 |
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.