Plugin Directory

Changeset 1592531


Ignore:
Timestamp:
02/09/2017 02:07:05 PM (9 years ago)
Author:
loushou
Message:
  • [new] added tool to restore event tart/end times from backed up values that autoscript created
  • [tweak] changed logic of start/end time autofix script, to only run for events that do not have a TZ designation
  • [tweak] using home_url instead of site_url for ticket links
  • [tweak] added code to prevent php warning in some confirmation emails
  • [fix] fixed conflict with cart addons woo plugin
  • [fix] repaired an issue where updates were being checked too many times throughout the day, in some case

loushou

Location:
opentickets-community-edition/trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • opentickets-community-edition/trunk/inc/core/post-type.class.php

    r1567191 r1592531  
    864864        if (empty($html) || empty($post_thumbnail_id)) {
    865865            $post = get_post($post_id);
    866             if (is_object($post) && isset($post->post_type) && $post->post_type == self::$o->core_post_type && !empty($post->post_parent)) {
     866            if (is_object($post) && isset($post->post_type) && $post->post_type == self::$o->core_post_type && !empty($post->post_parent) && $post->post_parent != $post->ID) {
    867867                $html = get_the_post_thumbnail($post->post_parent, $size, $attr);
    868868            }
     
    896896
    897897        // if the supplied object is an event, and it is not a parent event, then...
    898         if ( $map[ $object_id . '' ] == self::$o->core_post_type && $key == '_thumbnail_id' && $parent_id = wp_get_post_parent_id( $object_id ) ) {
     898        if ( $map[ $object_id . '' ] == self::$o->core_post_type && $key == '_thumbnail_id' && ( $parent_id = wp_get_post_parent_id( $object_id ) ) && $parent_id != $object_id ) {
    899899            // prevent weird recursion
    900900            remove_filter( 'get_post_metadata', array( __CLASS__, 'cascade_thumbnail_id' ), 10 );
  • opentickets-community-edition/trunk/inc/event-area/post-type.class.php

    r1536371 r1592531  
    494494        // get the event area object
    495495        $event_area = get_post( $event_area_id );
     496        if ( ! ( $event_area instanceof WP_Post ) )
     497            return $current;
     498
     499        // add the meta
    496500        $event_area->meta = get_post_meta( $event_area->ID );
    497501        foreach ( $event_area->meta as $k => $v )
    498502            $event_area->meta[ $k ] = current( $v );
     503
     504        // add the area type
    499505        $event_area->area_type = $this->event_area_type_from_event_area( $event_area );
    500506
  • opentickets-community-edition/trunk/inc/sys/extensions/updater.php

    r1299061 r1592531  
    216216        if ( ! $is_force && time() < $expires )
    217217            return array();
     218        update_option( 'qsot-extensions-updater-last-expires', time() + ( 12 * HOUR_IN_SECONDS ) );
    218219
    219220        // otherwise, run our update fetch request
  • opentickets-community-edition/trunk/inc/sys/pages/system-status.page.php

    r1536371 r1592531  
    129129            )
    130130        );
     131        $this->register_tool(
     132            'resTsFix',
     133            array(
     134                'name' => __( 'Attempt Repair of start and end times (very rare)', 'opentickets-community-edition' ),
     135                'description' => __( 'If you have an issue where all your event times changed after updating, you might need to run this tool. Contact support though.', 'opentickets-community-edition' ),
     136                'function' => array( &$this, 'tool_resTsFix' ),
     137                'messages' => array(
     138                    'updated-restses' => $this->_updatedw( __( 'Restored all the start and end times for all events, to their original values.', 'opentickets-community-edition' ) ),
     139                ),
     140            )
     141        );
    131142    }
    132143
     
    947958    }
    948959
     960    // cycle through all events, and update the timezone of the start and end times to match the site timezone, using the original ts values instead
     961    public function tool_resTsFix( $result, $args ) {
     962        // check that the repair can run
     963        if ( ! $this->_verify_action_nonce( 'resTsFix' ) )
     964            return $result;
     965
     966        // update all the event times to use the same tz as the site (non-dst)
     967        QSOT_Utils::restore_event_times();
     968
     969        // update and return the results data
     970        $result[1]['performed'] = 'updated-restses';
     971        $result[0] = true;
     972        return $result;
     973    }
     974
    949975
    950976    // empty all files from a directory (skips subdirs)
  • opentickets-community-edition/trunk/inc/sys/utils.php

    r1574067 r1592531  
    435435        );
    436436
     437        $force = isset( $_COOKIE, $_COOKIE['qs-force'] ) && '1' == $_COOKIE['qs-force'];
     438
    437439        // grab the next 1000
    438440        while ( $event_ids = get_posts( $args ) ) {
     
    446448                $event_id = array_shift( $event_ids );
    447449
    448                 // get the start and end time of this event from db
    449                 $start = get_post_meta( $event_id, '_start', true );
    450                 $end = get_post_meta( $event_id, '_end', true );
    451                 $orig_values = array( 'start' => $start, 'end' => $end );
     450                // see if this thing has gone through a tsfix before
     451                $tsfix = get_post_meta( $event_id, '_tsFix_update', true );
     452
     453                // if not, setup a tsfix update key now
     454                if ( ! $tsfix ) {
     455                    // get the start and end time of this event from db
     456                    $start = get_post_meta( $event_id, '_start', true );
     457                    $end = get_post_meta( $event_id, '_end', true );
     458                    $orig_values = array( 'start' => $start, 'end' => $end );
     459
     460                    // if the old values have a timezone designation, just skip this item, unless being forced
     461                    if ( ! $force && '+' == substr( $orig_values['start'], '-6', 1 ) )
     462                        continue;
     463
     464                    add_post_meta( $event_id, '_tsFix_update', $orig_values );
     465                }
    452466
    453467                // normalize the timestamp to UTC
     
    458472                update_post_meta( $event_id, '_start', $start );
    459473                update_post_meta( $event_id, '_end', $end );
    460                 // save original bad values for posterity
    461                 add_post_meta( $event_id, '_tsFix_update', $orig_values );
    462474            }
    463475        }
     
    465477        // add a record of the last time this ran
    466478        update_option( '_last_run_otce_normalize_event_times', time() . '|' . self::$normalize_version );
     479    }
     480
     481    // restore ticket times from a tsfix value
     482    public static function restore_event_times() {
     483        // get current site timeoffset
     484        $offset = self::non_dst_tz_offset();
     485
     486        $perpage = 1000;
     487        $pg_offset = 1;
     488        // get a list of all the event ids to update. throttle at 1000 per cycle
     489        $args = array(
     490            'post_type' => 'qsot-event',
     491            'post_status' => array( 'any', 'trash' ),
     492            'post_parent__not_in' => array( 0 ),
     493            'fields' => 'ids',
     494            'posts_per_page' => $perpage,
     495            'paged' => $pg_offset,
     496        );
     497
     498        $force = isset( $_COOKIE, $_COOKIE['qs-force'] ) && '1' == $_COOKIE['qs-force'];
     499
     500        // grab the next 1000
     501        while ( $event_ids = get_posts( $args ) ) {
     502            // inc page for next iteration
     503            $pg_offset++;
     504            $args['paged'] = $pg_offset;
     505
     506            // cycle through all results
     507            while ( is_array( $event_ids ) && count( $event_ids ) ) {
     508                // get the next event_id to update
     509                $event_id = array_shift( $event_ids );
     510
     511                // see if this thing has gone through a tsfix before
     512                $tsfix = get_post_meta( $event_id, '_tsFix_update', true );
     513
     514                // if it hasnt, bail
     515                if ( ! is_array( $tsfix ) || ! isset( $tsfix['start'], $tsfix['end'] ) )
     516                    continue;
     517
     518                // save the current, potentially munged values, incase we have to restore a restore
     519                add_post_meta( $event_id, '_resTsFix_update', array( 'start' => get_post_meta( $event_id, '_start', true ), 'end' => get_post_meta( $event_id, '_end', true ) ) );
     520
     521                $start = $end = '';
     522                // if the original dates have a timezone... then they are effect up and need to be adjusted to assume the timezone is wrong
     523                if ( '+' == substr( $tsfix['start'], '-6', 1 ) ) {
     524                    $start = explode( '+', $tsfix['start'] );
     525                    $start = current( $start );
     526                    $end = explode( '+', $tsfix['end'] );
     527                    $end = current( $end );
     528                // otherwise, assume the dates were for the site timezone, and update the ts
     529                } else {
     530                    $start = str_replace( 'T', ' ', $tsfix['start'] );
     531                    $end = str_replace( 'T', ' ', $tsfix['end'] );
     532                }
     533
     534                // save both times in the new format
     535                update_post_meta( $event_id, '_start', $start . $offset );
     536                update_post_meta( $event_id, '_end', $end . $offset );
     537            }
     538        }
     539
     540        // add a record of the last time this ran
     541        update_option( '_last_run_otce_restore_event_times', time() . '|' . self::$normalize_version );
    467542    }
    468543}
  • opentickets-community-edition/trunk/inc/ticket/ticket.class.php

    r1511879 r1592531  
    200200        // if we ARE using a permalink struct, then return a pretty permalink
    201201        if ( ! empty( $wp_rewrite->permalink_structure ) ) {
    202             $final = site_url( '/ticket/' . $code . '/' );
     202            $final = home_url( '/ticket/' . $code . '/' );
    203203        // otherwise, return an ugly permalink
    204204        } else {
     
    206206                'qsot-ticket' => 1,
    207207                'qsot-ticket-id' => $code,
    208             ), site_url() );
     208            ), home_url() );
    209209        }
    210210
     
    224224        // if we ARE using a permalink struct, then return a pretty permalink
    225225        if ( ! empty( $wp_rewrite->permalink_structure ) ) {
    226             $final = site_url( '/order-tickets/' . $order->order_key . '/' );
     226            $final = home_url( '/order-tickets/' . $order->order_key . '/' );
    227227        // otherwise, return an ugly permalink
    228228        } else {
     
    230230                'qsot-order-tickets' => 1,
    231231                'qsot-order-ticket-id' => $order->order_key,
    232             ), site_url() );
     232            ), home_url() );
    233233        }
    234234
  • opentickets-community-edition/trunk/launcher.php

    r1574067 r1592531  
    44 * Plugin URI:  http://opentickets.com/
    55 * Description: Event Management and Online Ticket Sales Platform
    6  * Version:     2.6.4
     6 * Version:     2.6.5
    77 * Author:      Quadshot Software LLC
    88 * Author URI:  http://quadshot.com/
     
    5454            'fctm' => 'fc',
    5555            'always_reserve' => 0,
    56             'version' => '2.6.4',
     56            'version' => '2.6.5',
    5757            'min_wc_version' => '2.6.1',
    5858            'core_post_type' => 'qsot-event',
  • opentickets-community-edition/trunk/opentickets.php

    r1554772 r1592531  
    753753    // on admin load, check if we need to update all the event timestamps now. if so, do it
    754754    public static function maybe_update_event_timestamps() {
     755        return;
     756        /* NO LONGER DO THIS ON UPDATE. CAN MUNGE DATA
    755757        // find out the last time the timestamp updater ran
    756758        $last_run = explode( '|', get_option( '_last_run_otce_normalize_event_times', '' ) );
     
    766768        if ( $run_now )
    767769            QSOT_Utils::normalize_event_times();
     770        */
    768771    }
    769772
  • opentickets-community-edition/trunk/readme.txt

    r1574067 r1592531  
    172172== Changelog ==
    173173
    174 = 2.6.4- Jan/13/2017 =
     174= 2.6.5 - Feb/06/2017 =
     175* [new] added tool to restore event tart/end times from backed up values that autoscript created
     176* [tweak] changed logic of start/end time autofix script, to only run for events that do not have a TZ designation
     177* [tweak] using home_url instead of site_url for ticket links
     178* [tweak] added code to prevent php warning in some confirmation emails
     179* [fix] fixed conflict with cart addons woo plugin
     180* [fix] repaired an issue where updates were being checked too many times throughout the day, in some case
     181
     182= 2.6.4 - Jan/13/2017 =
    175183* [tweak] made a javascript change that works around the new WC change that prevents the 'change seat' button from working in the admin
    176184* [tweak] another adjustment that solves an edge case daylights savings time issue
Note: See TracChangeset for help on using the changeset viewer.