Fixed: data Child Reports conversion problem

Updated: version number
This commit is contained in:
thanghv 2019-12-13 20:27:05 +07:00
parent a637d0eca1
commit e843c2f2e1
4 changed files with 101 additions and 60 deletions

View file

@ -115,7 +115,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
}
class MainWP_Child {
public static $version = '4.0.5';
public static $version = '4.0.5.1';
private $update_version = '1.5';
private $callableFunctions = array(
@ -1654,10 +1654,10 @@ class MainWP_Child {
public function http_request_reject_unsafe_urls( $r, $url ) {
$r['reject_unsafe_urls'] = false;
if ( isset($_POST['wpadmin_user']) && !empty($_POST['wpadmin_user']) && isset($_POST['wpadmin_passwd']) && !empty($_POST['wpadmin_passwd']) ) {
$auth = base64_encode( $_POST['wpadmin_user'] . ':' . $_POST['wpadmin_passwd'] );
$r['headers']['Authorization'] = "Basic $auth";
}
if ( isset($_POST['wpadmin_user']) && !empty($_POST['wpadmin_user']) && isset($_POST['wpadmin_passwd']) && !empty($_POST['wpadmin_passwd']) ) {
$auth = base64_encode( $_POST['wpadmin_user'] . ':' . $_POST['wpadmin_passwd'] );
$r['headers']['Authorization'] = "Basic $auth";
}
return $r;
}
@ -1771,7 +1771,7 @@ class MainWP_Child {
} else {
activate_plugin( $path . $fileName, '' /* false, true */ );
}
do_action( 'activate_plugin', $args['slug'], null );
//do_action( 'activate_plugin', $args['slug'], null );
}
}
} else {
@ -2064,17 +2064,17 @@ class MainWP_Child {
} else {
$information['upgrades'][ $plugin ] = true;
// to fix logging update
if (isset($information['plugin_updates']) && isset($information['plugin_updates'][$plugin])) {
$plugin_info = $information['plugin_updates'][$plugin];
$args = array();
$args['type'] = 'plugin';
$args['slug'] = $plugin;
$args['name'] = $plugin_info->Name;
$args['version'] = $plugin_info->update->new_version;
$args['old_version'] = $plugin_info->Version;
$args['action'] = 'update';
do_action( 'mainwp_child_upgradePluginTheme', $args );
}
// if (isset($information['plugin_updates']) && isset($information['plugin_updates'][$plugin])) {
// $plugin_info = $information['plugin_updates'][$plugin];
// $args = array();
// $args['type'] = 'plugin';
// $args['slug'] = $plugin;
// $args['name'] = $plugin_info->Name;
// $args['version'] = $plugin_info->update->new_version;
// $args['old_version'] = $plugin_info->Version;
// $args['action'] = 'update';
// //do_action( 'mainwp_child_upgradePluginTheme', $args );
// }
}
}
$failed = false;
@ -2177,17 +2177,17 @@ class MainWP_Child {
} else {
$information['upgrades'][ $theme ] = true;
// to fix logging update
if (isset($information['theme_updates']) && isset($information['theme_updates'][$theme])) {
$theme_info = $information['theme_updates'][$theme];
$args = array();
$args['type'] = 'theme';
$args['slug'] = $theme;
$args['name'] = $theme_info['Name'];
$args['version'] = $theme_info['update']['new_version'];
$args['old_version'] = $theme_info['Version'];
$args['action'] = 'update';
do_action( 'mainwp_child_upgradePluginTheme', $args );
}
// if (isset($information['theme_updates']) && isset($information['theme_updates'][$theme])) {
// $theme_info = $information['theme_updates'][$theme];
// $args = array();
// $args['type'] = 'theme';
// $args['slug'] = $theme;
// $args['name'] = $theme_info['Name'];
// $args['version'] = $theme_info['update']['new_version'];
// $args['old_version'] = $theme_info['Version'];
// $args['action'] = 'update';
// //do_action( 'mainwp_child_upgradePluginTheme', $args );
// }
}
}
@ -4743,7 +4743,7 @@ class MainWP_Child {
// to fix activate issue
if ('quotes-collection/quotes-collection.php' == $plugin) {
activate_plugin( $plugin, '', false, true );
do_action( 'activate_plugin', $plugin, null );
//do_action( 'activate_plugin', $plugin, null );
} else {
activate_plugin( $plugin );
}

View file

@ -133,14 +133,15 @@ class MainWP_Client_Report {
'media' => 'media'
);
return isset( $mapping_contexts[ $context ] ) ? $mapping_contexts[ $context ] : $context;
$context = isset( $mapping_contexts[ $context ] ) ? $mapping_contexts[ $context ] : $context;
return strtolower($context);
}
public function get_connector_by_compatible_context( $context ) {
$connector = "";
if ( $context == "plugins" || $context == "themes" ) {
if ( $context == "plugins" || $context == "themes" || $context == "wordpress" ) {
$connector = "installer";
} else if ( $context == 'profiles' ) {
$connector = "users";
@ -444,7 +445,7 @@ class MainWP_Client_Report {
// ok, pass, do not check context
} else if ( $connector == "widgets" && $record->connector == 'widgets') {
// ok, pass, don't check context
} else if ( $context !== $record->context) {
} else if ( $context !== strtolower( $record->context )) {
continue;
}
@ -508,6 +509,26 @@ class MainWP_Client_Report {
return $token_values;
}
// function get_meta_value_from_summary( $summary, $meta ) {
// $value = '';
// if ( $meta == 'name' ) {
// $value = str_replace(array('Updated plugin:', 'Updated theme:'), '', $summary);
// $value = trim( $value );
// $last_space_pos = strrpos($value, ' ');
// if ($last_space_pos !== false) {
// $value = substr($value , 0, 0 - $last_space_pos);
// }
// } else if ( $meta == 'version') {
// $last_space_pos = strrpos($value, ' ');
// if ($last_space_pos !== false) {
// $value = substr($value , $last_space_pos);
// }
// } else if ( $meta == 'old_version' ) {
// $value = 'N/A';
// }
// return $value;
// }
function get_section_loop_data( $records, $tokens, $section, $skip_records = array() ) {
@ -556,8 +577,19 @@ class MainWP_Client_Report {
foreach ( $records as $record ) {
if (in_array($record->ID, $skip_records)) {
continue;
// $fix_meta_name = $fix_old_version = $fix_version = '';
if ( in_array($record->ID, $skip_records) ) {
// to fix incorrect meta for update logging
// if ( 'updated' === $action && ('themes' === $context || 'plugins' === $context)) {
// if ( !isset( $record->meta ) || $record->meta == '') {
// $fix_meta_name = get_meta_value_from_summary($record->summary, 'name');
// $fix_old_version = get_meta_value_from_summary($record->summary, 'old_version');
// $fix_version = get_meta_value_from_summary($record->summary, 'version');
// }
// } else {
continue;
// }
}
// check connector
@ -583,7 +615,7 @@ class MainWP_Client_Report {
} else if ( $connector == "widgets" && $record->connector == 'widgets') {
// ok, pass, don't check context
//
} else if ( $context !== $record->context ) {
} else if ( $context !== strtolower( $record->context ) ) {
continue;
}
@ -689,9 +721,16 @@ class MainWP_Client_Report {
}
$value = $this->get_stream_meta_data( $record, $data );
if ( empty( $value ) && 'comments' === $context ) {
$value = __( 'Guest', 'mainwp-child-reports' );
}
// to check may compatible with old meta data
if ( empty( $value )) {
$value = $this->get_stream_meta_data( $record, 'author_meta' );
}
$token_values[ $token ] = $value;
break;
case 'status': // sucuri cases
@ -800,24 +839,23 @@ class MainWP_Client_Report {
$value = $meta[ $meta_key ];
$value = current( $value );
// if ( 'author_meta' === $meta_key || 'user_meta' === $meta_key ) {
// $value = maybe_unserialize( $value );
// $value = $value['display_name'];
//
// if ( 'author_meta' === $meta_key && $value == '' && $context == 'comments') {
// $value = __( 'Guest', 'mainwp-child-reports' );
// }
// // to fix empty author value
// if ( empty($value) ) {
// if (isset($value['agent']) && !empty($value['agent'])) {
// $value = $value['agent'];
// }
// }
//
// if (!is_string($value)) {
// $value = '';
// }
// }
// to compatible with old meta data
if ( 'author_meta' === $meta_key ) {
$value = maybe_unserialize( $value );
if (is_array($value)) {
$value = $value['display_name'];
// to fix empty author value
if ( empty($value) ) {
if (isset($value['agent']) && !empty($value['agent'])) {
$value = $value['agent'];
}
}
}
if (!is_string($value)) {
$value = '';
}
}
// end
}
}

View file

@ -6,7 +6,7 @@
Author: MainWP
Author URI: https://mainwp.com
Text Domain: mainwp-child
Version: 4.0.5
Version: 4.0.5.1
*/
include_once( ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php' ); //Version information from wordpress

View file

@ -5,9 +5,9 @@ Author: mainwp
Author URI: https://mainwp.com
Plugin URI: https://mainwp.com
Requires at least: 3.6
Tested up to: 5.3
Tested up to: 5.3.1
Requires PHP: 5.6
Stable tag: 4.0.5
Stable tag: 4.0.5.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -71,6 +71,9 @@ To see full documentation and FAQs please visit [MainWP Documentation](https://m
== Changelog ==
= 4.0.5.1 - 12-13-19 =
* Fixed: Child Reports data conversion problem
= 4.0.5 - 12-9-19 =
* Added: support for the Pro Reports extension
* Fixed: MainWP Child Reports version 2 compatibility