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 | abstract class Ajde_Model_Revision extends Ajde_Model |
||
4 | { |
||
5 | protected $_ignoreFieldInRevision = []; |
||
6 | protected $_ignoreFieldInRevisionIfEmpty = []; |
||
7 | |||
8 | const DEFAULT_LIMIT = 50; |
||
9 | |||
10 | public function getRevisionsHtml($crud = null) |
||
11 | { |
||
12 | if (!$this->getPK()) { |
||
13 | return; |
||
14 | } |
||
15 | |||
16 | $revisions = new RevisionCollection(); |
||
17 | $revisions->addFilter(new Ajde_Filter_Where('model', Ajde_Filter::FILTER_EQUALS, $this->getModelName())); |
||
18 | $revisions->addFilter(new Ajde_Filter_Where('foreignkey', Ajde_Filter::FILTER_EQUALS, $this->getPK())); |
||
19 | $revisions->orderBy('time', 'DESC'); |
||
20 | $revisions->limit(self::DEFAULT_LIMIT); |
||
21 | |||
22 | $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/crud:revisions')); |
||
23 | $controller->setRevisions($revisions); |
||
0 ignored issues
–
show
|
|||
24 | $controller->setModel($this); |
||
0 ignored issues
–
show
The method
setModel does not exist on object<Ajde_Controller> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
![]() |
|||
25 | $controller->setCrudInstance($crud); |
||
0 ignored issues
–
show
The method
setCrudInstance does not exist on object<Ajde_Controller> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
![]() |
|||
26 | |||
27 | return $controller->invoke(); |
||
28 | } |
||
29 | |||
30 | private function getModelName() |
||
31 | { |
||
32 | $modelNameCC = str_replace('Model', '', get_class($this)); |
||
33 | |||
34 | return $this->_tableName = $this->fromCamelCase($modelNameCC); |
||
35 | } |
||
36 | |||
37 | public function purgeRevisions() |
||
38 | { |
||
39 | if (!$this->getPK()) { |
||
40 | return false; |
||
41 | } |
||
42 | |||
43 | $revisions = new RevisionCollection(); |
||
44 | $revisions->addFilter(new Ajde_Filter_Where('model', Ajde_Filter::FILTER_EQUALS, $this->getModelName())); |
||
45 | $revisions->addFilter(new Ajde_Filter_Where('foreignkey', Ajde_Filter::FILTER_EQUALS, $this->getPK())); |
||
46 | $revisions->deleteAll(); |
||
47 | |||
48 | return true; |
||
49 | } |
||
50 | |||
51 | public function save() |
||
52 | { |
||
53 | // check all changed fields |
||
54 | $modelName = get_class($this); |
||
55 | $shadowModel = new $modelName(); |
||
56 | /* @var $shadowModel Ajde_Model */ |
||
57 | $shadowModel->loadByPK($this->getPK()); |
||
58 | if ($shadowModel->_hasMeta) { |
||
59 | $shadowModel->populateMeta(); |
||
60 | } |
||
61 | |||
62 | // old values |
||
63 | $oldValues = $shadowModel->values(); |
||
64 | foreach ($oldValues as &$oldValue) { |
||
65 | @$oldValue = (string) $oldValue; |
||
0 ignored issues
–
show
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
![]() |
|||
66 | } |
||
67 | |||
68 | // populate meta of current model, but don't override |
||
69 | if ($this->_hasMeta) { |
||
70 | $this->populateMeta(false, false); |
||
71 | } |
||
72 | |||
73 | // new values |
||
74 | $newValues = $this->values(); |
||
75 | foreach ($newValues as $k => &$newValue) { |
||
76 | if ($k == 'meta_4') { |
||
77 | // die('hier'); |
||
78 | } |
||
79 | @$newValue = (string) $newValue; |
||
0 ignored issues
–
show
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
![]() |
|||
80 | } |
||
81 | |||
82 | // ignore fields |
||
83 | foreach ($this->_ignoreFieldInRevision as $ignoreField) { |
||
84 | unset($oldValues[$ignoreField]); |
||
85 | unset($newValues[$ignoreField]); |
||
86 | } |
||
87 | |||
88 | // ignore fields |
||
89 | foreach ($this->_ignoreFieldInRevisionIfEmpty as $ignoreField) { |
||
90 | if (!isset($newValues[$ignoreField]) || empty($newValues[$ignoreField])) { |
||
91 | unset($oldValues[$ignoreField]); |
||
92 | unset($newValues[$ignoreField]); |
||
93 | } |
||
94 | } |
||
95 | |||
96 | if ($diffs = array_diff_assoc($oldValues, $newValues)) { |
||
97 | foreach ($diffs as $diffField => $diffValue) { |
||
98 | $revision = new RevisionModel(); |
||
99 | $revision->model = $this->getModelName(); |
||
0 ignored issues
–
show
The property
model does not exist on object<RevisionModel> . 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. ![]() |
|||
100 | $revision->foreignkey = $this->getPK(); |
||
0 ignored issues
–
show
The property
foreignkey does not exist on object<RevisionModel> . 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. ![]() |
|||
101 | $revision->user = UserModel::getLoggedIn(); |
||
0 ignored issues
–
show
The property
user does not exist on object<RevisionModel> . 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. ![]() |
|||
102 | $revision->field = $diffField; |
||
0 ignored issues
–
show
The property
field does not exist on object<RevisionModel> . 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. ![]() |
|||
103 | $revision->old = issetor($oldValues[$diffField]); |
||
0 ignored issues
–
show
The property
old does not exist on object<RevisionModel> . 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. ![]() Are you sure the assignment to
$revision->old is correct as issetor($oldValues[$diffField]) (which targets issetor() ) seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
104 | $revision->new = issetor($newValues[$diffField]); |
||
0 ignored issues
–
show
The property
new does not exist on object<RevisionModel> . 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. ![]() Are you sure the assignment to
$revision->new is correct as issetor($newValues[$diffField]) (which targets issetor() ) seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
105 | $revision->insert(); |
||
106 | } |
||
107 | } |
||
108 | |||
109 | return parent::save(); |
||
110 | } |
||
111 | } |
||
112 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: