-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBugzillaJob.class.php
More file actions
74 lines (53 loc) · 1.87 KB
/
BugzillaJob.class.php
File metadata and controls
74 lines (53 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
abstract class BugzillaJob extends Job {
// Run the job
public function run() {
$this->query = unserialize($this->params['query_obj']);
$article = new Article( $this->title );
if( $article ) {
// Pull from Bugzilla
$this->query->_fetch_by_options();
// Mess with the database
$this->_database_work();
}
return TRUE;
}
}
class BugzillaInsertJob extends BugzillaJob {
// Set up the background job
public function __construct( $title, $params ) {
parent::__construct('queryBugzillaInsert', $title, $params );
}
public function _database_work() {
// Get the master because we are writing
$dbw = wfGetDB( DB_MASTER );
// Add it to the cache
$res = $dbw->insert(
'bugzilla_cache',
array('id' => $this->query->id(),
'fetched_at' => wfTimestamp(TS_DB),
'data' => serialize($this->query->data)),
__METHOD__
);
}
}
class BugzillaUpdateJob extends BugzillaJob {
// Set up the background job
public function __construct( $title, $params ) {
parent::__construct('queryBugzillaUpdate', $title, $params );
}
public function _database_work() {
// Get the master because we are writing
$dbw = wfGetDB( DB_MASTER );
// Update cache entry
$res = $dbw->update(
'bugzilla_cache',
array('id' => $this->query->id(),
'fetched_at' => wfTimestamp(TS_DB),
'data' => serialize($this->query->data)),
array('id' => $this->query->id()),
__METHOD__
);
}
}
?>