1 | <?php |
||
12 | class StaticPagesQueue extends DataObject { |
||
|
|||
13 | |||
14 | /** |
||
15 | * |
||
16 | * @var array |
||
17 | */ |
||
18 | public static $create_table_options = array( |
||
19 | 'MySQLDatabase' => 'ENGINE=InnoDB' |
||
20 | ); |
||
21 | |||
22 | /** |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | public static $db = array( |
||
27 | 'Priority' => 'Int', |
||
28 | 'URLSegment' => 'Varchar(255)', |
||
29 | 'Freshness' => "Enum('stale, regenerating, error', 'stale')" |
||
30 | ); |
||
31 | |||
32 | /** |
||
33 | * |
||
34 | * @var array |
||
35 | */ |
||
36 | public static $defaults = array( |
||
37 | "Priority" => 3 |
||
38 | ); |
||
39 | |||
40 | /** |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | public static $default_sort = "\"Priority\""; |
||
45 | |||
46 | /** |
||
47 | * Sets database indexes |
||
48 | * |
||
49 | * @var array |
||
50 | */ |
||
51 | public static $indexes = array( |
||
52 | 'freshness_priority_created' => '(Freshness, Priority, Created)', |
||
53 | ); |
||
54 | |||
55 | /** |
||
56 | * |
||
57 | * @var boolean |
||
58 | */ |
||
59 | private static $disable_mysql_locks = false; |
||
60 | |||
61 | /** |
||
62 | * |
||
63 | * @var boolean |
||
64 | */ |
||
65 | private static $realtime = false; |
||
66 | |||
67 | /** |
||
68 | * |
||
69 | * @var int |
||
70 | */ |
||
71 | protected static $minutes_until_force_regeneration = 1; |
||
72 | |||
73 | /** |
||
74 | * |
||
75 | * @var array |
||
76 | */ |
||
77 | protected static $insert_statements = array(); |
||
78 | |||
79 | /** |
||
80 | * |
||
81 | * @var array |
||
82 | */ |
||
83 | protected static $urls = array(); |
||
84 | |||
85 | /** |
||
86 | * |
||
87 | * @return bool |
||
88 | */ |
||
89 | public static function is_realtime() { |
||
92 | |||
93 | /** |
||
94 | * |
||
95 | * @param type $priority |
||
96 | * @param type $URLSegment |
||
97 | * @return type |
||
98 | */ |
||
99 | public static function add_to_queue($priority, $URLSegment) { |
||
104 | |||
105 | /** |
||
106 | * This will push all the currently cached insert statements to be pushed |
||
107 | * into the database |
||
108 | * |
||
109 | * @return void |
||
110 | */ |
||
111 | public static function push_urls_to_db() { |
||
123 | |||
124 | /** |
||
125 | * Remove an object by the url |
||
126 | * |
||
127 | * @param string $URLSegment |
||
128 | * @return bool - if there was an queue item removed |
||
129 | * |
||
130 | */ |
||
131 | public static function delete_by_link($URLSegment) { |
||
139 | |||
140 | /** |
||
141 | * Update the queue with the information that this url renders an error somehow |
||
142 | * |
||
143 | * @param string $url |
||
144 | */ |
||
145 | public static function has_error( $url ) { |
||
152 | |||
153 | /** |
||
154 | * Returns a single queue object according to a particular priority and freshness measure. |
||
155 | * This method removes any duplicates and makes the object as "regenerating", so other calls to this method |
||
156 | * don't grab the same object. |
||
157 | * If we are using MySQLDatabase with InnoDB, we do row-level locking when updating the dataobject to allow for |
||
158 | * distributed cache rebuilds |
||
159 | * @static |
||
160 | * @param $freshness |
||
161 | * @param $sortOrder |
||
162 | */ |
||
163 | protected static function get_queue_object($freshness, $interval = null, $sortOrder = array('Priority'=>'DESC', 'ID'=>'ASC')) { |
||
203 | |||
204 | /** |
||
205 | * Finds the next most prioritized url that needs recaching |
||
206 | * |
||
207 | * @return string |
||
208 | */ |
||
209 | public static function get_next_url() { |
||
225 | |||
226 | /** |
||
227 | * Removes the .html fresh copy of the cache. |
||
228 | * Keeps the *.stale.html copy in place, |
||
229 | * in order to notify the user of the stale content. |
||
230 | * |
||
231 | * @param array $URLSegments |
||
232 | */ |
||
233 | protected static function remove_old_cache( array $URLSegments ) { |
||
247 | |||
248 | /** |
||
249 | * Mark this current StaticPagesQueue as a work in progress |
||
250 | * |
||
251 | * @param StaticPagesQueue $object |
||
252 | */ |
||
253 | protected static function mark_as_regenerating(StaticPagesQueue $object) { |
||
258 | |||
259 | /** |
||
260 | * Removes all duplicates that has the same URLSegment as $ID |
||
261 | * |
||
262 | * @param int $ID - ID of the object whose duplicates we want to remove |
||
263 | * @return void |
||
264 | */ |
||
265 | static function remove_duplicates( $ID ) { |
||
272 | |||
273 | /** |
||
274 | * |
||
275 | * @param string $url |
||
276 | * @param bool $onlyStale - Get only stale entries |
||
277 | * @return DataObject || false - The first item matching the query |
||
278 | */ |
||
279 | protected static function get_by_link($url) { |
||
287 | } |
||
288 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.