Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 02-09-2004, 02:18 AM
filburt1 filburt1 is offline
 
Join Date: Feb 2002
Location: Maryland, US
Posts: 6,144
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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).
Reply With Quote
  #12  
Old 02-09-2004, 02:28 AM
g-force2k2 g-force2k2 is offline
 
Join Date: Mar 2002
Location: Everywhere you wanna be..
Posts: 1,608
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #13  
Old 02-09-2004, 02:29 AM
filburt1 filburt1 is offline
 
Join Date: Feb 2002
Location: Maryland, US
Posts: 6,144
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #14  
Old 02-09-2004, 02:31 AM
g-force2k2 g-force2k2 is offline
 
Join Date: Mar 2002
Location: Everywhere you wanna be..
Posts: 1,608
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

Cheers,
g-force2k2
Reply With Quote
  #15  
Old 02-09-2004, 02:33 AM
filburt1 filburt1 is offline
 
Join Date: Feb 2002
Location: Maryland, US
Posts: 6,144
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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...
Reply With Quote
  #16  
Old 02-09-2004, 02:45 AM
g-force2k2 g-force2k2 is offline
 
Join Date: Mar 2002
Location: Everywhere you wanna be..
Posts: 1,608
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #17  
Old 02-09-2004, 02:50 AM
filburt1 filburt1 is offline
 
Join Date: Feb 2002
Location: Maryland, US
Posts: 6,144
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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)
Reply With Quote
  #18  
Old 02-09-2004, 02:55 AM
g-force2k2 g-force2k2 is offline
 
Join Date: Mar 2002
Location: Everywhere you wanna be..
Posts: 1,608
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #19  
Old 02-09-2004, 03:01 PM
filburt1 filburt1 is offline
 
Join Date: Feb 2002
Location: Maryland, US
Posts: 6,144
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #20  
Old 02-18-2004, 07:10 PM
filburt1 filburt1 is offline
 
Join Date: Feb 2002
Location: Maryland, US
Posts: 6,144
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:41 PM.


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.04415 seconds
  • Memory Usage 2,273KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (5)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete