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 | * @author Donatas Navidonskis <[email protected]> |
||
5 | * @since 2017 |
||
6 | * @class LangEditor |
||
7 | * |
||
8 | */ |
||
9 | class LangEditor extends LeftAndMain implements PermissionProvider { |
||
0 ignored issues
–
show
|
|||
10 | |||
11 | /** |
||
12 | * @var string |
||
13 | * @config |
||
14 | */ |
||
15 | private static $menu_title = 'Lang Editor'; |
||
0 ignored issues
–
show
|
|||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | * @config |
||
20 | */ |
||
21 | private static $url_segment = 'lang-editor'; |
||
0 ignored issues
–
show
|
|||
22 | |||
23 | /** |
||
24 | * @var float |
||
25 | * @config |
||
26 | */ |
||
27 | private static $menu_priority = -0.6; |
||
0 ignored issues
–
show
|
|||
28 | |||
29 | /** |
||
30 | * @var array |
||
31 | * @config |
||
32 | */ |
||
33 | private static $allowed_actions = [ |
||
0 ignored issues
–
show
|
|||
34 | 'FormEntities', |
||
35 | ]; |
||
36 | |||
37 | /** |
||
38 | * Default configuration of items per page. |
||
39 | * Set "null" if unlimited. |
||
40 | * |
||
41 | * @var int |
||
42 | * @config |
||
43 | */ |
||
44 | private static $items_per_page = 30; |
||
0 ignored issues
–
show
|
|||
45 | |||
46 | /** |
||
47 | * @return array |
||
48 | */ |
||
49 | public function providePermissions() { |
||
50 | $title = _t('LangEditor.MENU_TITLE', 'Lang Editor'); |
||
51 | |||
52 | return [ |
||
53 | "CMS_ACCESS_LangEditorAdmin" => [ |
||
54 | 'name' => _t('CMSMain.ACCESS', "Access to '{title}' section", ['title' => $title]), |
||
0 ignored issues
–
show
array('title' => $title) is of type array<string,string,{"title":"string"}> , but the function expects a string .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
55 | 'category' => _t('Permission.CMS_ACCESS_CATEGORY', 'CMS Access'), |
||
56 | ], |
||
57 | ]; |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * |
||
62 | * @param Member $member |
||
63 | * |
||
64 | * @return int|bool |
||
65 | */ |
||
66 | public function canView($member = null) { |
||
67 | return Permission::check('CMS_ACCESS_LangEditorAdmin', 'any', $member); |
||
0 ignored issues
–
show
|
|||
68 | } |
||
69 | |||
70 | public function init() { |
||
71 | static::config()->menu_title = _t('LangEditor.MENU_TITLE', 'Lang Editor'); |
||
72 | |||
73 | return parent::init(); |
||
74 | } |
||
75 | |||
76 | public static function flushCache() { |
||
77 | $cache = SS_Cache::factory(static::class); |
||
78 | $cache->clean(Zend_Cache::CLEANING_MODE_ALL); |
||
79 | } |
||
80 | |||
81 | public function getModules() { |
||
82 | $list = new ArrayList(); |
||
83 | $parameters = $this->getRequest()->getVars(); |
||
84 | |||
85 | unset($parameters['url']); |
||
86 | unset($parameters['start']); |
||
87 | unset($parameters['search']); |
||
88 | |||
89 | LangModule::get()->each(function (LangModule $module) use ($parameters, &$list) { |
||
90 | if (array_key_exists('moduleId', $parameters) && $parameters['moduleId'] == $module->ID) { |
||
91 | $module->Current = true; |
||
0 ignored issues
–
show
The property
Current does not exist on object<LangModule> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
92 | } |
||
93 | |||
94 | $parameters['moduleId'] = $module->ID; |
||
95 | |||
96 | $module->Link = Controller::join_links( |
||
0 ignored issues
–
show
The property
Link does not exist on object<LangModule> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
97 | Controller::curr()->Link(), |
||
98 | "?".http_build_query($parameters) |
||
99 | ); |
||
100 | |||
101 | $list->push($module); |
||
102 | }); |
||
103 | |||
104 | if (! $list->filter('Current', true)->first() && $list->count() > 0) { |
||
105 | $list->first()->Current = true; |
||
106 | } |
||
107 | |||
108 | return $list; |
||
109 | } |
||
110 | |||
111 | public function getCurrentModule() { |
||
112 | return $this->getModules()->filter('Current', true)->first(); |
||
113 | } |
||
114 | |||
115 | public function getCurrentSearchTerm() { |
||
116 | return $this->getRequest()->getVar('search'); |
||
117 | } |
||
118 | |||
119 | public function FormEntities() { |
||
120 | /** @var LangModule $module */ |
||
121 | if ($module = $this->getModules()->filter('Current', true)->first()) { |
||
122 | $entities = $module->Entities(); |
||
123 | $searchTerm = $this->getRequest()->getVar('search'); |
||
124 | |||
125 | if (! empty($searchTerm)) { |
||
126 | $entities = $entities->filter('SearchFields:LangFulltextBoolean', $searchTerm); |
||
127 | } |
||
128 | |||
129 | $parameters = $this->getRequest()->getVars(); |
||
130 | |||
131 | unset($parameters['url']); |
||
132 | |||
133 | $parameters = count($parameters) > 0 ? '?'.http_build_query($parameters) : ''; |
||
134 | |||
135 | $form = new FormEntities(Controller::curr(), __FUNCTION__, $entities); |
||
136 | $form->clearMessage(); |
||
137 | $form->setFormAction(Controller::join_links( |
||
138 | $this->Link('FormEntities'), |
||
139 | $parameters |
||
140 | )); |
||
141 | |||
142 | return $form; |
||
143 | } |
||
144 | |||
145 | return false; |
||
146 | } |
||
147 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.