GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (1495)

version.php (66 issues)

1
<?php 
2
/**
3
 * Version management for database migrations.
4
 * 
5
 * Database changes require special care:
6
 * - the model has to be adjusted for users installing the plugin
7
 * - the current setup has to be migrated for current users
8
 * 
9
 * These migrations are a way to handle current users. They do *not*
10
 * run on plugin activation.
11
 * 
12
 * Pattern:
13
 * 
14
 * - increment \PodloveSubscribeButton\DATABASE_VERSION constant by 1, e.g.
15
 * 		```php
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
16
 * 		define( __NAMESPACE__ . '\DATABASE_VERSION', 2 );
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
17
 * 		```
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
18
 * 		
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
19
 * - add a case in `\PodloveSubscribeButton\run_migrations_for_version`, e.g.
20
 * 		```php
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
21
 * 		function run_migrations_for_version( $version ) {
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
22
 *			global $wpdb;
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
23
 *			switch ( $version ) {
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
24
 *				case 2:
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
25
 *					$wbdb-> // run sql or whatever
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
26
 *					break;
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
27
 *			}
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
28
 *		}
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
29
 *		```
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
30
 *		
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
31
 *		Feel free to move the migration code into a separate function if it's
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
32
 *		rather complex.
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
33
 *		
0 ignored issues
show
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
34
 * - adjust the main model / setup process so new users installing the plugin
35
 *   will have these changes too
36
 *   
37
 * - Test the migrations! :)
38
 */
0 ignored issues
show
Coding Style Documentation introduced by
Missing @package tag in file comment
Loading history...
39
40
namespace PodloveSubscribeButton;
41
use \PodloveSubscribeButton\Model;
0 ignored issues
show
The type \PodloveSubscribeButton\Model was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
42
43
define( __NAMESPACE__ . '\DATABASE_VERSION', 2 );
44
45
add_action( 'admin_init', '\PodloveSubscribeButton\maybe_run_database_migrations' );
46
add_action( 'admin_init', '\PodloveSubscribeButton\run_database_migrations', 5 );
47
48
function maybe_run_database_migrations() {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for function maybe_run_database_migrations()
Loading history...
49
	$database_version = get_option('podlove_subscribe_button_plugin_database_version');
0 ignored issues
show
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
50
51
	if ( $database_version === false ) {
0 ignored issues
show
Use Yoda Condition checks, you must.
Loading history...
52
		// plugin has just been installed or Plugin Version < 1.3
0 ignored issues
show
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
53
		update_option( 'podlove_subscribe_button_plugin_database_version', DATABASE_VERSION );
54
	}
55
}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
56
57
function run_database_migrations() {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for function run_database_migrations()
Loading history...
58
	if (get_option('podlove_subscribe_button_plugin_database_version') >= DATABASE_VERSION)
0 ignored issues
show
Coding Style Best Practice introduced by
It is generally a best practice to always use braces with control structures.

Adding braces to control structures avoids accidental mistakes as your code changes:

// Without braces (not recommended)
if (true)
    doSomething();

// Recommended
if (true) {
    doSomething();
}
Loading history...
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
59
		return;
60
61
	if (is_multisite()) {
0 ignored issues
show
No space after opening parenthesis is prohibited
Loading history...
No space before closing parenthesis is prohibited
Loading history...
62
		set_time_limit(0); // may take a while, depending on network size
0 ignored issues
show
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
63
		\PodloveSubscribeButton\for_every_podcast_blog(function() { migrate_for_current_blog(); });
0 ignored issues
show
Opening brace must be the last content on the line
Loading history...
Closing brace of nested function must be on a new line
Loading history...
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
64
	} else {
65
		migrate_for_current_blog();
66
	}
67
68
	if (isset($_REQUEST['_wp_http_referer']) && $_REQUEST['_wp_http_referer']) {
0 ignored issues
show
No space after opening parenthesis is prohibited
Loading history...
Processing form data without nonce verification.
Loading history...
Missing wp_unslash() before sanitization.
Loading history...
Detected usage of a non-sanitized input variable: $_REQUEST
Loading history...
No space before closing parenthesis is prohibited
Loading history...
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
69
		wp_redirect($_REQUEST['_wp_http_referer']);
0 ignored issues
show
wp_redirect() found. Using wp_safe_redirect(), along with the allowed_redirect_hosts filter if needed, can help avoid any chances of malicious redirects within code. It is also important to remember to call exit() after a redirect so that no other unwanted code is executed.
Loading history...
Missing wp_unslash() before sanitization.
Loading history...
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
70
		exit;
71
	}
72
}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
73
74
function migrate_for_current_blog() {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for function migrate_for_current_blog()
Loading history...
75
	$database_version = get_option('podlove_subscribe_button_plugin_database_version');
0 ignored issues
show
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
76
77
	for ($i = $database_version+1; $i <= DATABASE_VERSION; $i++) { 
0 ignored issues
show
No space after opening parenthesis is prohibited
Loading history...
Expected 1 space before "+"; 0 found
Loading history...
Expected 1 space after "+"; 0 found
Loading history...
No space before closing parenthesis is prohibited
Loading history...
78
		\PodloveSubscribeButton\run_migrations_for_version($i);
0 ignored issues
show
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
79
		update_option('podlove_subscribe_button_plugin_database_version', $i);
0 ignored issues
show
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
80
	}
81
}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
82
83
/**
84
 * Find and run migration for given version number.
85
 *
86
 * @todo  move migrations into separate files
87
 * 
88
 * @param  int $version
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
89
 */
90
function run_migrations_for_version( $version ) {
91
	global $wpdb;
92
	
93
	switch ( $version ) {}
0 ignored issues
show
This switch statement is empty, and could be removed.

This check looks for switch statements that have no cases or where all cases have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

Consider removing the switch.

Loading history...
94
95
}