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 | namespace Wikibase\Repo\Content; |
||
4 | |||
5 | use Content; |
||
6 | use IContextSource; |
||
7 | use MediaWiki\Revision\SlotRenderingProvider; |
||
8 | use Page; |
||
9 | use Title; |
||
10 | use Wikibase\DataModel\Entity\EntityId; |
||
11 | use Wikibase\DataModel\Entity\EntityIdParser; |
||
12 | use Wikibase\DataModel\Entity\Property; |
||
13 | use Wikibase\DataModel\Entity\PropertyId; |
||
14 | use Wikibase\Lib\Store\EntityContentDataCodec; |
||
15 | use Wikibase\Lib\Store\EntityIdLookup; |
||
16 | use Wikibase\Lib\Store\EntityTermStoreWriter; |
||
17 | use Wikibase\Lib\Store\LanguageFallbackLabelDescriptionLookupFactory; |
||
18 | use Wikibase\Lib\Store\PropertyInfoStore; |
||
19 | use Wikibase\Repo\Actions\EditEntityAction; |
||
20 | use Wikibase\Repo\Actions\HistoryEntityAction; |
||
21 | use Wikibase\Repo\Actions\SubmitEntityAction; |
||
22 | use Wikibase\Repo\Actions\ViewEntityAction; |
||
23 | use Wikibase\Repo\PropertyInfoBuilder; |
||
24 | use Wikibase\Repo\Search\Fields\FieldDefinitions; |
||
25 | use Wikibase\Repo\Validators\EntityConstraintProvider; |
||
26 | use Wikibase\Repo\Validators\ValidatorErrorLocalizer; |
||
27 | |||
28 | /** |
||
29 | * Content handler for Wikibase items. |
||
30 | * |
||
31 | * @license GPL-2.0-or-later |
||
32 | * @author Jeroen De Dauw < [email protected] > |
||
33 | * @author Daniel Kinzler |
||
34 | */ |
||
35 | class PropertyHandler extends EntityHandler { |
||
36 | |||
37 | /** |
||
38 | * @var PropertyInfoStore |
||
39 | */ |
||
40 | private $infoStore; |
||
41 | |||
42 | /** |
||
43 | * @var PropertyInfoBuilder |
||
44 | */ |
||
45 | private $propertyInfoBuilder; |
||
46 | |||
47 | /** |
||
48 | * @var EntityIdLookup |
||
49 | */ |
||
50 | private $entityIdLookup; |
||
51 | |||
52 | /** |
||
53 | * @var LanguageFallbackLabelDescriptionLookupFactory |
||
54 | */ |
||
55 | private $labelLookupFactory; |
||
56 | |||
57 | /** |
||
58 | * @var EntityTermStoreWriter |
||
59 | */ |
||
60 | private $entityTermStoreWriter; |
||
61 | |||
62 | /** |
||
63 | * @param EntityTermStoreWriter $entityTermStoreWriter |
||
64 | * @param EntityContentDataCodec $contentCodec |
||
65 | * @param EntityConstraintProvider $constraintProvider |
||
66 | * @param ValidatorErrorLocalizer $errorLocalizer |
||
67 | * @param EntityIdParser $entityIdParser |
||
68 | * @param EntityIdLookup $entityIdLookup |
||
69 | * @param LanguageFallbackLabelDescriptionLookupFactory $labelLookupFactory |
||
70 | * @param PropertyInfoStore $infoStore |
||
71 | * @param PropertyInfoBuilder $propertyInfoBuilder |
||
72 | * @param FieldDefinitions $propertyFieldDefinitions |
||
73 | * @param callable|null $legacyExportFormatDetector |
||
74 | */ |
||
75 | public function __construct( |
||
76 | EntityTermStoreWriter $entityTermStoreWriter, |
||
77 | EntityContentDataCodec $contentCodec, |
||
78 | EntityConstraintProvider $constraintProvider, |
||
79 | ValidatorErrorLocalizer $errorLocalizer, |
||
80 | EntityIdParser $entityIdParser, |
||
81 | EntityIdLookup $entityIdLookup, |
||
82 | LanguageFallbackLabelDescriptionLookupFactory $labelLookupFactory, |
||
83 | PropertyInfoStore $infoStore, |
||
84 | PropertyInfoBuilder $propertyInfoBuilder, |
||
85 | FieldDefinitions $propertyFieldDefinitions, |
||
86 | $legacyExportFormatDetector = null |
||
87 | ) { |
||
88 | parent::__construct( |
||
89 | PropertyContent::CONTENT_MODEL_ID, |
||
90 | null, |
||
91 | $contentCodec, |
||
92 | $constraintProvider, |
||
93 | $errorLocalizer, |
||
94 | $entityIdParser, |
||
95 | $propertyFieldDefinitions, |
||
96 | $legacyExportFormatDetector |
||
97 | ); |
||
98 | |||
99 | $this->entityIdLookup = $entityIdLookup; |
||
100 | $this->labelLookupFactory = $labelLookupFactory; |
||
101 | $this->infoStore = $infoStore; |
||
102 | $this->propertyInfoBuilder = $propertyInfoBuilder; |
||
103 | $this->entityTermStoreWriter = $entityTermStoreWriter; |
||
104 | } |
||
105 | |||
106 | /** |
||
107 | * @return (\Closure|class-string)[] |
||
0 ignored issues
–
show
|
|||
108 | */ |
||
109 | public function getActionOverrides() { |
||
110 | return [ |
||
111 | 'history' => function( Page $page, IContextSource $context ) { |
||
112 | return new HistoryEntityAction( |
||
113 | $page, |
||
114 | $context, |
||
115 | $this->entityIdLookup, |
||
116 | $this->labelLookupFactory->newLabelDescriptionLookup( $context->getLanguage() ) |
||
117 | ); |
||
118 | }, |
||
119 | 'view' => ViewEntityAction::class, |
||
120 | 'edit' => EditEntityAction::class, |
||
121 | 'submit' => SubmitEntityAction::class, |
||
122 | ]; |
||
123 | } |
||
124 | |||
125 | /** |
||
126 | * @see EntityHandler::getSpecialPageForCreation |
||
127 | * |
||
128 | * @return string |
||
129 | */ |
||
130 | public function getSpecialPageForCreation() { |
||
131 | return 'NewProperty'; |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * Returns Property::ENTITY_TYPE |
||
136 | * |
||
137 | * @return string |
||
138 | */ |
||
139 | public function getEntityType() { |
||
140 | return Property::ENTITY_TYPE; |
||
141 | } |
||
142 | |||
143 | public function getSecondaryDataUpdates( |
||
144 | Title $title, |
||
145 | Content $content, |
||
146 | $role, |
||
147 | SlotRenderingProvider $slotOutput |
||
148 | ) { |
||
149 | $updates = parent::getSecondaryDataUpdates( $title, $content, $role, $slotOutput ); |
||
150 | |||
151 | /** @var PropertyContent $content */ |
||
152 | '@phan-var PropertyContent $content'; |
||
153 | $id = $content->getEntityId(); |
||
154 | $property = $content->getProperty(); |
||
155 | |||
156 | $updates[] = new DataUpdateAdapter( |
||
157 | [ $this->infoStore, 'setPropertyInfo' ], |
||
158 | $id, |
||
159 | $this->propertyInfoBuilder->buildPropertyInfo( $property ) |
||
160 | ); |
||
161 | |||
162 | if ( $content->isRedirect() ) { |
||
163 | $updates[] = new DataUpdateAdapter( |
||
164 | [ $this->entityTermStoreWriter, 'deleteTermsOfEntity' ], |
||
165 | $id |
||
166 | ); |
||
167 | } else { |
||
168 | $updates[] = new DataUpdateAdapter( |
||
169 | [ $this->entityTermStoreWriter, 'saveTermsOfEntity' ], |
||
170 | $property |
||
171 | ); |
||
172 | } |
||
173 | |||
174 | return $updates; |
||
175 | } |
||
176 | |||
177 | public function getDeletionUpdates( Title $title, $role ) { |
||
178 | $updates = parent::getDeletionUpdates( $title, $role ); |
||
179 | |||
180 | $id = $this->getIdForTitle( $title ); |
||
181 | |||
182 | $updates[] = new DataUpdateAdapter( |
||
183 | [ $this->infoStore, 'removePropertyInfo' ], |
||
184 | $id |
||
185 | ); |
||
186 | |||
187 | // Unregister the entity from the term store. |
||
188 | $updates[] = new DataUpdateAdapter( |
||
189 | [ $this->entityTermStoreWriter, 'deleteTermsOfEntity' ], |
||
190 | $id |
||
191 | ); |
||
192 | |||
193 | return $updates; |
||
194 | } |
||
195 | |||
196 | /** |
||
197 | * @see EntityHandler::makeEmptyEntity() |
||
198 | * |
||
199 | * @return Property |
||
200 | */ |
||
201 | public function makeEmptyEntity() { |
||
202 | return Property::newFromType( '' ); |
||
203 | } |
||
204 | |||
205 | /** |
||
206 | * @see EntityHandler::newEntityContent |
||
207 | * |
||
208 | * @param EntityHolder|null $entityHolder |
||
209 | * |
||
210 | * @return PropertyContent |
||
211 | */ |
||
212 | protected function newEntityContent( EntityHolder $entityHolder = null ) { |
||
213 | return new PropertyContent( $entityHolder ); |
||
214 | } |
||
215 | |||
216 | /** |
||
217 | * @see EntityContent::makeEntityId |
||
218 | * |
||
219 | * @param string $id |
||
220 | * |
||
221 | * @return EntityId |
||
222 | */ |
||
223 | public function makeEntityId( $id ) { |
||
224 | return new PropertyId( $id ); |
||
225 | } |
||
226 | |||
227 | } |
||
228 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.