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 | |||
4 | /** |
||
5 | * @package elastica |
||
6 | * @subpackage tests |
||
7 | */ |
||
8 | class FlickrPhotoTO extends DataObject implements TestOnly { |
||
9 | private static $searchable_fields = array('Title','FlickrID','Description','TakenAt', 'TakenAtDT', 'FirstViewed', |
||
10 | 'Aperture','ShutterSpeed','FocalLength35mm','ISO','AspectRatio', 'TestMethod', 'TestMethodHTML'); |
||
11 | |||
12 | private static $searchable_relationships = array('Photographer', 'FlickrTagTOs', 'FlickrSetTOs'); |
||
13 | |||
14 | private static $searchable_autocomplete = array('Title'); |
||
15 | |||
16 | // this needs to be declared here and not added by add_extension, as it does not extend DataExtension |
||
17 | private static $extensions = array('FlickrPhotoTOTestIndexingExtension'); |
||
18 | |||
19 | private static $db = array( |
||
20 | 'Title' => 'Varchar(255)', |
||
21 | 'FlickrID' => 'Varchar', |
||
22 | 'Description' => 'HTMLText', |
||
23 | // test Date and SS_Datetime |
||
24 | 'TakenAt' => 'SS_Datetime', |
||
25 | // same as above but different valid classname |
||
26 | 'TakenAtDT' => 'Datetime', |
||
27 | 'FirstViewed' => 'Date', |
||
28 | 'Aperture' => 'Float', |
||
29 | 'ShutterSpeed' => 'Varchar', |
||
30 | 'FocalLength35mm' => 'Int', |
||
31 | 'ISO' => 'Int', |
||
32 | 'OriginalHeight' => 'Int', |
||
33 | 'OriginalWidth' => 'Int', |
||
34 | 'AspectRatio' => 'Double', |
||
35 | 'Lat' => 'Decimal(18,15)', |
||
36 | 'Lon' => 'Decimal(18,15)', |
||
37 | 'ZoomLevel' => 'Int' |
||
38 | ); |
||
39 | |||
40 | private static $belongs_many_many = array( |
||
41 | 'FlickrSetTOs' => 'FlickrSetTO' |
||
42 | ); |
||
43 | |||
44 | //1 to many |
||
45 | private static $has_one = array( |
||
46 | 'Photographer' => 'FlickrAuthorTO' |
||
47 | ); |
||
48 | |||
49 | //many to many |
||
50 | private static $many_many = array( |
||
51 | 'FlickrTagTOs' => 'FlickrTagTO' |
||
52 | ); |
||
53 | |||
54 | |||
55 | 10 | public function TestMethod() { |
|
56 | 10 | return 'this is a test method'; |
|
57 | } |
||
58 | |||
59 | 10 | public function TestMethodHTML() { |
|
60 | 10 | return '<p>this is a test method that returns <b>HTML</b></p>'; |
|
61 | } |
||
62 | |||
63 | } |
||
64 | |||
65 | |||
66 | /** |
||
67 | * @package elastica |
||
68 | * @subpackage tests |
||
69 | */ |
||
70 | View Code Duplication | class FlickrTagTO extends DataObject implements TestOnly { |
|
0 ignored issues
–
show
|
|||
71 | private static $db = array( |
||
72 | 'Value' => 'Varchar', |
||
73 | 'FlickrID' => 'Varchar', |
||
74 | 'RawValue' => 'HTMLText' |
||
75 | ); |
||
76 | |||
77 | //many to many |
||
78 | private static $belongs_many_many = array( |
||
0 ignored issues
–
show
|
|||
79 | 'FlickrPhotoTOs' => 'FlickrPhotoTO' |
||
80 | ); |
||
81 | |||
82 | private static $searchable_fields = array('RawValue'); |
||
83 | } |
||
84 | |||
85 | |||
86 | /** |
||
87 | * @package elastica |
||
88 | * @subpackage tests |
||
89 | */ |
||
90 | View Code Duplication | class FlickrSetTO extends DataObject implements TestOnly { |
|
0 ignored issues
–
show
This class seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
91 | private static $searchable_fields = array('Title','FlickrID','Description'); |
||
92 | |||
93 | private static $db = array( |
||
94 | 'Title' => 'Varchar(255)', |
||
95 | 'FlickrID' => 'Varchar', |
||
96 | 'Description' => 'HTMLText' |
||
97 | ); |
||
98 | |||
99 | private static $many_many = array( |
||
100 | 'FlickrPhotoTOs' => 'FlickrPhotoTO' |
||
101 | ); |
||
102 | } |
||
103 | |||
104 | |||
105 | |||
106 | /** |
||
107 | * @package elastica |
||
108 | * @subpackage tests |
||
109 | */ |
||
110 | class FlickrAuthorTO extends DataObject implements TestOnly { |
||
0 ignored issues
–
show
|
|||
111 | private static $db = array( |
||
112 | 'PathAlias' => 'Varchar', |
||
113 | 'DisplayName' => 'Varchar' |
||
114 | ); |
||
115 | |||
116 | //1 to many |
||
117 | private static $has_many = array('FlickrPhotoTOs' => 'FlickrPhotoTO'); |
||
0 ignored issues
–
show
|
|||
118 | |||
119 | private static $searchable_fields = array('PathAlias', 'DisplayName'); |
||
120 | |||
121 | /** |
||
122 | * NOTE: You would not normally want to do this as this means that all of |
||
123 | * each user's FlickrPhotoTOs would be indexed against FlickrAuthorTO, so if |
||
124 | * the user has 10,000 pics then the text of those 10,000 pics would |
||
125 | * be indexed also. This is purely for test purposes with a small and |
||
126 | * controlled dataset |
||
127 | * |
||
128 | * @var array |
||
129 | */ |
||
130 | private static $searchable_relationships = array('FlickrPhotoTOs'); |
||
131 | } |
||
132 | |||
133 | |||
134 | |||
135 | |||
136 | class FlickrPhotoTOTestIndexingExtension extends Extension implements ElasticaIndexingHelperInterface,TestOnly { |
||
0 ignored issues
–
show
|
|||
137 | |||
138 | /** |
||
139 | * Add a mapping for the location of the photograph |
||
140 | */ |
||
141 | 10 | public function updateElasticsearchMapping(\Elastica\Type\Mapping $mapping) |
|
142 | { |
||
143 | // get the properties of the individual fields as an array |
||
144 | 10 | $properties = $mapping->getProperties(); |
|
145 | |||
146 | // add a location with geo point |
||
147 | 10 | $precision1cm = array('format' => 'compressed', 'precision' => '1cm'); |
|
148 | 10 | $properties['location'] = array( |
|
149 | 10 | 'type' => 'geo_point', |
|
150 | 10 | 'fielddata' => $precision1cm, |
|
151 | ); |
||
152 | |||
153 | 10 | $properties['ShutterSpeed'] = array( |
|
154 | 10 | 'type' => 'string', |
|
155 | 'index' => 'not_analyzed' |
||
156 | 10 | ); |
|
157 | |||
158 | 10 | $properties['Aperture'] = array( |
|
159 | // do not use float as the rounding makes facets impossible |
||
160 | 'type' => 'double' |
||
161 | 10 | ); |
|
162 | |||
163 | 10 | $properties['FlickrID'] = array('type' => 'integer'); |
|
164 | |||
165 | // by default casted as a string, we want a date 2015-07-25 18:15:33 y-M-d H:m:s |
||
166 | //$properties['TakenAt'] = array('type' => 'date', 'format' => 'y-M-d H:m:s'); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
66% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
167 | |||
168 | // set the new properties on the mapping |
||
169 | 10 | $mapping->setProperties($properties); |
|
170 | |||
171 | 10 | return $mapping; |
|
172 | } |
||
173 | |||
174 | |||
175 | /** |
||
176 | * Populate elastica with the location of the photograph |
||
177 | * @param \Elastica\Document $document Representation of an Elastic Search document |
||
178 | * @return \Elastica\Document modified version of the document |
||
179 | */ |
||
180 | 10 | public function updateElasticsearchDocument(\Elastica\Document $document) |
|
181 | { |
||
182 | 10 | if ($this->owner->Lat != null && $this->owner->Lon != null) { |
|
183 | 10 | $coors = array('lat' => $this->owner->Lat, 'lon' => $this->owner->Lon); |
|
184 | 10 | $document->set('location',$coors); |
|
185 | 10 | } |
|
186 | |||
187 | 10 | $sortable = $this->owner->ShutterSpeed; |
|
188 | 10 | $sortable = explode('/', $sortable); |
|
189 | 10 | if (sizeof($sortable) == 1) { |
|
190 | 10 | $sortable = trim($sortable[0]); |
|
191 | |||
192 | 10 | if ($this->owner->ShutterSpeed == null) { |
|
193 | $sortable = null; |
||
194 | } |
||
195 | |||
196 | 10 | if ($sortable == 1) { |
|
197 | 10 | $sortable = '1.000000'; |
|
198 | 10 | } |
|
199 | |||
200 | 10 | } else if (sizeof($sortable) == 2) { |
|
201 | 10 | $sortable = floatval($sortable[0])/intval($sortable[1]); |
|
202 | 10 | $sortable = round($sortable,6); |
|
203 | 10 | } |
|
204 | 10 | $sortable = $sortable . '|' . $this->owner->ShutterSpeed; |
|
205 | 10 | $document->set('ShutterSpeed', $sortable); |
|
206 | 10 | return $document; |
|
207 | } |
||
208 | |||
209 | |||
210 | 10 | public function updateElasticHTMLFields(array $htmlFields) { |
|
211 | 10 | array_push($htmlFields, 'TestMethodHTML'); |
|
212 | 10 | return $htmlFields; |
|
213 | } |
||
214 | } |
||
215 | |||
216 | |||
217 | /** |
||
218 | * @package elastica |
||
219 | * @subpackage tests |
||
220 | */ |
||
221 | class ManyTypesPage extends Page { // FIXME, TestOnly |
||
0 ignored issues
–
show
|
|||
222 | private static $searchable_fields = array( |
||
223 | 'BooleanField', |
||
224 | 'CurrencyField', |
||
225 | 'DateField', |
||
226 | 'DecimalField', |
||
227 | 'HTMLTextField', |
||
228 | 'HTMLVarcharField', |
||
229 | 'IntField', |
||
230 | 'PercentageField', |
||
231 | 'SS_DatetimeField', |
||
232 | 'TextField', |
||
233 | 'TimeField' |
||
234 | ); |
||
235 | |||
236 | private static $db = array( |
||
237 | 'BooleanField' => 'Boolean', |
||
238 | 'CurrencyField' => 'Currency', |
||
239 | 'DateField' => 'Date', |
||
240 | 'DecimalField' => 'Decimal', |
||
241 | 'HTMLTextField' => 'HTMLText', |
||
242 | 'HTMLVarcharField' => 'HTMLVarchar', |
||
243 | 'IntField' => 'Int', |
||
244 | 'PercentageField' => 'Percentage', |
||
245 | 'SS_DatetimeField' => 'SS_Datetime', |
||
246 | 'TextField' => 'Text', |
||
247 | 'TimeField' => 'Time' |
||
248 | ); |
||
249 | |||
250 | } |
||
251 | |||
252 | /** |
||
253 | * @package elastica |
||
254 | * @subpackage tests |
||
255 | */ |
||
256 | class ManyTypesPage_Controller extends Controller implements TestOnly { |
||
0 ignored issues
–
show
This class is not in CamelCase format.
Classes in PHP are usually named in CamelCase. In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well. Thus the name database provider becomes ![]() |
|||
257 | } |
||
258 | |||
259 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.