run:R W Run
7.85 KB
2026-03-11 16:18:51
R W Run
3.54 KB
2026-03-11 16:18:51
R W Run
148.33 KB
2026-03-11 16:18:51
R W Run
11.45 KB
2026-03-11 16:18:51
R W Run
3.58 KB
2026-03-11 16:18:51
R W Run
2.53 KB
2026-03-11 16:18:51
R W Run
2.6 KB
2026-03-11 16:18:51
R W Run
6.59 KB
2026-03-11 16:18:51
R W Run
14.83 KB
2026-03-11 16:18:51
R W Run
21.18 KB
2026-03-11 16:18:51
R W Run
48.13 KB
2026-03-11 16:18:51
R W Run
4.07 KB
2026-03-11 16:18:51
R W Run
5.3 KB
2026-03-11 16:18:51
R W Run
8.28 KB
2026-03-11 16:18:51
R W Run
26.73 KB
2026-03-11 16:18:51
R W Run
2.8 KB
2026-03-11 16:18:51
R W Run
15.2 KB
2026-03-11 16:18:51
R W Run
192.08 KB
2026-03-11 16:18:51
R W Run
11.77 KB
2026-03-11 16:18:51
R W Run
3.2 KB
2026-03-11 16:18:51
R W Run
22.89 KB
2026-03-11 16:18:51
R W Run
12.77 KB
2026-03-11 16:18:51
R W Run
4.08 KB
2026-03-11 16:18:51
R W Run
26.27 KB
2026-03-11 16:18:51
R W Run
4.97 KB
2026-03-11 16:18:51
R W Run
5.57 KB
2026-03-11 16:18:51
R W Run
13.93 KB
2026-03-11 16:18:51
R W Run
4.09 KB
2026-03-11 16:18:51
R W Run
6.79 KB
2026-03-11 16:18:51
R W Run
60.45 KB
2026-03-11 16:18:51
R W Run
32.4 KB
2026-03-11 16:18:51
R W Run
18.24 KB
2026-03-11 16:18:51
R W Run
66.01 KB
2026-03-11 16:18:51
R W Run
23.84 KB
2026-03-11 16:18:51
R W Run
17.72 KB
2026-03-11 16:18:51
R W Run
22.71 KB
2026-03-11 16:18:51
R W Run
18.05 KB
2026-03-11 16:18:51
R W Run
22.76 KB
2026-03-11 16:18:51
R W Run
7.34 KB
2026-03-11 16:18:51
R W Run
4.51 KB
2026-03-11 16:18:51
R W Run
9.02 KB
2026-03-11 16:18:51
R W Run
1.46 KB
2026-03-11 16:18:51
R W Run
51.76 KB
2026-03-11 16:18:51
R W Run
25.29 KB
2026-03-11 16:18:51
R W Run
21.61 KB
2026-03-11 16:18:51
R W Run
27.77 KB
2026-03-11 16:18:51
R W Run
15.35 KB
2026-03-11 16:18:51
R W Run
24.54 KB
2026-03-11 16:18:51
R W Run
56.44 KB
2026-03-11 16:18:51
R W Run
1.42 KB
2026-03-11 16:18:51
R W Run
63.66 KB
2026-03-11 16:18:51
R W Run
31.9 KB
2026-03-11 16:18:51
R W Run
14.44 KB
2026-03-11 16:18:51
R W Run
36.47 KB
2026-03-11 16:18:51
R W Run
14 KB
2026-03-11 16:18:51
R W Run
121.89 KB
2026-03-11 16:18:51
R W Run
6.26 KB
2026-03-11 16:18:51
R W Run
20.73 KB
2026-03-11 16:18:51
R W Run
15.23 KB
2026-03-11 16:18:51
R W Run
10.14 KB
2026-03-11 16:18:51
R W Run
6.94 KB
2026-03-11 16:18:51
R W Run
1.44 KB
2026-03-11 16:18:51
R W Run
46.85 KB
2026-03-11 16:18:51
R W Run
18.61 KB
2026-03-11 16:18:51
R W Run
6.08 KB
2026-03-11 16:18:51
R W Run
20.06 KB
2026-03-11 16:18:51
R W Run
5.73 KB
2026-03-11 16:18:51
R W Run
68.18 KB
2026-03-11 16:18:51
R W Run
40.8 KB
2026-03-11 16:18:51
R W Run
1.44 KB
2026-03-11 16:18:51
R W Run
25.26 KB
2026-03-11 16:18:51
R W Run
95.94 KB
2026-03-11 16:18:51
R W Run
43.12 KB
2026-03-11 16:18:51
R W Run
41.73 KB
2026-03-11 16:18:51
R W Run
6.46 KB
2026-03-11 16:18:51
R W Run
3.71 KB
2026-03-11 16:18:51
R W Run
116.31 KB
2026-03-11 16:18:51
R W Run
9.39 KB
2026-03-11 16:18:51
R W Run
64.34 KB
2026-03-11 16:18:51
R W Run
44.73 KB
2026-03-11 16:18:51
R W Run
1.27 KB
2026-03-11 16:18:51
R W Run
3.68 KB
2026-03-11 16:18:51
R W Run
33.53 KB
2026-03-11 16:18:51
R W Run
48.84 KB
2026-03-11 16:18:51
R W Run
26.35 KB
2026-03-11 16:18:51
R W Run
1.12 KB
2026-03-11 16:18:51
R W Run
4.19 KB
2026-03-11 16:18:51
R W Run
38.19 KB
2026-03-11 16:18:51
R W Run
91.33 KB
2026-03-11 16:18:51
R W Run
80.39 KB
2026-03-11 16:18:51
R W Run
32.67 KB
2026-03-11 16:18:51
R W Run
16.18 KB
2026-03-11 16:18:51
R W Run
44.46 KB
2026-03-11 16:18:51
R W Run
6.23 KB
2026-03-11 16:18:51
R W Run
8.23 KB
2026-03-11 16:18:51
R W Run
96.96 KB
2026-03-11 16:18:51
R W Run
6.83 KB
2026-03-11 16:18:51
R W Run
46.62 KB
2026-03-11 16:18:51
R W Run
10.82 KB
2026-03-11 16:18:51
R W Run
68.86 KB
2026-03-11 16:18:51
R W Run
33.63 KB
2026-03-11 16:18:51
R W Run
113.3 KB
2026-03-11 16:18:51
R W Run
22.98 KB
2026-03-11 16:18:51
R W Run
10.66 KB
2026-03-11 16:18:51
R W Run
error_log
📄class-wp-importer.php
1<?php
2/**
3 * WP_Importer base class
4 */
5#[AllowDynamicProperties]
6class WP_Importer {
7 /**
8 * Class Constructor
9 */
10 public function __construct() {}
11
12 /**
13 * Returns array with imported permalinks from WordPress database.
14 *
15 * @global wpdb $wpdb WordPress database abstraction object.
16 *
17 * @param string $importer_name
18 * @param string $blog_id
19 * @return array
20 */
21 public function get_imported_posts( $importer_name, $blog_id ) {
22 global $wpdb;
23
24 $hashtable = array();
25
26 $limit = 100;
27 $offset = 0;
28
29 // Grab all posts in chunks.
30 do {
31 $meta_key = $importer_name . '_' . $blog_id . '_permalink';
32 $results = $wpdb->get_results(
33 $wpdb->prepare(
34 "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s LIMIT %d,%d",
35 $meta_key,
36 $offset,
37 $limit
38 )
39 );
40
41 // Increment offset.
42 $offset = ( $limit + $offset );
43
44 if ( ! empty( $results ) ) {
45 foreach ( $results as $r ) {
46 // Set permalinks into array.
47 $hashtable[ $r->meta_value ] = (int) $r->post_id;
48 }
49 }
50 } while ( count( $results ) === $limit );
51
52 return $hashtable;
53 }
54
55 /**
56 * Returns count of imported permalinks from WordPress database.
57 *
58 * @global wpdb $wpdb WordPress database abstraction object.
59 *
60 * @param string $importer_name
61 * @param string $blog_id
62 * @return int
63 */
64 public function count_imported_posts( $importer_name, $blog_id ) {
65 global $wpdb;
66
67 $count = 0;
68
69 // Get count of permalinks.
70 $meta_key = $importer_name . '_' . $blog_id . '_permalink';
71 $result = $wpdb->get_results(
72 $wpdb->prepare(
73 "SELECT COUNT( post_id ) AS cnt FROM $wpdb->postmeta WHERE meta_key = %s",
74 $meta_key
75 )
76 );
77
78 if ( ! empty( $result ) ) {
79 $count = (int) $result[0]->cnt;
80 }
81
82 return $count;
83 }
84
85 /**
86 * Sets array with imported comments from WordPress database.
87 *
88 * @global wpdb $wpdb WordPress database abstraction object.
89 *
90 * @param string $blog_id
91 * @return array
92 */
93 public function get_imported_comments( $blog_id ) {
94 global $wpdb;
95
96 $hashtable = array();
97
98 $limit = 100;
99 $offset = 0;
100
101 // Grab all comments in chunks.
102 do {
103 $results = $wpdb->get_results(
104 $wpdb->prepare(
105 "SELECT comment_ID, comment_agent FROM $wpdb->comments LIMIT %d,%d",
106 $offset,
107 $limit
108 )
109 );
110
111 // Increment offset.
112 $offset = ( $limit + $offset );
113
114 if ( ! empty( $results ) ) {
115 foreach ( $results as $r ) {
116 // Explode comment_agent key.
117 list ( $comment_agent_blog_id, $source_comment_id ) = explode( '-', $r->comment_agent );
118
119 $source_comment_id = (int) $source_comment_id;
120
121 // Check if this comment came from this blog.
122 if ( (int) $blog_id === (int) $comment_agent_blog_id ) {
123 $hashtable[ $source_comment_id ] = (int) $r->comment_ID;
124 }
125 }
126 }
127 } while ( count( $results ) === $limit );
128
129 return $hashtable;
130 }
131
132 /**
133 * @param int $blog_id
134 * @return int|void
135 */
136 public function set_blog( $blog_id ) {
137 if ( is_numeric( $blog_id ) ) {
138 $blog_id = (int) $blog_id;
139 } else {
140 $blog = 'http://' . preg_replace( '#^https?://#', '', $blog_id );
141 $parsed = parse_url( $blog );
142 if ( ! $parsed || empty( $parsed['host'] ) ) {
143 fwrite( STDERR, "Error: can not determine blog_id from $blog_id\n" );
144 exit;
145 }
146 if ( empty( $parsed['path'] ) ) {
147 $parsed['path'] = '/';
148 }
149 $blogs = get_sites(
150 array(
151 'domain' => $parsed['host'],
152 'number' => 1,
153 'path' => $parsed['path'],
154 )
155 );
156 if ( ! $blogs ) {
157 fwrite( STDERR, "Error: Could not find blog\n" );
158 exit;
159 }
160 $blog = array_shift( $blogs );
161 $blog_id = (int) $blog->blog_id;
162 }
163
164 if ( function_exists( 'is_multisite' ) ) {
165 if ( is_multisite() ) {
166 switch_to_blog( $blog_id );
167 }
168 }
169
170 return $blog_id;
171 }
172
173 /**
174 * @param int $user_id
175 * @return int|void
176 */
177 public function set_user( $user_id ) {
178 if ( is_numeric( $user_id ) ) {
179 $user_id = (int) $user_id;
180 } else {
181 $user_id = (int) username_exists( $user_id );
182 }
183
184 if ( ! $user_id || ! wp_set_current_user( $user_id ) ) {
185 fwrite( STDERR, "Error: can not find user\n" );
186 exit;
187 }
188
189 return $user_id;
190 }
191
192 /**
193 * Sorts by strlen, longest string first.
194 *
195 * @param string $a
196 * @param string $b
197 * @return int
198 */
199 public function cmpr_strlen( $a, $b ) {
200 return strlen( $b ) - strlen( $a );
201 }
202
203 /**
204 * Gets URL.
205 *
206 * @param string $url
207 * @param string $username
208 * @param string $password
209 * @param bool $head
210 * @return array
211 */
212 public function get_page(
213 $url,
214 $username = '',
215 #[\SensitiveParameter]
216 $password = '',
217 $head = false
218 ) {
219 // Increase the timeout.
220 add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
221
222 $headers = array();
223 $args = array();
224 if ( true === $head ) {
225 $args['method'] = 'HEAD';
226 }
227 if ( ! empty( $username ) && ! empty( $password ) ) {
228 $headers['Authorization'] = 'Basic ' . base64_encode( "$username:$password" );
229 }
230
231 $args['headers'] = $headers;
232
233 return wp_safe_remote_request( $url, $args );
234 }
235
236 /**
237 * Bumps up the request timeout for http requests.
238 *
239 * @param int $val
240 * @return int
241 */
242 public function bump_request_timeout( $val ) {
243 return 60;
244 }
245
246 /**
247 * Checks if user has exceeded disk quota.
248 *
249 * @return bool
250 */
251 public function is_user_over_quota() {
252 if ( function_exists( 'upload_is_user_over_quota' ) ) {
253 if ( upload_is_user_over_quota() ) {
254 return true;
255 }
256 }
257
258 return false;
259 }
260
261 /**
262 * Replaces newlines, tabs, and multiple spaces with a single space.
263 *
264 * @param string $text
265 * @return string
266 */
267 public function min_whitespace( $text ) {
268 return preg_replace( '|[\r\n\t ]+|', ' ', $text );
269 }
270
271 /**
272 * Resets global variables that grow out of control during imports.
273 *
274 * @since 3.0.0
275 *
276 * @global wpdb $wpdb WordPress database abstraction object.
277 * @global int[] $wp_actions
278 */
279 public function stop_the_insanity() {
280 global $wpdb, $wp_actions;
281 // Or define( 'WP_IMPORTING', true );
282 $wpdb->queries = array();
283 // Reset $wp_actions to keep it from growing out of control.
284 $wp_actions = array();
285 }
286}
287
288/**
289 * Returns value of command line params.
290 * Exits when a required param is not set.
291 *
292 * @param string $param
293 * @param bool $required
294 * @return mixed
295 */
296function get_cli_args( $param, $required = false ) {
297 $args = $_SERVER['argv'];
298 if ( ! is_array( $args ) ) {
299 $args = array();
300 }
301
302 $out = array();
303
304 $last_arg = null;
305 $return = null;
306
307 $il = count( $args );
308
309 for ( $i = 1, $il; $i < $il; $i++ ) {
310 if ( (bool) preg_match( '/^--(.+)/', $args[ $i ], $match ) ) {
311 $parts = explode( '=', $match[1] );
312 $key = preg_replace( '/[^a-z0-9]+/', '', $parts[0] );
313
314 if ( isset( $parts[1] ) ) {
315 $out[ $key ] = $parts[1];
316 } else {
317 $out[ $key ] = true;
318 }
319
320 $last_arg = $key;
321 } elseif ( (bool) preg_match( '/^-([a-zA-Z0-9]+)/', $args[ $i ], $match ) ) {
322 for ( $j = 0, $jl = strlen( $match[1] ); $j < $jl; $j++ ) {
323 $key = $match[1][ $j ];
324 $out[ $key ] = true;
325 }
326
327 $last_arg = $key;
328 } elseif ( null !== $last_arg ) {
329 $out[ $last_arg ] = $args[ $i ];
330 }
331 }
332
333 // Check array for specified param.
334 if ( isset( $out[ $param ] ) ) {
335 // Set return value.
336 $return = $out[ $param ];
337 }
338
339 // Check for missing required param.
340 if ( ! isset( $out[ $param ] ) && $required ) {
341 // Display message and exit.
342 echo "\"$param\" parameter is required but was not specified\n";
343 exit;
344 }
345
346 return $return;
347}
348