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

Reply
 
Thread Tools Display Modes
  #1  
Old 07-16-2006, 12:19 PM
Nimlh?g Nimlh?g is offline
 
Join Date: Jul 2006
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Issues creating multiple threads with Thread_FirstPost

I'm working on a script, which requires multiple threads to be posted in a newly created forum.

In order to do that, I've created a little function which takes some basic info like forumid, userid, title and post content, and creates a Thread_FirstPost datamanager instance and then saves the post.

This works like a charm .. only .. it'll post the first post, and then nothing. Once I call the function once, it simply won't do anything anymore after that.

What am I doing wrong here?

Function:
PHP Code:
// we'll be needing these :)
require_once(DIR .'/includes/class_dm.php');
require_once(
DIR .'/includes/class_dm_threadpost.php');
function 
postThread( &$vbulletin$forumid$userid$title$text$open=1$sticky=0$iconid=1$allowsmilie=)
{


      
$visible '1';    // we want the post to be visible
      
      // need a datamanager to post a new thread
    
$newThread =& datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');        
    
    
$foruminfo verify_id('forum'$forumid01);    // post in this forum
    
$newThread->set('forumid'$forumid);                // set the forumid
    
$newThread->set('userid'$userid);                    // post as this user
    
$newThread->set('pagetext'$text);                    // post this post
    
$newThread->set('title'$title);                    // post with this title
    
$newThread->set('allowsmilie'$allowsmilie);        // allow smilies, or not
    
$newThread->set('visible'$visible);                // make the post visible
    
$newThread->set'open'$open );                    // locked/unlocked
    
$newThread->set'sticky'$sticky );                // sticky/unsticky
    
$newThread->set'iconid'$iconid );                // post icon
    
$newThread->set_info('forum'$foruminfo);            // set the forum information
    
$newThread->save();                                    // save the post
    
unset( $newThread$pagetext );

Any suggestions?
Reply With Quote
  #2  
Old 07-16-2006, 01:19 PM
Code Monkey's Avatar
Code Monkey Code Monkey is offline
 
Join Date: May 2004
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Nimlh?g
Any suggestions?
Just a couple. Not sure if it's related to the problem or not.

You should have

PHP Code:
$foruminfo fetch_foruminfo($forumid); 
not

PHP Code:
$foruminfo verify_id('forum'$forumid01); 
Also you should have

PHP Code:
$threadinfo = array();
$newThread->set_info('thread'$threadinfo); 
Reply With Quote
  #3  
Old 07-16-2006, 03:49 PM
Nimlh?g Nimlh?g is offline
 
Join Date: Jul 2006
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If I get the foruminfo that way, I get the following errors:
Quote:
Fatal error: Existing data passed is not an array
Called set_existing in /www/testvb/includes/class_dm_threadpost.php on line 584
Called post_save_each_post in /www/testvb/includes/class_dm_threadpost.php on line 1536
Called post_save_each in /www/testvb/includes/class_dm_threadpost.php on line 1470
Called save in /www/newincludes/useful.php on line 28
Called postThread in /www/testvb/admincp/featuredcrap.php on line 145
in /includes/class_dm.php on line 235
I did a little bit of digging, and I'm getting the impression that this has something to do with the forumcache.

If I fetch the forum info, like so:
PHP Code:
$foruminfo fetch_foruminfo$forumidFALSE );
// instead of
$foruminfo verify_id('forum'$forumid ); 
then that error goes away, but the problem remains .. the second thread is not being posted

I'm thinking that perhaps vB expects the forumcache to be updated between two thread-postings or something?

As a last resort I can always use a simple redirect to post the second thread, which I'm guessing would work, but I'd rather get this to work if at all possible.
Reply With Quote
  #4  
Old 07-16-2006, 04:39 PM
Code Monkey's Avatar
Code Monkey Code Monkey is offline
 
Join Date: May 2004
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I know what it is. Are you posting in rapid succesion and thereby violating the default time interval between posts?

Just after your sets and before you save put this. It's what I do in Articlebot.

PHP Code:
$newThread->registry->options['floodchecktime'] = 0
Also, I believe you should also have the $newThread->pre_save() bit in there as that runs many functions needed for a thread.
Reply With Quote
  #5  
Old 07-16-2006, 05:46 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Re the above;

Instead of altering the floodcheck setting you should really add this ;

PHP Code:
$newThread->set_info('skip_floodcheck'true); 
AFAIK, presave isn't a requirement (and indeed, is not always used in vb source files).
Reply With Quote
  #6  
Old 07-17-2006, 01:36 AM
Code Monkey's Avatar
Code Monkey Code Monkey is offline
 
Join Date: May 2004
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Paul M
Re the above;

Instead of altering the floodcheck setting you should really add this ;
I will when 3.6 is released since that is when it begins it's availabilty. Thanks for the scouting report.

However, in the 3.5 series you need to do it the way I stated.

PHP Code:
$newThread->registry->options['floodchecktime'] = 0
Quote:
Originally Posted by Paul M
AFAIK, presave isn't a requirement (and indeed, is not always used in vb source files).
Also, the new setting for floodcheck is checked in pre_save_post() which is called by pre_save(). So, you will need to call the pre_save function in order to use that setting as far as I can see so far.

Even so, the inline docs for pre_save_post suggest it will is not likely called for threads, mostly posts. I'll have to test it when I update Articlebot for 3.6.
Reply With Quote
  #7  
Old 07-17-2006, 02:08 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by JumpD
Thanks for the scouting report.
What does that mean ?

Quote:
Originally Posted by JumpD
Also, the new setting for floodcheck is checked in pre_save_post() which is called by pre_save(). So, you will need to call the pre_save function in order to use that setting as far as I can see so far.
The reported post > new thread code does not seem to call presave, but does use that floodcheck setting.
Reply With Quote
  #8  
Old 07-18-2006, 12:53 AM
Code Monkey's Avatar
Code Monkey Code Monkey is offline
 
Join Date: May 2004
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Paul M
What does that mean ?
That means you found a new undocumented feature in 3.6 so I'm writing it down.

Quote:
Originally Posted by Paul M
The reported post > new thread code does not seem to call presave, but does use that floodcheck setting.
Well, the only place I can find it referenced in the 3.6 files regarding threads and posts is in class_dm_threadpost.php in pre_save_post(). If you find it anywhere else, please let me know. It's not in any of the $validfields settings that I have found.
Reply With Quote
  #9  
Old 07-18-2006, 03:18 AM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Had another look.

If presave() has not been called then save() calls it for you.
Reply With Quote
  #10  
Old 04-13-2007, 10:37 PM
FleXy FleXy is offline
 
Join Date: Dec 2006
Posts: 81
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

But how with this class (or another class_dm*) I can edit existing post? Please help!
example will be realy helpful
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 06:16 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04290 seconds
  • Memory Usage 2,294KB
  • Queries Executed 13 (?)
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
  • (8)bbcode_php
  • (8)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (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_postinfo_query
  • fetch_postinfo
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete