Merge lp:~edb/quam-plures/cronjob_stuff into lp:quam-plures
- cronjob_stuff
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 7621 |
Proposed branch: | lp:~edb/quam-plures/cronjob_stuff |
Merge into: | lp:quam-plures |
Diff against target: |
494 lines (+97/-149) 7 files modified
qp_inc/cron/cronjobs.ctrl.php (+28/-46) qp_inc/cron/jobs/_error_test.job.php (+0/-15) qp_inc/cron/jobs/_post_notifications.job.php (+5/-13) qp_inc/cron/jobs/_test.job.php (+0/-15) qp_inc/cron/views/_cronjob_list.view.php (+41/-48) qp_plugins/test_plugin/README.html (+1/-0) qp_plugins/test_plugin/_test.plugin.php (+22/-12) |
To merge this branch: | bzr merge lp:~edb/quam-plures/cronjob_stuff |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tilman Blumenbach (community) | Approve | ||
EdB | Needs Resubmitting | ||
Review via email: mp+65107@code.launchpad.net |
Commit message
Description of the change
Tilman Blumenbach (tblue) wrote : | # |
hmmm... dunno why. Don't recall it cuz it's been a while, and for today my mission seems to be somehow fixing this POS software known as bazaar. It decided to always throw an error at me so I'm back to deleting everything and guessing at which version and combination of whatever actually works.
Oh well. Let it sit I guess.
Maybe because it is one tiny little step in a HUGE pile of crap in the core? I mean, there are very few aspects of the whole cronjob arrangement that actually work and this was just a teeny tiny little step towards making the whole thing work. Dunno though. Don't recall and don't have time to play with one little branch right now. Or the ability to play with it given that bazaar decided to die.
Tilman Blumenbach (tblue) wrote : | # |
Hm, I don't know, it's not like it breaks the branch or something... I can merge it if you think it'd be a good idea? Or if you want me to change it back to 0, just move branch ownership to quam-plures-core (same for the other branches you have in review -- so I can fix stuff if necessary).
Tilman Blumenbach (tblue) wrote : | # |
Marking as Needs Fixing, see above:
> Looks fine, but why do you set $ctst_error to 0 (used to be 1) when setting
> the default filters for the cronjob list? This way, failed cronjobs are hidden
> by default; shouldn't the admin see them right away?
Setting that thing to 0 may have been a brain-fart, but might have had "hand in the air gives up in disgust" awareness behind it, so bear with me as I explain what might have been the case and before I dig in to code to confirm or deny what I am about to document.
The problem MIGHT be that the error conditions it reports on having nothing to do with cron job errors. Rather, it reports "a problem exists" when the actual problem really is that our code is disgracefully sloppy and fails to clean up after itself. Specifically, if you remove a plugin that was the target of a scheduled job then you get an error. Not because cron failed in any way, and not because cron did a job and returned a failure notification, but because our code failed to remove the cron job from the scheduler when the installation owner instructed the core to remove the plugin.
Additionally and possibly related, I am pretty sure I learned (while trying to understand cron job stuff) that any error code a job returns is ONLY important internally. In other words if a cron job returns 100 it is up to us to interpret that as either good or bad or whatever. And we, of course, have nothing for a plugin author to reference on that topic. Why? Because we inherited a lump of coal that we have not yet compressed and polished into a rather awesome diamond. Again. Thus, all "error reporting" is currently bogus and useless and 100% misleading. Thus, I figured why should we bother to report them?
I think. Just thinking before diving it. Seriously. I could be completely off and it could have just been a complete mistake. I've done that once or twice ;)
Anyway now I'll jump into the code now that my head is a little bit back where it was when I started playing this branch.
Tilman Blumenbach (tblue) wrote : | # |
Okay, have fun digging. ;)
Resubmitting after just setting it back to a '1' value.
For the record, this is one very small step down the crontask path that is kinda documented at http://
dang. forgot to select resubmit.
Tilman Blumenbach (tblue) wrote : | # |
Hmm, let's finally approve this (again).
Bump? I guess I don't mind doing my own merging as long as no one who is going to look has found any objection. Tblue gave this an "approve", so Lee are you interested in taking a look? If not no problem. If so give a comment so we know, then one of us will know if we should do a merge or not.
I actually do want to avoid self-merges due to it is a bad place to be. Some of my branches "work without errors" but they weren't the best possible code. So the feedback makes it "work without errors and be better code", and self-merging takes away that opportunity.
But look how old this stuff gets :(
Preview Diff
1 | === modified file 'qp_inc/cron/cronjobs.ctrl.php' |
2 | --- qp_inc/cron/cronjobs.ctrl.php 2010-12-31 12:12:03 +0000 |
3 | +++ qp_inc/cron/cronjobs.ctrl.php 2011-09-01 02:17:27 +0000 |
4 | @@ -44,72 +44,55 @@ |
5 | param( 'results_crontab_order', 'string', '-A', true ); |
6 | param( 'results_crontab_page', 'integer', 1, true ); |
7 | |
8 | - |
9 | -// fp> The if below was the point where THE LINE WAS CROSSED! |
10 | -// This is bloated here. This has to go into the action handling block (and maybe a function) |
11 | -// THIS IS NO LONGER CONTROLLER INITIALIZATION. THIS IS ACTION EXECUTION! |
12 | -// dh> ok. Moved the other param inits above. Ok? I don't think it should be an extra function.. |
13 | - |
14 | // Init names and params for "static" available jobs and ask Plugins about their jobs: |
15 | if( $action == 'new' || $action == 'create' ) |
16 | { |
17 | // NOTE: keys starting with "plugin_" are reserved for jobs provided by Plugins |
18 | $cron_job_names = array( |
19 | - 'test' => T_('Basic test job'), |
20 | - 'error' => T_('Error test job'), |
21 | - 'prune_hits_sessions' => T_('Prune old hits & sessions'), |
22 | - // post notifications, not user schedulable |
23 | - ); |
24 | + 'prune_hits_sessions' => T_('Prune old hits & sessions'), |
25 | + ); |
26 | $cron_job_params = array( |
27 | - 'test' => array( |
28 | - 'ctrl' => 'cron/jobs/_test.job.php', |
29 | - 'params' => NULL ), |
30 | - 'error' => array( |
31 | - 'ctrl' => 'cron/jobs/_error_test.job.php', |
32 | - 'params' => NULL ), |
33 | - 'prune_hits_sessions' => array( |
34 | - 'ctrl' => 'cron/jobs/_prune_hits_sessions.job.php', |
35 | - 'params' => NULL ), |
36 | - // post notifications, not user schedulable |
37 | - ); |
38 | + 'prune_hits_sessions' => array( |
39 | + 'ctrl' => 'cron/jobs/_prune_hits_sessions.job.php', |
40 | + 'params' => NULL ), |
41 | + ); |
42 | |
43 | // Get additional jobs from Plugins: |
44 | foreach( $Plugins->trigger_collect( 'GetCronJobs' ) as $plug_ID => $jobs ) |
45 | { |
46 | - if( ! is_array($jobs) ) |
47 | + if( ! is_array( $jobs ) ) |
48 | { |
49 | - $Debuglog->add( sprintf('GetCronJobs() for plugin #%d did not return array. Ignoring its jobs.', $plug_ID), array('plugins', 'error') ); |
50 | + $Debuglog->add( sprintf( T_('GetCronJobs() for plugin #%d did not return array. Ignoring its jobs.'), $plug_ID ), array('plugins', 'error') ); |
51 | continue; |
52 | } |
53 | foreach( $jobs as $job ) |
54 | { |
55 | // Validate params from plugin: |
56 | - if( ! isset($job['params']) ) |
57 | + if( ! isset( $job['params'] ) ) |
58 | { |
59 | $job['params'] = NULL; |
60 | } |
61 | - if( ! is_array($job) || ! isset($job['ctrl'], $job['name']) ) |
62 | + if( ! is_array( $job ) || ! isset( $job['ctrl'], $job['name'] ) ) |
63 | { |
64 | - $Debuglog->add( sprintf('GetCronJobs() for plugin #%d did return invalid job. Ignoring.', $plug_ID), array('plugins', 'error') ); |
65 | + $Debuglog->add( sprintf( T_('GetCronJobs() for plugin #%d returned an invalid job. Ignoring.'), $plug_ID ), array('plugins', 'error') ); |
66 | continue; |
67 | } |
68 | if( isset($job['params']) && ! is_array($job['params']) ) |
69 | { |
70 | - $Debuglog->add( sprintf('GetCronJobs() for plugin #%d did return invalid job params (not an array). Ignoring.', $plug_ID), array('plugins', 'error') ); |
71 | + $Debuglog->add( sprintf( T_('GetCronJobs() for plugin #%d did return invalid job params (not an array). Ignoring.'), $plug_ID ), array('plugins', 'error') ); |
72 | continue; |
73 | } |
74 | $ctrl_id = 'plugin_'.$plug_ID.'_'.$job['ctrl']; |
75 | |
76 | $cron_job_names[$ctrl_id] = $job['name']; |
77 | $cron_job_params[$ctrl_id] = array( |
78 | - 'ctrl' => $ctrl_id, |
79 | - 'params' => $job['params'], |
80 | - ); |
81 | + 'ctrl' => $ctrl_id, |
82 | + 'params' => $job['params'], |
83 | + ); |
84 | } |
85 | } |
86 | } |
87 | |
88 | - |
89 | switch( $action ) |
90 | { |
91 | case 'new': |
92 | @@ -157,7 +140,7 @@ |
93 | $edited_Cronjob->set( 'params', $cron_job_params[$cjob_type]['params'] ); |
94 | |
95 | if( ! param_errors_detected() ) |
96 | - { // No errors |
97 | + { // No errors |
98 | |
99 | // Save to DB: |
100 | $edited_Cronjob->dbinsert(); |
101 | @@ -178,7 +161,7 @@ |
102 | // TODO: prevent deletion of running tasks. |
103 | $DB->begin(); |
104 | |
105 | - $tsk_status = $DB->get_var( |
106 | + $tsk_status = $DB->get_var( |
107 | 'SELECT clog_status |
108 | FROM T_cron__log |
109 | WHERE clog_ctsk_ID= '.$ctsk_ID, |
110 | @@ -187,17 +170,18 @@ |
111 | if( $tsk_status == 'started' ) |
112 | { |
113 | $DB->rollback(); |
114 | - |
115 | $Messages->add( sprintf( T_('Job #%d is currently running. It cannot be deleted.'), $ctsk_ID ), 'error' ); |
116 | } |
117 | else |
118 | { |
119 | // Delete task: |
120 | - $DB->query( 'DELETE FROM T_cron__task |
121 | + $DB->query( 'DELETE |
122 | + FROM T_cron__task |
123 | WHERE ctsk_ID = '.$ctsk_ID ); |
124 | |
125 | // Delete log (if exists): |
126 | - $DB->query( 'DELETE FROM T_cron__log |
127 | + $DB->query( 'DELETE |
128 | + FROM T_cron__log |
129 | WHERE clog_ctsk_ID = '.$ctsk_ID ); |
130 | |
131 | $DB->commit(); |
132 | @@ -209,12 +193,12 @@ |
133 | $action = 'list'; |
134 | break; |
135 | |
136 | - |
137 | case 'view': |
138 | $cjob_ID = param( 'cjob_ID', 'integer', true ); |
139 | |
140 | $sql = 'SELECT * |
141 | - FROM T_cron__task LEFT JOIN T_cron__log ON ctsk_ID = clog_ctsk_ID |
142 | + FROM T_cron__task |
143 | + LEFT JOIN T_cron__log ON ctsk_ID = clog_ctsk_ID |
144 | WHERE ctsk_ID = '.$cjob_ID; |
145 | $cjob_row = $DB->get_row( $sql, OBJECT, 0, 'Get cron job and log' ); |
146 | if( empty( $cjob_row ) ) |
147 | @@ -226,16 +210,14 @@ |
148 | |
149 | case 'list': |
150 | // Detect timed out tasks: |
151 | - $sql = " UPDATE T_cron__log |
152 | - SET clog_status = 'timeout' |
153 | - WHERE clog_status = 'started' |
154 | - AND clog_realstart_datetime < ".$DB->quote( date2mysql( time() + $time_difference - $cron_timeout_delay ) ); |
155 | + $sql = "UPDATE T_cron__log |
156 | + SET clog_status = 'timeout' |
157 | + WHERE clog_status = 'started' |
158 | + AND clog_realstart_datetime < ".$DB->quote( date2mysql( time() + $time_difference - $cron_timeout_delay ) ); |
159 | $DB->query( $sql, 'Detect cron timeouts.' ); |
160 | - |
161 | break; |
162 | } |
163 | |
164 | - |
165 | // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect) |
166 | $AdminUI->disp_html_head(); |
167 | |
168 | @@ -269,4 +251,4 @@ |
169 | // Display body bottom, debug info and close </html>: |
170 | $AdminUI->disp_global_footer(); |
171 | |
172 | -?> |
173 | \ No newline at end of file |
174 | +?> |
175 | |
176 | === removed file 'qp_inc/cron/jobs/_error_test.job.php' |
177 | --- qp_inc/cron/jobs/_error_test.job.php 2009-12-12 16:12:01 +0000 |
178 | +++ qp_inc/cron/jobs/_error_test.job.php 1970-01-01 00:00:00 +0000 |
179 | @@ -1,15 +0,0 @@ |
180 | -<?php |
181 | -/** |
182 | - * This file implements the Error Test Cron controller |
183 | - * |
184 | - * @author fplanque: Francois PLANQUE |
185 | - * |
186 | - * @package pond |
187 | - */ |
188 | -if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); |
189 | - |
190 | -$result_message = T_('The Error TEST cron controller simulates an error, thus this "error" is normal!'); |
191 | - |
192 | -return 100; /* Simulated error */ |
193 | - |
194 | -?> |
195 | \ No newline at end of file |
196 | |
197 | === modified file 'qp_inc/cron/jobs/_post_notifications.job.php' |
198 | --- qp_inc/cron/jobs/_post_notifications.job.php 2009-12-12 16:12:01 +0000 |
199 | +++ qp_inc/cron/jobs/_post_notifications.job.php 2011-09-01 02:17:27 +0000 |
200 | @@ -4,16 +4,12 @@ |
201 | * |
202 | * @author fplanque: Francois PLANQUE |
203 | * |
204 | - * @todo dh> Should this also handle feedback notifications (according to the "outbound_notifications_mode" setting)? |
205 | - * fp> No. The feedback notifications should have their own job. |
206 | - * |
207 | * @package pond |
208 | */ |
209 | if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); |
210 | |
211 | global $Settings; |
212 | |
213 | - |
214 | if( $Settings->get( 'outbound_notifications_mode' ) != 'cron' ) |
215 | { // Autopruning is NOT requested |
216 | $result_message = T_('Post notifications are not set to run as a scheduled task.'); |
217 | @@ -23,30 +19,26 @@ |
218 | // Get the ID of the post we are supposed to post-process: |
219 | if( empty( $job_params['item_ID'] ) ) |
220 | { |
221 | - $result_message = 'No item_ID parameter received.'; // No trans. |
222 | + $result_message = T_('No item_ID parameter received.'); |
223 | return 3; |
224 | } |
225 | |
226 | $item_ID = $job_params['item_ID']; |
227 | |
228 | - |
229 | // Notify that we are going to take care of that post's post processing: |
230 | $DB->query( 'UPDATE T_items__item |
231 | SET post_notifications_status = "started" |
232 | WHERE post_ID = '.$item_ID.' |
233 | - AND post_notifications_status = "todo" |
234 | - AND post_notifications_ctsk_ID = '.$job_params['ctsk_ID'] ); |
235 | + AND post_notifications_status = "todo" |
236 | + AND post_notifications_ctsk_ID = '.$job_params['ctsk_ID'] ); |
237 | if( $DB->rows_affected != 1 ) |
238 | -{ // We would not "lock" the requested post |
239 | +{ // We would not "lock" the requested post |
240 | $result_message = sprintf( T_('Could not lock post #%d. It may already be processed.'), $item_ID ); |
241 | return 4; |
242 | } |
243 | |
244 | // Get the Item: |
245 | $ItemCache = & get_Cache( 'ItemCache' ); |
246 | -/** |
247 | - * @var Item |
248 | - */ |
249 | $edited_Item = & $ItemCache->get_by_ID( $item_ID ); |
250 | |
251 | // send outbound pings: |
252 | @@ -65,4 +57,4 @@ |
253 | |
254 | return 1; /* ok */ |
255 | |
256 | -?> |
257 | \ No newline at end of file |
258 | +?> |
259 | |
260 | === removed file 'qp_inc/cron/jobs/_test.job.php' |
261 | --- qp_inc/cron/jobs/_test.job.php 2009-12-12 16:12:01 +0000 |
262 | +++ qp_inc/cron/jobs/_test.job.php 1970-01-01 00:00:00 +0000 |
263 | @@ -1,15 +0,0 @@ |
264 | -<?php |
265 | -/** |
266 | - * This file implements the test Cron controller |
267 | - * |
268 | - * @author fplanque: Francois PLANQUE |
269 | - * |
270 | - * @package pond |
271 | - */ |
272 | -if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); |
273 | - |
274 | -$result_message = T_('The TEST cron controller says hello!'); |
275 | - |
276 | -return 1; /* ok */ |
277 | - |
278 | -?> |
279 | \ No newline at end of file |
280 | |
281 | === modified file 'qp_inc/cron/views/_cronjob_list.view.php' |
282 | --- qp_inc/cron/views/_cronjob_list.view.php 2011-03-07 14:26:49 +0000 |
283 | +++ qp_inc/cron/views/_cronjob_list.view.php 2011-09-01 02:17:27 +0000 |
284 | @@ -24,7 +24,6 @@ |
285 | */ |
286 | if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); |
287 | |
288 | - |
289 | // Get filters: |
290 | global $ctst_pending, $ctst_started, $ctst_timeout, $ctst_error, $ctst_finished; |
291 | if( !$ctst_pending && !$ctst_started && !$ctst_timeout && !$ctst_error && !$ctst_finished ) |
292 | @@ -33,6 +32,7 @@ |
293 | $ctst_started = 1; |
294 | $ctst_timeout = 1; |
295 | $ctst_error = 1; |
296 | + $ctst_finished = 0; |
297 | } |
298 | |
299 | /* |
300 | @@ -67,7 +67,6 @@ |
301 | |
302 | $Results->title = get_manual_link( 'scheduled-jobs' ).T_('Scheduled jobs'); |
303 | |
304 | - |
305 | $Results->global_icon( T_('Refresh'), 'refresh', regenerate_url(), T_('Refresh'), 3, 4 ); |
306 | if( $current_User->check_perm( 'options', 'edit', false, NULL ) ) |
307 | { // Permission to edit settings: |
308 | @@ -99,41 +98,40 @@ |
309 | ) |
310 | ); |
311 | |
312 | - |
313 | -$Results->cols[] = array( |
314 | - 'th' => T_('ID'), |
315 | - 'order' => 'ctsk_ID', |
316 | - 'th_class' => 'shrinkwrap', |
317 | - 'td_class' => 'shrinkwrap', |
318 | - 'td' => '$ctsk_ID$' |
319 | - ); |
320 | - |
321 | -$Results->cols[] = array( |
322 | - 'th' => T_('Planned at'), |
323 | - 'order' => 'ctsk_start_datetime', |
324 | - 'td_class' => 'shrinkwrap', |
325 | - 'td' => '$ctsk_start_datetime$', |
326 | - ); |
327 | - |
328 | -$Results->cols[] = array( |
329 | - 'th' => T_('Name'), |
330 | - 'order' => 'ctsk_name', |
331 | - 'td' => '<a href="%regenerate_url(\'action,cjob_ID\',\'action=view&cjob_ID=$ctsk_ID$\')%">$ctsk_name$</a>', |
332 | - ); |
333 | - |
334 | -$Results->cols[] = array( |
335 | - 'th' => T_('Status'), |
336 | - 'order' => 'status', |
337 | - 'td_class' => 'shrinkwrap cron_$status$', |
338 | - 'td' => '$status$', |
339 | - ); |
340 | - |
341 | -$Results->cols[] = array( |
342 | - 'th' => T_('Repeat'), |
343 | - 'order' => 'ctsk_repeat_after', |
344 | - 'td_class' => 'shrinkwrap', |
345 | - 'td' => '$ctsk_repeat_after$', |
346 | - ); |
347 | +$Results->cols[] = array( |
348 | + 'th' => T_('ID'), |
349 | + 'order' => 'ctsk_ID', |
350 | + 'th_class' => 'shrinkwrap', |
351 | + 'td_class' => 'shrinkwrap', |
352 | + 'td' => '$ctsk_ID$' |
353 | +); |
354 | + |
355 | +$Results->cols[] = array( |
356 | + 'th' => T_('Planned at'), |
357 | + 'order' => 'ctsk_start_datetime', |
358 | + 'td_class' => 'shrinkwrap', |
359 | + 'td' => '$ctsk_start_datetime$', |
360 | +); |
361 | + |
362 | +$Results->cols[] = array( |
363 | + 'th' => T_('Name'), |
364 | + 'order' => 'ctsk_name', |
365 | + 'td' => '<a href="%regenerate_url(\'action,cjob_ID\',\'action=view&cjob_ID=$ctsk_ID$\')%">$ctsk_name$</a>', |
366 | +); |
367 | + |
368 | +$Results->cols[] = array( |
369 | + 'th' => T_('Status'), |
370 | + 'order' => 'status', |
371 | + 'td_class' => 'shrinkwrap cron_$status$', |
372 | + 'td' => '$status$', |
373 | +); |
374 | + |
375 | +$Results->cols[] = array( |
376 | + 'th' => T_('Repeat'), |
377 | + 'order' => 'ctsk_repeat_after', |
378 | + 'td_class' => 'shrinkwrap', |
379 | + 'td' => '$ctsk_repeat_after$', |
380 | +); |
381 | |
382 | function crontab_actions( $ctsk_ID, $status ) |
383 | { |
384 | @@ -143,26 +141,21 @@ |
385 | |
386 | if( $status != 'started' && $current_User->check_perm( 'options', 'edit', false, NULL ) ) |
387 | { // User can edit options: |
388 | - $col = action_icon( T_('Delete this job!'), 'delete', |
389 | - regenerate_url( 'action', 'ctsk_ID='.$ctsk_ID.'&action=delete') ); |
390 | + $col = action_icon( T_('Delete this job!'), 'delete', regenerate_url( 'action', 'ctsk_ID='.$ctsk_ID.'&action=delete' ) ); |
391 | } |
392 | |
393 | return $col; |
394 | } |
395 | $Results->cols[] = array( |
396 | - 'th' => T_('Actions'), |
397 | - 'td_class' => 'shrinkwrap', |
398 | - 'td' => '%crontab_actions( #ctsk_ID#, #status# )%', |
399 | - ); |
400 | - |
401 | - |
402 | + 'th' => T_('Actions'), |
403 | + 'td_class' => 'shrinkwrap', |
404 | + 'td' => '%crontab_actions( #ctsk_ID#, #status# )%', |
405 | +); |
406 | |
407 | // Display results : |
408 | $Results->display(); |
409 | |
410 | - |
411 | global $srvc_url; |
412 | echo '<p>[<a href="'.$srvc_url.'cron_exec.php" onclick="return pop_up_window( \''.$srvc_url.'cron_exec.php\', \'evo_cron\' )" target="evo_cron">'.T_('Execute pending jobs in a popup window now!').'</a>]</p>'; |
413 | |
414 | - |
415 | -?> |
416 | \ No newline at end of file |
417 | +?> |
418 | |
419 | === modified file 'qp_plugins/test_plugin/README.html' |
420 | --- qp_plugins/test_plugin/README.html 2010-12-18 18:52:49 +0000 |
421 | +++ qp_plugins/test_plugin/README.html 2011-09-01 02:17:27 +0000 |
422 | @@ -101,6 +101,7 @@ |
423 | <h2>Release History:</h2> |
424 | <div id="log"> |
425 | <dl> |
426 | +<dt>0.2</dt><dd>moved sample cronjobs into this plugin (18-Jun-11)</dd> |
427 | <dt>0.1</dt><dd>initial release (1-Jan-11)</dd> |
428 | </dl> |
429 | </div> |
430 | |
431 | === modified file 'qp_plugins/test_plugin/_test.plugin.php' |
432 | --- qp_plugins/test_plugin/_test.plugin.php 2010-12-31 11:43:06 +0000 |
433 | +++ qp_plugins/test_plugin/_test.plugin.php 2011-09-01 02:17:27 +0000 |
434 | @@ -58,7 +58,7 @@ |
435 | var $sub_group = 'plugin demo'; // used if $group is 'other' |
436 | var $number_of_installs = 1; |
437 | var $priority = 50; |
438 | - var $version = '0.1'; |
439 | + var $version = '0.2'; |
440 | |
441 | |
442 | /** |
443 | @@ -234,9 +234,9 @@ |
444 | function GetExtraEvents() |
445 | { |
446 | return array( |
447 | - // Gets "min" and "max" as params and should return a random number in between: |
448 | - 'test_plugin_get_random' => $this->T_('TEST plugin event that returns a random number.'), |
449 | - ); |
450 | + // Gets "min" and "max" as params and should return a random number in between: |
451 | + 'test_plugin_get_random' => $this->T_('TEST plugin event that returns a random number.'), |
452 | + ); |
453 | } |
454 | |
455 | |
456 | @@ -245,13 +245,19 @@ |
457 | */ |
458 | function GetCronJobs( & $params ) |
459 | { |
460 | - return array( |
461 | - array( |
462 | - 'name' => $this->T_('TEST plugin - cron job'), |
463 | - 'ctrl' => 'test_job', |
464 | - 'params' => array( 'param' => 1 ), |
465 | - ), |
466 | - ); |
467 | + $jobs = array( |
468 | + array( |
469 | + 'name' => $this->T_('TEST plugin - cron job'), |
470 | + 'ctrl' => 'test_job', |
471 | + 'params' => array( 'param' => 1 ) |
472 | + ), |
473 | + array( |
474 | + 'name' => $this->T_('TEST plugin - cron job ERROR'), |
475 | + 'ctrl' => 'test_job_error', |
476 | + 'params' => array( 'param' => 1 ) |
477 | + ), |
478 | + ); |
479 | + return $jobs; |
480 | } |
481 | |
482 | |
483 | @@ -262,7 +268,11 @@ |
484 | { |
485 | if( $params['ctrl'] == 'test_job' ) |
486 | { |
487 | - return array( 'code' => 1, 'message' => $this->T_('Test successful.') ); |
488 | + return array( 'code' => 1, 'message' => $this->T_('The TEST plugin cron job says hello!') ); |
489 | + } |
490 | + if( $params['ctrl'] == 'test_job_error' ) |
491 | + { |
492 | + return array( 'code' => 100, 'message' => $this->T_('The TEST plugin Error cron job simulates an error, thus this "error" is normal!') ); |
493 | } |
494 | } |
495 |
Looks fine, but why do you set $ctst_error to 0 (used to be 1) when setting the default filters for the cronjob list? This way, failed cronjobs are hidden by default; shouldn't the admin see them right away?