Issues (4122)

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.

maintenance/populateParentId.php (2 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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 34 and the first side effect is on line 26.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * Makes the required database updates for rev_parent_id
4
 * to be of any use. It can be used for some simple tracking
5
 * and to find new page edits by users.
6
 *
7
 * This program is free software; you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation; either version 2 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License along
18
 * with this program; if not, write to the Free Software Foundation, Inc.,
19
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
 * http://www.gnu.org/copyleft/gpl.html
21
 *
22
 * @file
23
 * @ingroup Maintenance
24
 */
25
26
require_once __DIR__ . '/Maintenance.php';
27
28
/**
29
 * Maintenance script that makes the required database updates for rev_parent_id
30
 * to be of any use.
31
 *
32
 * @ingroup Maintenance
33
 */
34
class PopulateParentId extends LoggedUpdateMaintenance {
35
	public function __construct() {
36
		parent::__construct();
37
		$this->addDescription( 'Populates rev_parent_id' );
38
	}
39
40
	protected function getUpdateKey() {
41
		return 'populate rev_parent_id';
42
	}
43
44
	protected function updateSkippedMessage() {
45
		return 'rev_parent_id column of revision table already populated.';
46
	}
47
48
	protected function doDBUpdates() {
49
		$db = $this->getDB( DB_MASTER );
50
		if ( !$db->tableExists( 'revision' ) ) {
51
			$this->error( "revision table does not exist" );
52
53
			return false;
54
		}
55
		$this->output( "Populating rev_parent_id column\n" );
56
		$start = $db->selectField( 'revision', 'MIN(rev_id)', false, __FUNCTION__ );
57
		$end = $db->selectField( 'revision', 'MAX(rev_id)', false, __FUNCTION__ );
58
		if ( is_null( $start ) || is_null( $end ) ) {
59
			$this->output( "...revision table seems to be empty, nothing to do.\n" );
60
61
			return true;
62
		}
63
		# Do remaining chunk
64
		$blockStart = intval( $start );
65
		$blockEnd = intval( $start ) + $this->mBatchSize - 1;
66
		$count = 0;
67
		$changed = 0;
68
		while ( $blockStart <= $end ) {
69
			$this->output( "...doing rev_id from $blockStart to $blockEnd\n" );
70
			$cond = "rev_id BETWEEN $blockStart AND $blockEnd";
71
			$res = $db->select( 'revision',
72
				[ 'rev_id', 'rev_page', 'rev_timestamp', 'rev_parent_id' ],
73
				[ $cond, 'rev_parent_id' => null ], __METHOD__ );
74
			# Go through and update rev_parent_id from these rows.
75
			# Assume that the previous revision of the title was
76
			# the original previous revision of the title when the
77
			# edit was made...
78
			foreach ( $res as $row ) {
79
				# First, check rows with the same timestamp other than this one
80
				# with a smaller rev ID. The highest ID "wins". This avoids loops
81
				# as timestamp can only decrease and never loops with IDs (from parent to parent)
82
				$previousID = $db->selectField( 'revision', 'rev_id',
83
					[ 'rev_page' => $row->rev_page, 'rev_timestamp' => $row->rev_timestamp,
84
						"rev_id < " . intval( $row->rev_id ) ],
85
					__METHOD__,
86
					[ 'ORDER BY' => 'rev_id DESC' ] );
87
				# If there are none, check the highest ID with a lower timestamp
88
				if ( !$previousID ) {
89
					# Get the highest older timestamp
90
					$lastTimestamp = $db->selectField(
91
						'revision',
92
						'rev_timestamp',
93
						[
94
							'rev_page' => $row->rev_page,
95
							"rev_timestamp < " . $db->addQuotes( $row->rev_timestamp )
96
						],
97
						__METHOD__,
98
						[ 'ORDER BY' => 'rev_timestamp DESC' ]
99
					);
100
					# If there is one, let the highest rev ID win
101 View Code Duplication
					if ( $lastTimestamp ) {
102
						$previousID = $db->selectField( 'revision', 'rev_id',
103
							[ 'rev_page' => $row->rev_page, 'rev_timestamp' => $lastTimestamp ],
104
							__METHOD__,
105
							[ 'ORDER BY' => 'rev_id DESC' ] );
106
					}
107
				}
108
				$previousID = intval( $previousID );
109
				if ( $previousID != $row->rev_parent_id ) {
110
					$changed++;
111
				}
112
				# Update the row...
113
				$db->update( 'revision',
114
					[ 'rev_parent_id' => $previousID ],
115
					[ 'rev_id' => $row->rev_id ],
116
					__METHOD__ );
117
				$count++;
118
			}
119
			$blockStart += $this->mBatchSize;
120
			$blockEnd += $this->mBatchSize;
121
			wfWaitForSlaves();
0 ignored issues
show
Deprecated Code introduced by
The function wfWaitForSlaves() has been deprecated with message: since 1.27 Use LBFactory::waitForReplication

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
122
		}
123
		$this->output( "rev_parent_id population complete ... {$count} rows [{$changed} changed]\n" );
124
125
		return true;
126
	}
127
}
128
129
$maintClass = "PopulateParentId";
130
require_once RUN_MAINTENANCE_IF_MAIN;
131