Fixed: CodeFactor issues

This commit is contained in:
Bogdan Rapaić 2020-04-22 20:05:24 +02:00 committed by GitHub
parent d6e53806ad
commit 25ea8e91b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 98 additions and 95 deletions

View file

@ -1818,17 +1818,7 @@ class MainWP_Child_Back_Up_Buddy {
$profile_array = pb_backupbuddy::$options['profiles'][ $requested_profile ];
$serial_override = pb_backupbuddy::random_string( 10 );
if ( $newBackup->start_backup_process(
$profile_array,
'manual',
array(),
isset( $_POST['post_backup_steps'] ) && is_array( $_POST['post_backup_steps'] ) ? $_POST['post_backup_steps'] : array(),
'',
$serial_override,
'',
'',
''
) !== true ) {
if ( true !== $newBackup->start_backup_process( $profile_array, 'manual', array(), isset( $_POST['post_backup_steps'] ) && is_array( $_POST['post_backup_steps'] ) ? $_POST['post_backup_steps'] : array(), '', $serial_override, '', '', '' ) ) {
return array( 'error' => __( 'Fatal Error #4344443: Backup failure. Please see any errors listed in the Status Log for details.', 'mainwp-child' ) );
}
return array( 'result' => 'SUCCESS' );

View file

@ -761,13 +761,17 @@ class MainWP_Child_Back_WP_Up {
$without_dupes = array();
foreach ( $output->items as $key ) {
$temp_array = $key;
$temp_array['downloadurl'] = str_replace( array(
$temp_array['downloadurl'] = str_replace(
array(
'&',
network_admin_url( 'admin.php' ) . '?page=backwpupbackups&action=',
), array(
),
array(
'&',
admin_url( 'admin-ajax.php' ) . '?action=mainwp_backwpup_download_backup&type=',
), $temp_array['downloadurl'] . '&_wpnonce=' . $this->create_nonce_without_session( 'mainwp_download_backup' ) );
),
$temp_array['downloadurl'] . '&_wpnonce=' . $this->create_nonce_without_session( 'mainwp_download_backup' )
);
$temp_array['downloadurl_id'] = '/wp-admin/admin.php?page=backwpupbackups';
if ( preg_match( '/.*&jobid=([^&]+)&.*/is', $temp_array['downloadurl'], $matches ) ) {
@ -1157,14 +1161,9 @@ class MainWP_Child_Back_WP_Up {
$dir = @opendir( $main_folder_name );
if ( $dir ) {
while ( ( $file = readdir( $dir ) ) !== false ) {
if ( ! in_array( $file, array(
'.',
'..',
) ) && is_dir( $main_folder_name . '/' . $file ) && ! in_array( trailingslashit( $main_folder_name . '/' . $file ), mainwp_backwpup_get_exclude_dirs( $main_folder_name ) )
) {
while ( false !== ( $file = readdir( $dir ) ) ) {
if ( ! in_array( $file, array( '.', '..', ) ) && is_dir( $main_folder_name . '/' . $file ) && ! in_array( trailingslashit( $main_folder_name . '/' . $file ), mainwp_backwpup_get_exclude_dirs( $main_folder_name ) ) ) {
$folder_size = ' (' . size_format( BackWPup_File::get_folder_size( $main_folder_name . '/' . $file ), 2 ) . ')';
$return_temp[] = array(
'size' => $folder_size,
'name' => $file,

View file

@ -776,7 +776,9 @@ class MainWP_Child_iThemes_Security {
$wpdb->query( 'DELETE FROM `' . $wpdb->users . '` WHERE ID = 1;' );
$wpdb->insert( $wpdb->users, array(
$wpdb->insert(
$wpdb->users,
array(
'user_login' => $user_login,
'user_pass' => $user_object->user_pass,
'user_nicename' => $user_object->user_nicename,
@ -786,7 +788,8 @@ class MainWP_Child_iThemes_Security {
'user_activation_key' => $user_object->user_activation_key,
'user_status' => $user_object->user_status,
'display_name' => $user_object->display_name,
) );
)
);
if ( is_multisite() && null !== $username && validate_username( $new_user ) ) {

View file

@ -69,7 +69,8 @@ class MainWP_Child_WooCommerce_Status {
$reports = new WC_Admin_Report();
// Get sales.
$sales = $wpdb->get_var( $wpdb->prepare(
$sales = $wpdb->get_var(
$wpdb->prepare(
"SELECT SUM( postmeta.meta_value ) FROM {$wpdb->posts} as posts
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID
LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )
@ -81,11 +82,15 @@ class MainWP_Child_WooCommerce_Status {
AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' )
AND postmeta.meta_key = '_order_total'
AND posts.post_date >= %s
AND posts.post_date <= %s
", date( 'Y-m-01', $start_date ), date( 'Y-m-d H:i:s', $end_date ) ) );
AND posts.post_date <= %s",
date( 'Y-m-01', $start_date ),
date( 'Y-m-d H:i:s', $end_date )
)
);
// Get top seller.
$top_seller = $wpdb->get_row( $wpdb->prepare(
$top_seller = $wpdb->get_row(
$wpdb->prepare(
"SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id
FROM {$wpdb->posts} as posts
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID
@ -104,8 +109,11 @@ class MainWP_Child_WooCommerce_Status {
AND posts.post_date <= %s
GROUP BY product_id
ORDER BY qty DESC
LIMIT 1
", date( 'Y-m-01', $start_date ), date( 'Y-m-d H:i:s', $end_date )) );
LIMIT 1",
date( 'Y-m-01', $start_date ),
date( 'Y-m-d H:i:s', $end_date )
)
);
if ( ! empty( $top_seller ) ) {
$top_seller->name = get_the_title( $top_seller->product_id );
@ -160,7 +168,7 @@ class MainWP_Child_WooCommerce_Status {
$end_date = date( 'Y-m-d H:i:s', $end_date );
// Get sales.
$sales = $wpdb->get_var(\
$sales = $wpdb->get_var(
"SELECT SUM( postmeta.meta_value ) FROM {$wpdb->posts} as posts
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID
LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )
@ -172,8 +180,8 @@ class MainWP_Child_WooCommerce_Status {
AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' )
AND postmeta.meta_key = '_order_total'
AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s')
AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s')
" );
AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s')"
);
// Get top seller.
$top_seller = $wpdb->get_row(
@ -195,8 +203,8 @@ class MainWP_Child_WooCommerce_Status {
AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare( '%s', $end_date ) . ", '%Y-%m-%d %H:%i:%s' )
GROUP BY product_id
ORDER BY qty DESC
LIMIT 1
" );
LIMIT 1"
);
if ( ! empty( $top_seller ) ) {
$top_seller->name = get_the_title( $top_seller->product_id );

View file

@ -1198,12 +1198,15 @@ class MainWP_Clone {
MainWP_Helper::endSession();
// Send request to the childsite!
$result = MainWP_Helper::fetchUrl( $url, array(
$result = MainWP_Helper::fetchUrl(
$url,
array(
'cloneFunc' => 'createCloneBackupPoll',
'key' => $key,
'f' => $rand,
'json_result' => true,
) );
)
);
if ( ! isset( $result['size'] ) ) {
throw new Exception( __( 'Invalid response', 'mainwp-child' ) );