Issues (30)

Security Analysis    no request data  

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.

code/ChildPaginatorControllerExtension.php (22 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
class ChildPaginatorControllerExtension extends Extension
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    /*
6
    Call this from a template to iterate through a number of items (default 10) for the
7
    currently selected page.  The result is saved as a variable called $this->lastPagedResults for
8
    caching purposes when it comes to rendering the pagination
9
10
    <code>
11
    <% control PagedChildren(NewsItem,8) %>
12
    <li>
13
    <a href="$Link">$Title</a>
14
    <br/>
15
    <a href="$Link">$NewsItemImage.SetWidth(200)</a>
16
    <br/>
17
    <a href="$Link">$NewsItemDate.Nice</a>
18
19
    </li>
20
    <% end_control %>
21
    </code>
22
    */
23 View Code Duplication
    public function PagedChildren($klazz, $pageLength = 10, $prime = false, $relationship_key = 'ParentID')
0 ignored issues
show
The parameter $relationship_key is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Method name "ChildPaginatorControllerExtension::PagedChildren" is not in camel caps format
Loading history...
24
    {
25
        $parentID = $this->owner->ID;
26
        $req = Controller::curr()->getRequest();
27
        $list = DataList::create($klazz)->where('"ParentID" = '.$parentID);
28
        $this->lastPagedResults = new PaginatedList($list, $req);
0 ignored issues
show
The property lastPagedResults does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
29
        $this->lastPagedResults->setPageLength($pageLength);
30
        $this->lastPagedResults->setLimitItems($pageLength);
0 ignored issues
show
$pageLength is of type integer, but the function expects a boolean.

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);
Loading history...
31
        $result = $this->lastPagedResults;
32
        if ($prime == true) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
33
        $result = ''; // render nothing to the template, we are only updating variables
0 ignored issues
show
It seems like the identation of this line is off (expected at least 12 spaces, but found 8).
Loading history...
34
        }
35
36
        return $result;
37
    }
38
39 View Code Duplication
    public function AllPagedChildren($pageLength = 10, $sort = 'Sort', $prime = false, $relationship_key = 'ParentID')
0 ignored issues
show
The parameter $sort is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $relationship_key is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Method name "ChildPaginatorControllerExtension::AllPagedChildren" is not in camel caps format
Loading history...
40
    {
41
        $parentID = $this->owner->ID;
42
        $req = Controller::curr()->getRequest();
43
        $list = SiteTree::get()->where('"ParentID" = '.$parentID);
44
        $this->lastPagedResults = new PaginatedList($list, $req);
45
        $this->lastPagedResults->setPageLength($pageLength);
46
        $this->lastPagedResults->setLimitItems($pageLength);
0 ignored issues
show
$pageLength is of type integer, but the function expects a boolean.

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);
Loading history...
47
        $result = $this->lastPagedResults;
48
        if ($prime == true) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
49
            $result = ''; // render nothing to the template, we are only updating variables
50
        }
51
52
        return $result;
53
    }
54
55
    public function PagedDataObjectsByClassName($klazz, $pageLength = 10, $sort = 'ASC')
0 ignored issues
show
Method name "ChildPaginatorControllerExtension::PagedDataObjectsByClassName" is not in camel caps format
Loading history...
56
    {
57
        $req = Controller::curr()->getRequest();
58
        $this->lastPagedResults = new PaginatedList(DataList::create($klazz)->sort('LastEdited '.$sort), $req);
59
        $this->lastPagedResults->setPageLength($pageLength);
60
        $this->lastPagedResults->setLimitItems($pageLength);
0 ignored issues
show
$pageLength is of type integer, but the function expects a boolean.

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);
Loading history...
61
62
        return $this->lastPagedResults;
63
    }
64
65
    public function SetPagedOffset($newoffset)
0 ignored issues
show
Method name "ChildPaginatorControllerExtension::SetPagedOffset" is not in camel caps format
Loading history...
66
    {
67
        $this->PagedOffset = $newoffset;
0 ignored issues
show
The property PagedOffset does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
68
    }
69
70
    public function PagedChildrenAllButFirst()
0 ignored issues
show
Method name "ChildPaginatorControllerExtension::PagedChildrenAllButFirst" is not in camel caps format
Loading history...
71
    {
72
    }
73
74
    /*
75
    The current page number.  This is only populated after the call to PagedChildren
76
    */
77
    public function PageNumber()
0 ignored issues
show
Method name "ChildPaginatorControllerExtension::PageNumber" is not in camel caps format
Loading history...
78
    {
79
        return $this->PageNumber; // variable, not the method, populated when loading the pages items
0 ignored issues
show
The property PageNumber does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
80
    }
81
82
    /*
83
    A cached copy of the pagination results
84
    */
85
    public function LastPagedResults()
0 ignored issues
show
Method name "ChildPaginatorControllerExtension::LastPagedResults" is not in camel caps format
Loading history...
86
    {
87
        return $this->lastPagedResults;
88
    }
89
}
90