Skip to content

Instantly share code, notes, and snippets.

@fjarrett
Created December 20, 2013 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fjarrett/8058052 to your computer and use it in GitHub Desktop.
Save fjarrett/8058052 to your computer and use it in GitHub Desktop.
Attempt to resolve IP value database error
<?php
/**
* Log handler
* @param string $message sprintf-ready error message string
* @param array $args sprintf (and extra) arguments to use
* @param int $object_id Target object id
* @param string $action Action performed (stream_action)
* @param int $user_id User responsible for the action
* @param array $contexts Contexts of the action
* @return void
*/
public function log( $connector, $message, $args, $object_id, $contexts, $user_id = null ) {
if ( is_null( $user_id ) ) {
$user_id = get_current_user_id();
}
$ip = filter_input( INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP );
$ip = ( $ip ) ? $ip : null;
$recordarr = array(
'object_id' => $object_id,
'author' => $user_id,
'created' => current_time( 'mysql', 1 ),
'summary' => vsprintf( $message, $args ),
'parent' => self::$instance->prev_record,
'connector' => $connector,
'contexts' => $contexts,
'meta' => $args,
'ip' => $ip,
);
$record_id = WP_Stream_DB::get_instance()->insert( $recordarr );
return $record_id;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment