protected function do_creations() { $exclusions = $this->current_queue->instances_to_exclude(); $instances_to_create = array_values($this->current_queue->instances_to_create()); try { $sequence = new Tribe__Events__Pro__Recurrence__Sequence($instances_to_create, $this->current_event_id); } catch (Exception $e) { $exception = new Tribe__Exception($e); $exception->handle(); return; } foreach ($sequence->get_sorted_sequence() as $key => $date_duration) { // Don't process more than the current batch size allows if ($this->batch_complete()) { break; } // Some instances may deliberately have been removed - let's remove // them from the list of events to create and move on if (in_array($date_duration, $exclusions)) { unset($instances_to_create[$date_duration['original_index']]); $this->processed++; continue; } if (!$this->current_queue->have_ownership_of_job()) { return; } $sequence_number = isset($date_duration['sequence']) ? $date_duration['sequence'] : 1; $instance = new Tribe__Events__Pro__Recurrence__Instance($this->current_event_id, $date_duration, 0, $sequence_number); if (!$instance->already_exists()) { $instance->save(); } unset($instances_to_create[$date_duration['original_index']]); $this->processed++; } $this->current_queue->instances_to_create($instances_to_create); }
/** * Gets the name of the class the method is called in; typically will be a child class * * This uses some hackery if the server is on PHP 5.2, and it can fail in rare * circumstances causing a null value to be returned. * * @return string|null Class name */ protected static final function get_called_class() { $class_name = null; if (function_exists('get_called_class')) { // For PHP 5.3+ we can use the late static binding class name. $class_name = get_called_class(); } else { // For PHP 5.2 and under we hack around the lack of late static bindings. try { $backtraces = debug_backtrace(); // Grab each class from the backtrace. foreach ($backtraces as $i) { $class = null; if (array_key_exists('class', $i)) { // Direct call to a class. $class = $i['class']; } elseif (array_key_exists('function', $i) && strpos($i['function'], 'call_user_func') === 0 && array_key_exists('args', $i) && is_array($i['args']) && is_array($i['args'][0]) && isset($i['args'][0][0])) { // Found a call from call_user_func... and $i['args'][0][0] is present // indicating a static call to a method. $class = $i['args'][0][0]; } else { // Slight performance boost from skipping ahead. continue; } // Check to see if the parent is the current class. // The first backtrace with a matching parent is our class. if (get_parent_class($class) === __CLASS__) { $class_name = $class; break; } } } catch (Exception $e) { // Host has disabled or misconfigured debug_backtrace(). $exception = new Tribe__Exception($e); $exception->handle(); } } // Class name was not set by debug_backtrace() hackery. if (null === $class_name) { tribe_notice('tribe_debug_backtrace_disabled', array(__CLASS__, 'notice_debug_backtrace')); } return $class_name; }