PATH:
home
/
centosnipponia
/
public_html
/
ticketing.nipponia.com
/
include
/
upgrader
/
streams
/
core
<?php class EventEnumRemoval extends MigrationTask { var $description = "Remove the Enum 'state' field from ThreadEvents"; var $queue; var $skipList; var $errorList = array(); var $limit = 20000; function sleep() { return array('queue'=>$this->queue, 'skipList'=>$this->skipList); } function wakeup($stuff) { $this->queue = $stuff['queue']; $this->skipList = $stuff['skipList']; while (!$this->isFinished()) $this->do_batch(30, $this->limit); } function run($max_time) { $this->do_batch($max_time * 0.9, $this->limit); } function isFinished() { return $this->getQueueLength() == 0; } function do_batch($time=30, $max=0) { if(!$this->queueEvents($max) || !$this->getQueueLength()) return 0; $this->setStatus("{$this->getQueueLength()} events remaining"); $count = 0; $start = Misc::micro_time(); while ($this->getQueueLength() && (Misc::micro_time()-$start) < $time) { if($this->next() && $max && ++$count>=$max) { break; } } return $this->queueEvents($max); } function queueEvents($limit=0){ global $cfg, $ost; # Since the queue is persistent - we want to make sure we get to empty # before we find more events. if(($qc=$this->getQueueLength())) return $qc; $sql = "SELECT COUNT(t.id) FROM ".THREAD_EVENT_TABLE. " t INNER JOIN ".EVENT_TABLE. " e ON (e.name=t.state) WHERE t.event_id IS NULL"; //XXX: Do a hard fail or error querying the database? if(!($res=db_query($sql))) return $this->error('Unable to query DB for Thread Event migration!'); $count = db_result($res); // Force the log message to the database $ost->logDebug("Thread Event Migration", 'Found '.$count .' events to migrate', true); if($count == 0) return 0; //Nothing else to do!! $start = db_result(db_query("SELECT id FROM ".THREAD_EVENT_TABLE. " WHERE event_id IS NULL ORDER BY id ASC LIMIT 1")); $this->queue = array(); $info=array( 'count' => $count, 'start' => $start, 'end' => $start + $limit ); $this->enqueue($info); return $this->getQueueLength(); } function skip($eventId, $error) { $this->skipList[] = $eventId; return $this->error($error." (ID #$eventId)"); } function error($what) { global $ost; $this->errors++; $this->errorList[] = $what; // Log the error but don't send the alert email $ost->logError('Upgrader: Thread Event Migrater', $what, false); # Assist in returning FALSE for inline returns with this method return false; } function getErrors() { return $this->errorList; } function getSkipList() { return $this->skipList; } function enqueue($info) { $this->queue[] = $info; } function getQueueLength() { return count($this->queue ?: []); } function next() { # Fetch next item -- use the last item so the array indices don't # need to be recalculated for every shift() operation. $info = array_pop($this->queue); $sql = "UPDATE ".THREAD_EVENT_TABLE. " t INNER JOIN ".EVENT_TABLE. " e ON (e.name=t.state) SET t.event_id = e.id WHERE t.event_id IS NULL AND t.id <= ". $info['end']; db_query($sql); return true; } } return 'EventEnumRemoval'; ?>
[+]
..
[-] 16fcef4a-d51f303a.patch.sql
[edit]
[-] e2b4e5cb-f0d2e14d.cleanup.sql
[edit]
[-] 61c9d5d7-6de40a4d.patch.sql
[edit]
[-] 15af7cd3-98ae1ed2.patch.sql
[edit]
[-] ed60ba20-934954de.patch.sql
[edit]
[-] 32de1766-852ca89e.patch.sql
[edit]
[-] 5cd0a25a-2d590ffa.task.php
[edit]
[-] e2b4e5cb-f0d2e14d.task.php
[edit]
[-] 740428f9-8aeda901.patch.sql
[edit]
[-] 9ef33a06-8f99b8bf.patch.sql
[edit]
[-] 8f99b8bf-03ff59bf.patch.sql
[edit]
[-] 852ca89e-740428f9.patch.sql
[edit]
[-] 9f3b454c-c0fd16f4.patch.sql
[edit]
[-] 36f6b328-5cd0a25a.task.php
[edit]
[-] e7038ce9-ddbe2e76.patch.sql
[edit]
[-] c0fd16f4-d959a00e.patch.sql
[edit]
[-] 00ff231f-9f3b454c.patch.sql
[edit]
[-] 98ae1ed2-e342f869.task.php
[edit]
[-] 15b30765-dd0022fb.task.php
[edit]
[-] d51f303a-dad45ca2.patch.sql
[edit]
[-] d51f303a-dad45ca2.task.php
[edit]
[-] 6de40a4d-1b0fce99.patch.sql
[edit]
[-] c37e1656-e2b4e5cb.task.php
[edit]
[-] 15719536-dd0022fb.patch.sql
[edit]
[-] 2e20a0eb-98ae1ed2.patch.sql
[edit]
[-] 5cd0a25a-2d590ffa.cleanup.sql
[edit]
[-] 435c62c3-2e7531a2.cleanup.sql
[edit]
[-] 70921d5c-26fd79dc.patch.sql
[edit]
[-] 98ae1ed2-e342f869.patch.sql
[edit]
[-] 1da1bcba-15b30765.patch.sql
[edit]
[-] 03ff59bf-b26f29a6.patch.sql
[edit]
[-] add62892-c37e1656.patch.sql
[edit]
[-] b26f29a6-1ee831c8.task.php
[edit]
[-] 9143a511-0d6099a6.cleanup.sql
[edit]
[-] 15b30765-dd0022fb.cleanup.sql
[edit]
[-] e2b4e5cb-f0d2e14d.patch.sql
[edit]
[-] 1b0fce99-ed60ba20.patch.sql
[edit]
[-] 934954de-f1ccd3bb.task.php
[edit]
[-] c00511c7-7be60a84.patch.sql
[edit]
[-] 26fd79dc-00c949a6.patch.sql
[edit]
[-] 1ee831c8-36f6b328.cleanup.sql
[edit]
[-] e7038ce9-ddbe2e76.task.php
[edit]
[-] dad45ca2-61c9d5d7.cleanup.sql
[edit]
[-] 61c9d5d7-6de40a4d.task.php
[edit]
[-] c2d2fabf-aa4664af.patch.sql
[edit]
[-] 0d6099a6-98ad7d55.cleanup.sql
[edit]
[-] 9143a511-0d6099a6.patch.sql
[edit]
[-] 934b8db8-ad9d0a5f.patch.sql
[edit]
[-] 98ad7d55-934b8db8.patch.sql
[edit]
[-] 87d4a323-4bd47d94.patch.sql
[edit]
[-] dd0022fb-f4da0c9b.patch.sql
[edit]
[-] cce1ba43-e7dfe821.patch.sql
[edit]
[-] 36f6b328-5cd0a25a.patch.sql
[edit]
[-] dad45ca2-61c9d5d7.task.php
[edit]
[-] 8aeda901-16fcef4a.task.php
[edit]
[-] 8f99b8bf-03ff59bf.cleanup.sql
[edit]
[-] bbb021fb-49478749.patch.sql
[edit]
[-] ad9d0a5f-0ca85857.patch.sql
[edit]
[-] f0d2e14d-83a22ba2.patch.sql
[edit]
[-] 03ff59bf-b26f29a6.cleanup.sql
[edit]
[-] f8856d56-abe9c0cb.patch.sql
[edit]
[-] 0d6099a6-98ad7d55.patch.sql
[edit]
[-] e342f869-c00511c7.patch.sql
[edit]
[-] 00c949a6-8b923d61.patch.sql
[edit]
[-] 00c949a6-8b923d61.task.php
[edit]
[-] dad45ca2-61c9d5d7.patch.sql
[edit]
[-] f0d2e14d-83a22ba2.task.php
[edit]
[-] e6978154-cc6d1b03.patch.sql
[edit]
[-] 86707325-526c601b.patch.sql
[edit]
[-] c00511c7-7be60a84.cleanup.sql
[edit]
[-] b26f29a6-1ee831c8.cleanup.sql
[edit]
[-] 4bd47d94-e7038ce9.cleanup.sql
[edit]
[-] 934954de-f1ccd3bb.patch.sql
[edit]
[-] 1ee831c8-36f6b328.task.php
[edit]
[-] d0e37dca-1da1bcba.patch.sql
[edit]
[-] ddbe2e76-add62892.patch.sql
[edit]
[-] f1ccd3bb-f5692e24.patch.sql
[edit]
[-] 36f6b328-5cd0a25a.cleanup.sql
[edit]
[-] b19dc97d-435c62c3.patch.sql
[edit]
[-] abe9c0cb-bbb021fb.patch.sql
[edit]
[-] 87d4a323-4bd47d94.task.php
[edit]
[-] f1ccd3bb-f5692e24.task.php
[edit]
[-] 1ee831c8-36f6b328.patch.sql
[edit]
[-] cc6d1b03-914098f4.patch.sql
[edit]
[-] f5692e24-4323a6a8.task.php
[edit]
[-] b26f29a6-1ee831c8.patch.sql
[edit]
[-] aee589ab-98ae1ed2.patch.sql
[edit]
[-] 60fcbee1-f8856d56.patch.sql
[edit]
[-] 8b923d61-9b5550da.patch.sql
[edit]
[-] 86707325-526c601b.cleanup.sql
[edit]
[-] 914098f4-87d4a323.patch.sql
[edit]
[-] 435c62c3-2e7531a2.patch.sql
[edit]
[-] 2d590ffa-9143a511.patch.sql
[edit]
[-] 8f99b8bf-03ff59bf.task.php
[edit]
[-] 49478749-c2d2fabf.patch.sql
[edit]
[-] aa4664af-b19dc97d.patch.sql
[edit]
[-] f5692e24-4323a6a8.patch.sql
[edit]
[-] f1ccd3bb-f5692e24.cleanup.sql
[edit]
[-] 0ca85857-86707325.patch.sql
[edit]
[-] 4bd47d94-e7038ce9.patch.sql
[edit]
[-] 26fd79dc-00c949a6.cleanup.sql
[edit]
[-] 526c601b-cce1ba43.patch.sql
[edit]
[-] 522e5b78-02decaa2.patch.sql
[edit]
[-] 15b30765-dd0022fb.patch.sql
[edit]
[-] d959a00e-32de1766.patch.sql
[edit]
[-] 9b5550da-e6978154.patch.sql
[edit]
[-] 4bd47d94-e7038ce9.task.php
[edit]
[-] 934b8db8-ad9d0a5f.task.php
[edit]
[-] f0d2e14d-83a22ba2.cleanup.sql
[edit]
[-] c37e1656-e2b4e5cb.patch.sql
[edit]
[-] 435c62c3-2e7531a2.task.php
[edit]
[-] 5cd0a25a-2d590ffa.patch.sql
[edit]
[-] 8aeda901-16fcef4a.patch.sql
[edit]
[-] 98ae1ed2-e342f869.cleanup.sql
[edit]
[-] 26fd79dc-00c949a6.task.php
[edit]
[-] 0d6099a6-98ad7d55.task.php
[edit]
[-] 2e7531a2-d0e37dca.patch.sql
[edit]
[-] 4323a6a8-9ef33a06.patch.sql
[edit]
[-] e7dfe821-70921d5c.patch.sql
[edit]
[-] f4da0c9b-00ff231f.patch.sql
[edit]
[-] 02decaa2-60fcbee1.patch.sql
[edit]
[-] 7be60a84-522e5b78.patch.sql
[edit]
[-] c00511c7-7be60a84.task.php
[edit]
[-] 9143a511-0d6099a6.task.php
[edit]
[-] 83a22ba2-5fb92bef.patch.sql
[edit]
[-] a67ba35e-98ae1ed2.patch.sql
[edit]