View Single Post
  #1  
Old 10-11-2009, 07:19 AM
mouth mouth is offline
 
Join Date: Jun 2009
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default undefined method db::query_first_slave() in class_dm_threadpost.php

Hi,

Version = 3.8.4 (PL1)

I am attempting to use the data manager to create a new thread in the forums. A user add an entry to an external calendar and I want to create a new thread in the forums for the external calendar entry.

I have some test code that has vBulletin data manager code only and that works fine. The thread is successfully added to the database ....

PHP Code:
<?
// Statements for vBulletin insert
$forums_path = $_SERVER['DOCUMENT_ROOT'] . '/forums';
define('VB_AREA', 'External');
define('SKIP_SESSIONCREATE', 1);
define('SKIP_USERINFO', 1);
define('CWD', $forums_path);
require_once(CWD . '/global.php');
require_once(CWD . '/includes/class_dm.php');
require_once(CWD . '/includes/class_dm_threadpost.php');
require_once(CWD . '/includes/functions_databuild.php');
// Statements for vBulletin insert
?>

<html>
<head>
<title>Events Calendar</title>
<link rel="stylesheet" type="text/css" href="/style.css">
</head>
<body>

<?
/* --- Insert calendar item into vBulletin forums --- */
// Statements for vBulletin insert - Refer to statements at the top of this page
$userid = 1;
// pick a forum to add the thread to
$forum_id = 82;
$title = "Testing 1-2-3";
$post_text = "Blah Blah Blah Blah";
$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$foruminfo = fetch_foruminfo($forum_id);
$threaddm->set_info('forum', $foruminfo);
$threaddm->set('forumid', $foruminfo['forumid']);
$threaddm->set('userid', $userid);
$threaddm->set('title', $title);
$threaddm->set('pagetext', $post_text);
$threaddm->set('allowsmilie', 1);
$threaddm->set('visible', 1);
$threaddm->pre_save();

if (count($threaddm->errors) > 0)
{
    // Errors occurred. Do not proceed with the save.
    // You may want to loop through $dataman->errors and 
    // display the results the user.
    $errorlist = '';
    foreach ($threaddm->errors AS $index => $error)
    {
        $errorlist .= "<li>$error</li>";
    } 
    echo "<ul>" . $errorlist . "</ul>";
}
else
{
    // No errors occurred.
    // Proceed with the save (see the next step).
    $thread_id = $threaddm->save();
    build_forum_counters($forum_id);
    echo "<br />thread id: " . $thread_id . "\n";

}  
/* --- Insert calendar item into vBulletin forums --- */

?>

</body>
</html>
When I insert this code into my calendar php script, the following fatal error is recorded in the php error log, when the script is run ...

PHP Fatal error: Call to undefined method db::query_first_slave() in [forums path]/includes/class_dm_threadpost.php on line 74

I have ensured that the call to vBulletin's global.php is not inside a function. Here is some of the code from my calendar script ...

PHP Code:
<?
error_reporting(E_ALL);
session_start();

require_once($_SERVER['DOCUMENT_ROOT'] . "/include/common.inc");
require_once($_SERVER['DOCUMENT_ROOT'] . "/include/functions.inc");
require_once("include/config.php");

// connect to the database
$conn = mysql_connect($db_host, $db_user, $db_pass, true) or die("Could not connect to database!");
mysql_select_db($db_name, $conn);

// Statements for vBulletin insert
$forums_path = $_SERVER['DOCUMENT_ROOT'] . '/forums';
define('VB_AREA', 'External');
define('SKIP_SESSIONCREATE', 1);
define('SKIP_USERINFO', 1);
define('CWD', $forums_path);
require_once(CWD . '/global.php');
require_once(CWD . '/includes/class_dm.php');
require_once(CWD . '/includes/class_dm_threadpost.php');
require_once(CWD . '/includes/functions_databuild.php');
// Statements for vBulletin insert
?>

<html>
<head>
[ ... ]
</head>
<body>
[ ... calendar html and php ...]

[ ... vBulletin test code as per above ... ]

[ ... calendar html and php ...]

</body>
</html>
Can anyone point me to where I can further analyse and resolve this? Or perhaps even can see my problem? Thanks.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06101 seconds
  • Memory Usage 1,784KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete