Issues (2756)

admin/upgrade.php (19 issues)

1
<?php
2
define( 'YOURLS_ADMIN', true );
3
define( 'YOURLS_UPGRADING', true );
4
require_once( dirname( __DIR__ ).'/includes/load-yourls.php' );
5
require_once( YOURLS_INC.'/functions-upgrade.php' );
6
require_once( YOURLS_INC.'/functions-install.php' );
7
yourls_maybe_require_auth();
8
9
yourls_html_head( 'upgrade', yourls__( 'Upgrade YOURLS' ) );
10
yourls_html_logo();
11
yourls_html_menu();
12
?>
13
		<h2><?php yourls_e( 'Upgrade YOURLS' ); ?></h2>
14
<?php
15
0 ignored issues
show
Blank line found at start of embedded PHP content
Loading history...
16
// Check if upgrade is needed
17
if ( !yourls_upgrade_is_needed() ) {
18
	echo '<p>' . yourls_s( 'Upgrade not required. Go <a href="%s">back to play</a>!', yourls_admin_url('index.php') ) . '</p>';
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 124 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
19
20
21
} else {
22
	/*
23
	step 1: create new tables and populate them, update old tables structure,
0 ignored issues
show
First line of comment not aligned correctly; expected 5 spaces but found 1
Loading history...
Block comments must start with a capital letter
Loading history...
24
	step 2: convert each row of outdated tables if needed
0 ignored issues
show
Comment line indented incorrectly; expected at least 5 spaces but found 1
Loading history...
25
	step 3: - if applicable finish updating outdated tables (indexes etc)
0 ignored issues
show
Comment line indented incorrectly; expected at least 5 spaces but found 1
Loading history...
26
	        - update version & db_version in options, this is all done!
27
	*/
28
29
	// From what are we upgrading?
30
	if ( isset( $_GET['oldver'] ) && isset( $_GET['oldsql'] ) ) {
31
		$oldver = (string)( $_GET['oldver'] );
32
		$oldsql = (string)( $_GET['oldsql'] );
33
	} else {
34
		list( $oldver, $oldsql ) = yourls_get_current_version_from_sql();
35
	}
36
37
	// To what are we upgrading ?
38
	$newver = YOURLS_VERSION;
39
	$newsql = YOURLS_DB_VERSION;
40
41
	// Verbose & ugly details
42
	yourls_debug_mode(true);
43
44
	// Let's go
45
	$step = ( isset( $_GET['step'] ) ? intval( $_GET['step'] ) : 0 );
46
	switch( $step ) {
47
48
		default:
49
		case 0:
50
			?>
51
			<p><?php yourls_e( 'Your current installation needs to be upgraded.' ); ?></p>
52
			<p><?php yourls_e( 'Please, pretty please, it is recommended that you <strong>backup</strong> your database<br/>(you should do this regularly anyway)' ); ?></p>
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 163 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
53
			<p><?php yourls_e( "Nothing awful <em>should</em> happen, but this doesn't mean it <em>won't</em> happen, right? ;)" ); ?></p>
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 129 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
54
			<p><?php yourls_e( "On every step, if <span class='error'>something goes wrong</span>, you'll see a message and hopefully a way to fix." ); ?></p>
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 149 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
55
			<p><?php yourls_e( 'If everything goes too fast and you cannot read, <span class="success">good for you</span>, let it go :)' ); ?></p>
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 138 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
56
			<p><?php yourls_e( 'Once you are ready, press "Upgrade" !' ); ?></p>
57
			<?php
58
			echo "
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $oldver instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $newver instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $oldsql instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $newsql instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
59
			<form action='upgrade.php?' method='get'>
60
			<input type='hidden' name='step' value='1' />
61
			<input type='hidden' name='oldver' value='$oldver' />
62
			<input type='hidden' name='newver' value='$newver' />
63
			<input type='hidden' name='oldsql' value='$oldsql' />
64
			<input type='hidden' name='newsql' value='$newsql' />
65
			<input type='submit' class='primary' value='" . yourls_esc_attr__( 'Upgrade' ) . "' />
66
			</form>";
67
68
			break;
0 ignored issues
show
Case breaking statement indented incorrectly; expected 6 spaces, found 3
Loading history...
69
70
		case 1:
71
		case 2:
72
			$upgrade = yourls_upgrade( $step, $oldver, $newver, $oldsql, $newsql );
0 ignored issues
show
Are you sure the assignment to $upgrade is correct as yourls_upgrade($step, $o...wver, $oldsql, $newsql) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
73
			break;
0 ignored issues
show
Case breaking statement indented incorrectly; expected 6 spaces, found 3
Loading history...
74
75
		case 3:
76
			$upgrade = yourls_upgrade( 3, $oldver, $newver, $oldsql, $newsql );
0 ignored issues
show
Are you sure the assignment to $upgrade is correct as yourls_upgrade(3, $oldve...wver, $oldsql, $newsql) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
77
			echo '<p>' . yourls__( 'Your installation is now up to date ! ' ) . '</p>';
78
			echo '<p>' . yourls_s( 'Go back to <a href="%s">the admin interface</a>', yourls_admin_url('index.php') ) . '</p>';
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 118 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
79
	}
80
81
}
82
83
?>
84
85
<?php yourls_html_footer(); ?>
86