vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   External Thread Creation: Registry Object is not an Object error (https://vborg.vbsupport.ru/showthread.php?t=270546)

TeknoSounds 09-19-2011 07:22 AM

External Thread Creation: Registry Object is not an Object error
 
Greetings, I'm (still) attempting to create a new thread outside VB, but now I'm getting the following errors (echoes 0 & 1 happen previously in the code):
Code:

012
Fatal error: MGCCbEvo_core::Registry object is not an object in [path]/mgc_cb_evo/classes/class_core.php on line 21

As you can see, this is from MGC chatbox. When the chatbox is disabled from the ACP, I then get the following error:
Code:

0123
Fatal error: Registry object is not an object in [path]/includes/class_dm.php on line 205

I can't seem to figure out why its not able to create the registry object for either MGC or the datamanager. Code below.

PHP Code:

    //Create New VB Thread from Event Info
    
public function CreateNewVBThread($date$name$venue$city$state) {
        
//Variables
        
echo 2;
        
$postip "127.0.0.1";
        
$userid 243;
        
$username 'Events Announcer';
        
$title = ($date ' - ' $name ' @ ' $venue ' - ' $city ', ' $state);
        
$threadinfo = array();
        
$forumdir "/myforumdirectory";
        
$specialtemplates = array();
        
$actiontemplates = array();
        
$globaltemplates = array();

        
chdir($forumdir);

        require(
$forumdir '/global.php');
        require(
$forumdir '/includes/functions_databuild.php');

        
//Determine City/Forum
        
if ($state "TX") {
            switch (
$city) {
                case 
"Austin":
                    
$forumid 70;
                    break;
                case 
"Dallas":
                    
$forumid 77;
                    break;
                case 
"Houston":
                    
$forumid 78;
                    break;
                case 
"San Antonio":
                    
$forumid 79;
                    break;
                default:
                    
$forumid 80;
                    break;
            }
        }
        else {
            
$forumid 81;
        }
        echo 
3;
        
//Create new thread given info below
        
$threaddm =& datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');

        
$foruminfo fetch_foruminfo($forumid);
        
$threaddm->set_info('forum'$foruminfo);
        
$threaddm->set_info('thread'$threadinfo);
        
$threaddm->setr('forumid'$forumid);
        
$threaddm->setr('userid'$userid);
        
$threaddm->setr('title'$title);
        
$threaddm->set('username'$username);
        
$threaddm->set('pagetext''This is a test');
        
$threaddm->set('allowsmilie'1);
        
$threaddm->set('visible'1);
        
$threaddm->set('ipaddress'$postip);
        
$threaddm->set('dateline'TIMENOW);
                
        
$threaddm->pre_save();
        if(
count($threaddm->errors) < 1)
        {
            
$threadid $threaddm->save();
            unset(
$threaddm);
            
build_thread_counters($threadid);
        }
        else 
        {
            print 
"Error making new thread! " $threaddm->errors[0] . $threaddm->errors[1] . $threaddm->errors[2] ;
        }
        
        
build_forum_counters($forumid);

    }  
//end CreateNewVBThread() */ 

The file does live in a folder outside of vb currently, though plans are to remove this section and place it in its own file in the vb folder later.

kh99 09-19-2011 06:43 PM

On this line:

PHP Code:

        $threaddm =& datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost'); 


you're passing $vbulletin to the datamanager_init() function but $vbulletin is not defined. If you want to pass the global $vbulletin object you need a "global $vbulletin;" statement before that call.

TeknoSounds 09-20-2011 03:30 AM

Okay did that and the errors are gone, but now its not doing anything again it seems *sigh* back to testing

kh99 09-20-2011 06:21 AM

You mean no errors but it's not creating a thread? I tried it and it's working for me. To test it I took out the word "public" and changed a few other things for my forum, but I think the important parts are the same.

TeknoSounds 09-20-2011 07:21 AM

argh!!! really?? Well dangit... Tho that is really good to know the code works as a standalone. Now just to get it to work when its supposed to be called.

Thanks so much for the help kh99 :D
But I might be back hehe.


All times are GMT. The time now is 03:12 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.01037 seconds
  • Memory Usage 1,755KB
  • 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
  • (2)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete