vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   vB3 cron system (https://vborg.vbsupport.ru/showthread.php?t=61327)

filburt1 02-09-2004 02:18 AM

The latest code block I posted is already at the global level. It would be easy for me to raise an error flag, but the problem is I would have to have a gargantuan tree of nested ifs (at least ten, more likely around 20) in order to gracefully have the code flow to the end of the file (the point at which the cron system resumes its work with the next job).

g-force2k2 02-09-2004 02:28 AM

so then are you trying to break the control of the cron job to stop the following scheduled cron jobs, because I see that you are logging the error that has occurred, and if thats the case couldn't you simple add a continue ; to end that section of the while loop in the file, after it the included cron php files are within the actual loop, it would then resume the next cron job after all, because the continue only breaks that certain loop.

Cheers,
g-force2k2

filburt1 02-09-2004 02:29 AM

To clear the ambiguity, I'm trying to make my custom cron job (vbms_checkmail.php) gracefully terminate and yield control to the next scheduled job (whatever.php), if there is any.

g-force2k2 02-09-2004 02:31 AM

Alright, then couldn't continue ; possibly do the trick?

Cheers,
g-force2k2

filburt1 02-09-2004 02:33 AM

That's actually a really good idea. The only problem would be that it could reference the wrong loop (for example, if I want to exit from within a loop).

Or wait, how would it work exactly? If continue is used in a function where there aren't even loops, would PHP just reversely traverse the code tree until it finds a loop, and then force the next iteration?

edit: http://www.php.net/continue for reference doesn't mention anything other than the freaky fact it supports an argument. I wish PHP was as clean as Java but as easy as it is now...

g-force2k2 02-09-2004 02:45 AM

Hmm... very interesting, I did some tests with continue ; in both an included file and a function and both returned errors, but something else did work.

PHP Code:

return ; 

It returns to the main script I am assuming here's the three php files that I made and when I told it to 'continue' or in this case 'return' it skipped the rest of the script.

numbermain.php
PHP Code:

<?php

error_reporting 
E_ALL & ~E_NOTICE ) ;

require_once ( 
"numberfunction.php" ) ;
while ( 
$x <= 35 ) :
    include ( 
"numbercount.php" ) ;
endwhile ;

?>

numbercount.php
PHP Code:

<?php

error_reporting 
E_ALL & ~E_NOTICE ) ;

global 
$x ;
$x++ ;
$dobreak do_check $x ) ;
if ( 
$dobreak ) :
    return ;
endif ;

echo 
$x "<br />" ;

?>

numberfunction.php
PHP Code:

<?php

error_reporting 
E_ALL & ~E_NOTICE ) ;

function 
do_check ( &$x 
{
    
$dobreak ;
    if ( 
$x == OR $x == ) :
        
$dobreak ;
    endif ;
    return 
$dobreak ;
}

?>

And the result was:

Code:

1
2
3
4
6
7
8
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

Skipped five and nine as I had asked the script. Maybe that will help some.

Cheers,
g-force2k2

filburt1 02-09-2004 02:50 AM

Well remember that because PHP's file inclusion functions are essentially identical to the #include preprocessor directive in C--just dumps a file into another file--the code being run is this:
PHP Code:

<?php 

error_reporting 
E_ALL & ~E_NOTICE ) ; 

require_once ( 
"numberfunction.php" ) ; 
while ( 
$x <= 35 ) : 
    
error_reporting E_ALL & ~E_NOTICE ) ; 

    function 
do_check ( &$x 
    { 
        
$dobreak 
        if ( 
$x == OR $x == ) : 
            
$dobreak 
        endif ; 
        return 
$dobreak 
    } 

endwhile ; 

?>

You always need braces surrounding an include or require when using control structures or loops: http://www.php.net/include/ (example 11-6)

g-force2k2 02-09-2004 02:55 AM

Quote:

Originally Posted by filburt1
Well remember that because PHP's file inclusion functions are essentially identical to the #include preprocessor directive in C--just dumps a file into another file--the code being run is this:

Yeah I don't really know C ( or C++ ) at all, wanted to learn some, but you don't think that placing a return to return the the main cron control script, which would be exiting out of the inner cron script that is erroring woud do what you're looking to accomplish?

Cheers,
g-force2k2

filburt1 02-09-2004 03:01 PM

Quote:

Originally Posted by g-force2k2
Yeah I don't really know C ( or C++ ) at all, wanted to learn some, but you don't think that placing a return to return the the main cron control script, which would be exiting out of the inner cron script that is erroring woud do what you're looking to accomplish?

Cheers,
g-force2k2

Bizarrely, it looks like that might work. However it looks like any death code would have to be within vbms_checkmail.php and none of its helper functions.
Quote:

Handling Returns: It is possible to execute a return() statement inside an included file in order to terminate processing in that file and return to the script which called it. Also, it's possible to return values from included files. You can take the value of the include call as you would a normal function.

filburt1 02-18-2004 07:10 PM

Interestingly, it looks like exit; will work. vB registers a shutdown function via register_shutdown_function() named exec_cron() that will, hopefully, cause the cron jobs to continue to run.


All times are GMT. The time now is 07:28 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01061 seconds
  • Memory Usage 1,758KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (5)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete