Skip to content

Commit

Permalink
Merge pull request #557 from x-team/issue-556
Browse files Browse the repository at this point in the history
Remove use of extract() throughout Stream
  • Loading branch information
frankiejarrett committed May 30, 2014
2 parents df3edba + 03c1434 commit 1843500
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
16 changes: 10 additions & 6 deletions connectors/installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static function callback_upgrader_process_complete( $upgrader, $extra ) {
'Plugin/theme installation. 1: Type (plugin/theme), 2: Plugin/theme name, 3: Plugin/theme version',
'stream'
);
$logs[] = compact( 'slug', 'name', 'version', 'message', 'action', 'message' );
$logs[] = compact( 'slug', 'name', 'version', 'message', 'action' );
} elseif ( 'update' === $action ) {
$action = 'updated';
$message = _x(
Expand All @@ -158,7 +158,7 @@ public static function callback_upgrader_process_complete( $upgrader, $extra ) {
$version = $plugin_data['Version'];
$old_version = $plugins[ $slug ]['Version'];

$logs[] = compact( 'slug', 'name', 'old_version', 'version', 'message', 'action', 'message' );
$logs[] = compact( 'slug', 'name', 'old_version', 'version', 'message', 'action' );
}
} else { // theme
if ( isset( $extra['bulk'] ) && true == $extra['bulk'] ) {
Expand All @@ -174,7 +174,7 @@ public static function callback_upgrader_process_complete( $upgrader, $extra ) {
$old_version = $theme['Version'];
$version = $theme_data['Version'];

$logs[] = compact( 'slug', 'name', 'old_version', 'version', 'message', 'action', 'message' );
$logs[] = compact( 'slug', 'name', 'old_version', 'version', 'message', 'action' );
}
}
} else {
Expand All @@ -184,11 +184,15 @@ public static function callback_upgrader_process_complete( $upgrader, $extra ) {
$context = $type . 's';

foreach ( $logs as $log ) {
extract( $log );
unset( $log['action'] );
$name = isset( $log['name'] ) ? $log['name'] : null;
$version = isset( $log['version'] ) ? $log['version'] : null;
$slug = isset( $log['slug'] ) ? $log['slug'] : null;
$old_version = isset( $log['old_version'] ) ? $log['old_version'] : null;
$message = isset( $log['message'] ) ? $log['message'] : null;
$action = isset( $log['action'] ) ? $log['action'] : null;
self::log(
$message,
compact( 'type', 'name', 'version', 'slug', 'success', 'error', 'from' , 'old_version' ),
compact( 'type', 'name', 'version', 'slug', 'success', 'error', 'old_version' ),
null,
array( $context => $action )
);
Expand Down
6 changes: 4 additions & 2 deletions includes/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public static function stream_activity_contents( $paged = 1 ) {

$total_items = count( $all_records );
$args = array(
'total_pages' => absint( ceil( $total_items / $records_per_page ) ), // Cast as an integer, not a float
'current' => $paged,
'total_pages' => absint( ceil( $total_items / $records_per_page ) ), // Cast as an integer, not a float
);

self::pagination( $args );
Expand All @@ -91,7 +91,9 @@ public static function pagination( $args = array() ) {
'total_pages' => 1,
)
);
extract( $args );

$current = $args['current'];
$total_pages = $args['total_pages'];

$records_link = add_query_arg(
array( 'page' => WP_Stream_Admin::RECORDS_PAGE_SLUG ),
Expand Down
4 changes: 3 additions & 1 deletion includes/live-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ public static function heartbeat_received( $response, $data ) {
self::$list_table = new WP_Stream_List_Table( array( 'screen' => 'toplevel_page_' . WP_Stream_Admin::RECORDS_PAGE_SLUG ) );
self::$list_table->prepare_items();

extract( self::$list_table->_pagination_args, EXTR_SKIP );
$total_items = isset( self::$list_table->_pagination_args['total_items'] ) ? self::$list_table->_pagination_args['total_items'] : null;
$total_pages = isset( self::$list_table->_pagination_args['total_pages'] ) ? self::$list_table->_pagination_args['total_pages'] : null;
$per_page = isset( self::$list_table->_pagination_args['per_page'] ) ? self::$list_table->_pagination_args['per_page'] : null;

if ( isset( $data['wp-stream-heartbeat'] ) && isset( $total_items ) ) {
$response['total_items'] = $total_items;
Expand Down

0 comments on commit 1843500

Please sign in to comment.