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
Loading history...
|
|||
| 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(); |
||
| 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. Loading history...
|
|||
| 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. Loading history...
|
|||
| 35 | ); |
||
| 36 | |||
| 37 | if ($versions) { |
||
| 38 | $this->VersionNumber = $versions->Count() + 1; |
||
| 39 | } else { |
||
| 40 | $this->VersionNumber = 1; |
||
| 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. Loading history...
|
|||
| 45 | $this->Filename = $this->saveCurrentVersion(); |
||
| 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. Loading history...
|
|||
| 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. Loading history...
|
|||
| 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. Loading history...
|
|||
| 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. Loading history...
|
|||
| 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) |
||
| 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. Loading history...
|
|||
| 116 | if ($file->ParentID) { |
||
| 117 | $base = Controller::join_links( |
||
| 118 | $file->Parent()->getFullPath(), |
||
| 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. Loading history...
|
|||
| 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. Loading history...
|
|||
| 128 | ); |
||
| 129 | } |
||
| 130 | |||
| 131 | Filesystem::makeFolder($base); |
||
| 132 | |||
| 133 | $extension = $file->getExtension(); |
||
| 134 | $basename = basename($file->Name, $extension); |
||
| 135 | $version = $this->VersionNumber; |
||
| 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. Loading history...
|
|||
| 144 | ); |
||
| 145 | } |
||
| 146 | |||
| 147 | return Director::makeRelative($cachedPath); |
||
| 148 | } |
||
| 149 | } |
||
| 150 |