Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check log entry array keys before using them in Jetpack connector #768

Merged
merged 2 commits into from
Sep 9, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions connectors/class-connector-jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,23 @@ public function register() {
* @param array $entry
*/
public function callback_jetpack_log_entry( array $entry ) {
$method = $entry['code'];
$data = $entry['data'];
if ( isset( $entry['code'] ) ) {
$method = $entry['code'];
} else {
return;
}

if ( isset( $entry['data'] ) ) {
$data = $entry['data'];
} else {
$data = null;
}

$context = null;
$action = null;
$meta = array();

if ( in_array( $method, array( 'activate', 'deactivate' ) ) ) {
if ( in_array( $method, array( 'activate', 'deactivate' ) ) && ! is_null( $data ) ) {
$module_slug = $data;
$module = \Jetpack::get_module( $module_slug );
$module_name = $module['name'];
Expand All @@ -329,7 +340,7 @@ public function callback_jetpack_log_entry( array $entry ) {
$module_name,
( 'activated' === $action ) ? esc_html__( 'activated', 'stream' ) : esc_html__( 'deactivated', 'stream' )
);
} elseif ( in_array( $method, array( 'authorize', 'unlink' ) ) ) {
} elseif ( in_array( $method, array( 'authorize', 'unlink' ) ) && ! is_null( $data ) ) {
$user_id = intval( $data );

if ( empty( $user_id ) ) {
Expand Down Expand Up @@ -358,8 +369,6 @@ public function callback_jetpack_log_entry( array $entry ) {
return;
}

$meta = array();

if ( ! $is_multisite ) {
$message = sprintf(
__( 'Site %s Jetpack', 'stream' ),
Expand Down