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 class represents a single version of a file. Each file can have many |
||
4 | * versions, and one of these is currently active at any one time. |
||
5 | * |
||
6 | * @package silverstripe-versionedfiles |
||
7 | */ |
||
8 | class FileVersion extends DataObject |
||
9 | { |
||
10 | const VERSION_FOLDER = '_versions'; |
||
11 | |||
12 | private static $db = array( |
||
0 ignored issues
–
show
Comprehensibility
introduced
by
![]() |
|||
13 | 'VersionNumber' => 'Int', |
||
14 | 'Filename' => 'Varchar(255)' |
||
15 | ); |
||
16 | |||
17 | private static $has_one = array( |
||
0 ignored issues
–
show
|
|||
18 | 'Creator' => 'Member', |
||
19 | 'File' => 'File' |
||
20 | ); |
||
21 | |||
22 | /** |
||
23 | * Saves version meta-data, and generates the saved file version on first |
||
24 | * write. |
||
25 | */ |
||
26 | public function onBeforeWrite() |
||
27 | { |
||
28 | if (!$this->isInDB()) { |
||
29 | $this->CreatorID = Member::currentUserID(); |
||
0 ignored issues
–
show
The property
CreatorID does not exist on object<FileVersion> . 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. ![]() |
|||
30 | } |
||
31 | |||
32 | if (!$this->VersionNumber) { |
||
0 ignored issues
–
show
The property
VersionNumber does not exist on object<FileVersion> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
33 | $versions = DataObject::get( |
||
34 | 'FileVersion', sprintf('"FileID" = %d', $this->FileID) |
||
0 ignored issues
–
show
The property
FileID does not exist on object<FileVersion> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
35 | ); |
||
36 | |||
37 | if ($versions) { |
||
38 | $this->VersionNumber = $versions->Count() + 1; |
||
0 ignored issues
–
show
The property
VersionNumber does not exist on object<FileVersion> . 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. ![]() |
|||
39 | } else { |
||
40 | $this->VersionNumber = 1; |
||
0 ignored issues
–
show
The property
VersionNumber does not exist on object<FileVersion> . 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. ![]() |
|||
41 | } |
||
42 | } |
||
43 | |||
44 | if (!$this->Filename) { |
||
0 ignored issues
–
show
The property
Filename does not exist on object<FileVersion> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
45 | $this->Filename = $this->saveCurrentVersion(); |
||
0 ignored issues
–
show
The property
Filename does not exist on object<FileVersion> . 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. ![]() |
|||
46 | } |
||
47 | |||
48 | parent::onBeforeWrite(); |
||
49 | } |
||
50 | |||
51 | public function onBeforeDelete() |
||
52 | { |
||
53 | if (file_exists($this->getFullPath())) { |
||
54 | unlink($this->getFullPath()); |
||
55 | } |
||
56 | |||
57 | parent::onBeforeDelete(); |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * @return string |
||
62 | */ |
||
63 | public function getTitle() |
||
64 | { |
||
65 | return sprintf( |
||
66 | _t('VersionNumber.VERSIONNUM', "Version %d"), $this->VersionNumber |
||
0 ignored issues
–
show
The property
VersionNumber does not exist on object<FileVersion> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
67 | ); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @return string |
||
72 | */ |
||
73 | public function getName() |
||
74 | { |
||
75 | return basename($this->Filename); |
||
0 ignored issues
–
show
The property
Filename does not exist on object<FileVersion> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @return string |
||
80 | */ |
||
81 | public function getURL() |
||
82 | { |
||
83 | return Controller::join_links(Director::baseURL(), $this->Filename); |
||
0 ignored issues
–
show
The property
Filename does not exist on object<FileVersion> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
84 | } |
||
85 | |||
86 | /** |
||
87 | * @return string |
||
88 | */ |
||
89 | public function getFullPath() |
||
90 | { |
||
91 | return Director::baseFolder() . $this->Filename; |
||
0 ignored issues
–
show
The property
Filename does not exist on object<FileVersion> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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 | /** |
||
95 | * Returns a Boolean object indicating if this version is currently active. |
||
96 | * |
||
97 | * @return Boolean |
||
98 | */ |
||
99 | public function IsCurrent() |
||
100 | { |
||
101 | return DBField::create_field( |
||
102 | 'Boolean', ($this->File()->CurrentVersionID == $this->ID) |
||
0 ignored issues
–
show
The method
File does not exist on object<FileVersion> ? 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 { }
![]() |
|||
103 | ); |
||
104 | } |
||
105 | |||
106 | /** |
||
107 | * Saves the current version of the linked File object in a versions |
||
108 | * directory, then returns the relative path to where it is stored. |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | protected function saveCurrentVersion() |
||
113 | { |
||
114 | // Ensure we re-fetch fresh record from database (in case it was recently renamed / moved) |
||
115 | $file = File::get()->byID($this->FileID); |
||
0 ignored issues
–
show
The property
FileID does not exist on object<FileVersion> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
116 | if ($file->ParentID) { |
||
117 | $base = Controller::join_links( |
||
118 | $file->Parent()->getFullPath(), |
||
0 ignored issues
–
show
|
|||
119 | self::VERSION_FOLDER, |
||
120 | $this->FileID |
||
0 ignored issues
–
show
The property
FileID does not exist on object<FileVersion> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
121 | ); |
||
122 | } else { |
||
123 | $base = Controller::join_links( |
||
124 | Director::baseFolder(), |
||
125 | ASSETS_DIR, |
||
126 | self::VERSION_FOLDER, |
||
127 | $this->FileID |
||
0 ignored issues
–
show
The property
FileID does not exist on object<FileVersion> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
128 | ); |
||
129 | } |
||
130 | |||
131 | Filesystem::makeFolder($base); |
||
132 | |||
133 | $extension = $file->getExtension(); |
||
0 ignored issues
–
show
The method
getExtension() does not exist on DataObject . Did you maybe mean getExtensionInstance() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise. ![]() |
|||
134 | $basename = basename($file->Name, $extension); |
||
135 | $version = $this->VersionNumber; |
||
0 ignored issues
–
show
The property
VersionNumber does not exist on object<FileVersion> . 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. ![]() |
|||
136 | |||
137 | $cachedPath = Controller::join_links( |
||
138 | $base, "{$basename}$version.$extension" |
||
139 | ); |
||
140 | |||
141 | if (!copy($file->getFullPath(), $cachedPath)) { |
||
142 | throw new Exception( |
||
143 | "Unable to copy version #$version of file #$this->FileID from:\n \"{$file->getFullPath()}\"\nto:\n\"$cachedPath\"" |
||
0 ignored issues
–
show
The property
FileID does not exist on object<FileVersion> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
144 | ); |
||
145 | } |
||
146 | |||
147 | return Director::makeRelative($cachedPath); |
||
148 | } |
||
149 | } |
||
150 |