Plugin Directory

Changeset 2166556 for wp-slimstat


Ignore:
Timestamp:
10/01/2019 08:18:21 PM (6 years ago)
Author:
coolmann
Message:

Fixed a bug in the algorithm tagging new visitors via their fingerprint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-slimstat/trunk/wp-slimstat.php

    r2166555 r2166556  
    181181                // Is this a new visitor, based on his fingerprint?
    182182                if ( !empty( self::$stat[ 'fingerprint' ] ) && self::_is_new_visitor( self::$stat[ 'fingerprint' ] ) ) {
    183                     self::$stat[ 'notes' ][] = 'new:yes';
     183                    self::$stat[ 'notes' ] = array( 'new:yes' );
    184184                }
    185185
     
    273273            // Is this a new visitor, based on his fingerprint?
    274274            if ( !empty( self::$stat[ 'fingerprint' ] ) && self::_is_new_visitor( self::$stat[ 'fingerprint' ] ) ) {
    275                 self::$stat[ 'notes' ][] = 'new:yes';
     275                self::$stat[ 'notes' ] = array( 'new:yes' );
    276276            }
    277277
     
    296296    public static function slimtrack() {
    297297        self::$stat[ 'dt' ] = self::date_i18n( 'U' );
    298         self::$stat[ 'notes' ] = array();
     298
     299        if ( empty( self::$stat[ 'notes' ] ) ) {
     300            self::$stat[ 'notes' ] = array();
     301        }
    299302
    300303        // Allow third-party tools to initialize the stat array
     
    14371440
    14381441        // The 'notes' column stores multiple comma-separated values: we need to append the new value to the existing ones
     1442        // Also, values are organized in an array, which we need to implode as a string
    14391443        $notes = '';
    14401444        if ( !empty( $_data[ 'notes' ] ) && is_array( $_data[ 'notes' ] ) ) {
    1441             $imploded_notes = '[' . esc_sql( implode( '][', $_data[ 'notes' ] ) ) . ']';
    1442             $notes = ( count( $_data ) > 1 ? ',' : '' ) . "notes=CONCAT( IFNULL( notes, '' ), '" . $imploded_notes . "' )";
     1445            $notes = ( count( $_data ) > 1 ? ',' : '' ) . "notes=CONCAT( IFNULL( notes, '' ), '[" . esc_sql( implode( '][', $_data[ 'notes' ] ) ) . "]' )";
    14431446            unset( $_data[ 'notes' ] );
    14441447        }
Note: See TracChangeset for help on using the changeset viewer.