1 | <?php |
||||
2 | /** |
||||
3 | * CLI |
||||
4 | * |
||||
5 | * @author Pronamic <[email protected]> |
||||
6 | * @copyright 2005-2020 Pronamic |
||||
7 | * @license GPL-3.0-or-later |
||||
8 | * @package Pronamic\WordPress\Pay\Mollie |
||||
9 | */ |
||||
10 | |||||
11 | namespace Pronamic\WordPress\Pay\Gateways\Mollie; |
||||
12 | |||||
13 | /** |
||||
14 | * Title: CLI |
||||
15 | * Description: |
||||
16 | * Copyright: 2005-2020 Pronamic |
||||
17 | * Company: Pronamic |
||||
18 | * |
||||
19 | * @author Remco Tolsma |
||||
20 | * @version 3.0.0 |
||||
21 | * @since 3.0.0 |
||||
22 | * @link https://github.com/woocommerce/woocommerce/blob/3.9.0/includes/class-wc-cli.php |
||||
23 | */ |
||||
24 | class CLI { |
||||
25 | /** |
||||
26 | * Construct CLI. |
||||
27 | */ |
||||
28 | public function __construct() { |
||||
29 | \WP_CLI::add_command( |
||||
0 ignored issues
–
show
|
|||||
30 | 'pronamic-pay mollie organizations synchronize', |
||||
31 | function( $args, $assoc_args ) { |
||||
32 | $this->wp_cli_organizations_synchronize( $args, $assoc_args ); |
||||
33 | } |
||||
34 | ); |
||||
35 | |||||
36 | \WP_CLI::add_command( |
||||
37 | 'pronamic-pay mollie customers synchronize', |
||||
38 | function( $args, $assoc_args ) { |
||||
39 | $this->wp_cli_customers_synchronize( $args, $assoc_args ); |
||||
40 | } |
||||
41 | ); |
||||
42 | |||||
43 | \WP_CLI::add_command( |
||||
44 | 'pronamic-pay mollie customers connect-wp-users', |
||||
45 | function( $args, $assoc_args ) { |
||||
46 | $this->wp_cli_customers_connect_wp_users( $args, $assoc_args ); |
||||
47 | } |
||||
48 | ); |
||||
49 | } |
||||
50 | |||||
51 | /** |
||||
52 | * CLI organizations synchronize. |
||||
53 | * |
||||
54 | * @link https://docs.mollie.com/reference/v2/organizations-api/current-organization |
||||
55 | * @param array $args Arguments. |
||||
56 | * @param array $assoc_args Associative arguments. |
||||
57 | */ |
||||
58 | public function wp_cli_organizations_synchronize( $args, $assoc_args ) { |
||||
59 | \WP_CLI::error( 'Command not implemented yet.' ); |
||||
60 | } |
||||
61 | |||||
62 | /** |
||||
63 | * CLI customers synchronize. |
||||
64 | * |
||||
65 | * @link https://docs.mollie.com/reference/v2/customers-api/list-customers |
||||
66 | * @param array $args Arguments. |
||||
67 | * @param array $assoc_args Associative arguments. |
||||
68 | */ |
||||
69 | public function wp_cli_customers_synchronize( $args, $assoc_args ) { |
||||
70 | global $post; |
||||
71 | |||||
72 | $query = new \WP_Query( |
||||
73 | array( |
||||
74 | 'post_type' => 'pronamic_gateway', |
||||
75 | 'post_status' => 'publish', |
||||
76 | 'nopaging' => true, |
||||
77 | 'meta_query' => array( |
||||
78 | array( |
||||
79 | 'key' => '_pronamic_gateway_id', |
||||
80 | 'value' => 'mollie', |
||||
81 | ), |
||||
82 | array( |
||||
83 | 'key' => '_pronamic_gateway_mollie_api_key', |
||||
84 | 'compare' => 'EXISTS', |
||||
85 | ), |
||||
86 | ), |
||||
87 | ) |
||||
88 | ); |
||||
89 | |||||
90 | if ( $query->have_posts() ) { |
||||
91 | while ( $query->have_posts() ) { |
||||
92 | $query->the_post(); |
||||
93 | |||||
94 | $api_key = get_post_meta( $post->ID, '_pronamic_gateway_mollie_api_key', true ); |
||||
95 | |||||
96 | \WP_CLI::log( $post->post_title ); |
||||
97 | \WP_CLI::log( $api_key ); |
||||
98 | \WP_CLI::log( '' ); |
||||
99 | |||||
100 | $client = new Client( $api_key ); |
||||
0 ignored issues
–
show
It seems like
$api_key can also be of type false ; however, parameter $api_key of Pronamic\WordPress\Pay\G...e\Client::__construct() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
101 | } |
||||
102 | |||||
103 | \wp_reset_postdata(); |
||||
104 | } |
||||
105 | |||||
106 | \WP_CLI::error( 'Command not fully implemented yet.' ); |
||||
107 | } |
||||
108 | |||||
109 | /** |
||||
110 | * CLI connect Mollie customers to WordPress users. |
||||
111 | * |
||||
112 | * @link https://docs.mollie.com/reference/v2/customers-api/list-customers |
||||
113 | * @link https://make.wordpress.org/cli/handbook/internal-api/wp-cli-add-command/ |
||||
114 | * @link https://developer.wordpress.org/reference/classes/wpdb/query/ |
||||
115 | * @param array $args Arguments. |
||||
116 | * @param array $assoc_args Associative arguments. |
||||
117 | */ |
||||
118 | public function wp_cli_customers_connect_wp_users( $args, $assoc_args ) { |
||||
119 | global $wpdb; |
||||
120 | |||||
121 | $query = " |
||||
122 | INSERT IGNORE INTO $wpdb->pronamic_pay_mollie_customer_users ( |
||||
123 | customer_id, |
||||
124 | user_id |
||||
125 | ) |
||||
126 | SELECT |
||||
127 | mollie_customer.id AS mollie_customer_id, |
||||
128 | wp_user.ID AS wp_user_id |
||||
129 | FROM |
||||
130 | $wpdb->pronamic_pay_mollie_customers AS mollie_customer |
||||
131 | INNER JOIN |
||||
132 | $wpdb->users AS wp_user |
||||
133 | ON mollie_customer.email = wp_user.user_email |
||||
134 | ; |
||||
135 | "; |
||||
136 | |||||
137 | $result = $wpdb->query( $query ); |
||||
138 | |||||
139 | if ( false === $result ) { |
||||
140 | \WP_CLI::error( |
||||
141 | sprintf( |
||||
142 | 'Database error: %s.', |
||||
143 | $wpdb->last_error |
||||
144 | ) |
||||
145 | ); |
||||
146 | } |
||||
147 | |||||
148 | \WP_CLI::log( |
||||
149 | sprintf( |
||||
150 | 'Connected %d users and Mollie customers.', |
||||
151 | $result |
||||
152 | ) |
||||
153 | ); |
||||
154 | } |
||||
155 | } |
||||
156 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths