PDA

View Full Version : External Thread Creation: Registry Object is not an Object error


TeknoSounds
09-19-2011, 07:22 AM
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):
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:
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.

//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', $vbulletin, ERRTYPE_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:

$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_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.