HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


creating a new CRON item...

Login / Search

 [ Join | More ]
 Add topic 
Posted
Item has a rating of 5 (Liked by FletchLiked by Jean)  
Rating:
#91492 (In Topic #18398)
Avatar

Community saint

in the proper place in sources_custom/hooks/system/cron …

Made a new file to be run when cron runs.   This to do the updating of the 'rewards' stuff.    

I ran {site}\data\cron_bridge.php to make sure it was working.   Got an error in that file, so I know cron_bridge is calling it.   

Fixed the error.   cron_bridge runs without displaying anything, so it must run ok.

I added a 'reward' for all users with 50 posts, just so it would pick up many people and add them in..  ran cron_bridge and then check the table..  nothing new added.    So something isn't right.

Tried to add 'echo' into my code to watch what it was doing, but echo's don't show up at all…   perhaps the script that runs them is set up that way.

So how do I run my new code, with visual debugging clues, to see where it is going on?

Man I ask a hell of a lot of questions.


Paul
Back to the top
 
Posted
Rating:
#91494
Avatar

Community saint

Just dump the output to a text file using either file_put_contents or @fopen.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#91495
Avatar

Community saint

eh, I can't get any of the file writing to work… either that or it's calling up the code and not really running it.

Paul
Back to the top
 
Posted
Rating:
#91498
Avatar

Community saint

Without seeing what you have written, two things come to mind .

1) The path to the output file might not be right. So a bare minimum dump would be something like:

Code

$_f=fopen(get_file_base().'/test_arbo.txt','wb');
fwrite($_f,'Testing');
fclose($_f);

2) The class name in your hook file does not match the hook file name. i.e. for rewards.php the calss would be Hook_cron_rewards.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#91501
Avatar

Community saint

Well, I think I figured it out, I have:

Code (php)

if (!addon_installed('ocrewards')) return;
 

at the start of the code.  I just found out from a different 'hook/modules/members' thing I was working on… even though I have installed this addon that I am working on, this statement fails.

Just commented it out, will go run cron_bridge again and see what happens.

Paul
Back to the top
 
Posted
Rating:
#91506
Avatar

There's an additional parameter in that function that needs to be true if it's a non-bundled addon. That's because for non-bundled addons it has to work a little harder, doing a database call.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#91511
Avatar

Community saint

Ah.   For future reference for anyone else.

This function is in sources/support.php .

if you are checking for a non-bundled add-on, you need to add a 'true':

Code (php)

/**
 * Check to see if an addon is installed.
 *
 * @param  ID_TEXT              The module name
 * @param  boolean              Whether to check non-bundled addons (ones without an addon_registry hook)
 * @return boolean              Whether it is
 */

function addon_installed($addon,$non_bundled_too=false)
 

Paul
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: