Issues (211)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Jobs/PublishItemsJob.php (7 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Symbiote\QueuedJobs\Jobs;
4
5
use SilverStripe\ORM\DataObject;
6
use Symbiote\QueuedJobs\Services\AbstractQueuedJob;
7
use Symbiote\QueuedJobs\Services\QueuedJob;
8
9
/**
10
 * An example queued job
11
 *
12
 * Use this as an example of how you can write your own jobs
13
 *
14
 * @author Marcus Nyeholt <[email protected]>
15
 * @license BSD http://silverstripe.org/bsd-license/
16
 */
17
class PublishItemsJob extends AbstractQueuedJob implements QueuedJob
18
{
19
    /**
20
     * @param DataObject $rootNodeID
21
     */
22
    public function __construct($rootNodeID = null)
23
    {
24
        // this value is automatically persisted between processing requests for
25
        // this job
26
        if ($rootNodeID) {
27
            $this->rootID = $rootNodeID;
0 ignored issues
show
The property rootID does not exist on object<Symbiote\QueuedJobs\Jobs\PublishItemsJob>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?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.

Loading history...
28
        }
29
    }
30
31
    protected function getRoot()
32
    {
33
        return DataObject::get_by_id('Page', $this->rootID);
0 ignored issues
show
The property rootID does not exist on object<Symbiote\QueuedJobs\Jobs\PublishItemsJob>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?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...
34
    }
35
36
    /**
37
     * Defines the title of the job
38
     *
39
     * @return string
40
     */
41
    public function getTitle()
42
    {
43
        return _t(
44
            'PublishItemsJob.Title',
45
            "Publish items beneath {title}",
46
            array('title' => $this->getRoot()->Title)
47
        );
48
    }
49
50
    /**
51
     * Indicate to the system which queue we think we should be in based
52
     * on how many objects we're going to touch on while processing.
53
     *
54
     * We want to make sure we also set how many steps we think we might need to take to
55
     * process everything - note that this does not need to be 100% accurate, but it's nice
56
     * to give a reasonable approximation
57
     *
58
     * @return int
59
     */
60
    public function getJobType()
61
    {
62
        $this->totalSteps = 'Lots';
0 ignored issues
show
Documentation Bug introduced by
The property $totalSteps was declared of type integer, but 'Lots' is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
63
        return QueuedJob::QUEUED;
64
    }
65
66
    /**
67
     * This is called immediately before a job begins - it gives you a chance
68
     * to initialise job data and make sure everything's good to go
69
     *
70
     * What we're doing in our case is to queue up the list of items we know we need to
71
     * process still (it's not everything - just the ones we know at the moment)
72
     *
73
     * When we go through, we'll constantly add and remove from this queue, meaning
74
     * we never overload it with content
75
     */
76
    public function setup()
77
    {
78
        if (!$this->getRoot()) {
79
            // we're missing for some reason!
80
            $this->isComplete = true;
81
            $this->remainingChildren = array();
0 ignored issues
show
The property remainingChildren does not exist on object<Symbiote\QueuedJobs\Jobs\PublishItemsJob>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?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.

Loading history...
82
            return;
83
        }
84
        $remainingChildren = array();
85
        $remainingChildren[] = $this->getRoot()->ID;
86
        $this->remainingChildren = $remainingChildren;
0 ignored issues
show
The property remainingChildren does not exist on object<Symbiote\QueuedJobs\Jobs\PublishItemsJob>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?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.

Loading history...
87
88
        // we reset this to 1; this is because we only know for sure about 1 item remaining
89
        // as time goes by, this will increase as we discover more items that need processing
90
        $this->totalSteps = 1;
91
    }
92
93
    /**
94
     * Lets process a single node, and publish it if necessary
95
     */
96
    public function process()
97
    {
98
        $remainingChildren = $this->remainingChildren;
0 ignored issues
show
The property remainingChildren does not exist on object<Symbiote\QueuedJobs\Jobs\PublishItemsJob>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?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.

Loading history...
99
100
        // if there's no more, we're done!
101
        if (!count($remainingChildren)) {
102
            $this->isComplete = true;
103
            return;
104
        }
105
106
        // we need to always increment! This is important, because if we don't then our container
107
        // that executes around us thinks that the job has died, and will stop it running.
108
        $this->currentStep++;
109
110
        // lets process our first item - note that we take it off the list of things left to do
111
        $ID = array_shift($remainingChildren);
112
113
        // get the page
114
        $page = DataObject::get_by_id('Page', $ID);
115
        if ($page) {
116
            // publish it
117
            $page->doPublish();
118
119
            // and add its children to the list to be published
120
            foreach ($page->Children() as $child) {
121
                $remainingChildren[] = $child->ID;
122
                // we increase how many steps we need to do - this means our total steps constantly rises,
123
                // but it gives users an idea of exactly how many more we know about
124
                $this->totalSteps++;
125
            }
126
            $page->destroy();
127
            unset($page);
128
        }
129
130
        // and now we store the new list of remaining children
131
        $this->remainingChildren = $remainingChildren;
0 ignored issues
show
The property remainingChildren does not exist on object<Symbiote\QueuedJobs\Jobs\PublishItemsJob>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?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.

Loading history...
132
133
        if (!count($remainingChildren)) {
134
            $this->isComplete = true;
135
            return;
136
        }
137
    }
138
}
139