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 01-24-2008, 12:11 PM
dionsis dionsis is offline
 
Join Date: Aug 2005
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Datamanager Issues

Ok can anyone including the developers out there suggest a method for solving

PHP Fatal error: Call to a member function query_first_slave() on a non-object in /path/to/my/forum/includes/functions.php on line 1194

from doing a bit of research it seems this error comes up mostly when a file X.php included file Y.PHP and Y.PHP would include the code for adding a user and in turn would include the globals.php, class_dm.php and class_dm_user.php

so it seems nested including is a problem for objects further down the line

has anyone got any idea's of how we can solve this issue as i'd like to make use of the datamanager for inserting users rather than the silly method of SQL inserting which isnt the best method going

Quote:
$cwd = getcwd();
chdir('/home/content/d/i/o/dionsis/html/acuffe/test/forum');
require_once('./global.php');
require_once('./includes/class_dm.php');
require_once('./includes/class_dm_user.php');
chdir($cwd);

$userdm = new vB_DataManager_User($vbulletin, ERRTYPE_ARRAY);

$userdm->set('username', $username);
$userdm->set('email', $email);
$userdm->set('password', $password);
$userdm->set('usergroupid',$usergroupid);
//$userdm->set('ipaddress', $ipaddress);
$userdm->set('timezoneoffset', $timezoneoffset);
$userdm->set_bitfield('options', 'adminemail', '1');
$userdm->set_bitfield('options', 'showemail', '1');

#If there are errors (eMail not set, eMail banned, Username taken, etc.) you can check for errors using
if (count($userdm->errors))
{
for($i=0; $i<count($userdm->errors); $i++)
{
print "ERROR{$i}:{$userdm->errors[$i]}\n";
return(false);
}
}
else
{
# If everything is OK
$newuserid = $userdm->save();
print "vbuserid:$newuserid\n";
return(true);
}
i also occassionally from time to time recieve this error

Quote:
[24-Jan-2008 05:57:01] PHP Fatal error: Call to a member function unlock_tables() on a non-object in /location/of/forum/includes/functions.php on line 5218
Again its all using the datamanager. I receive similar errors when using the likes of the Connector API.
Reply With Quote
  #2  
Old 01-25-2008, 04:07 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
// switch to vbulletin directory
$cwd getcwd();
chdir('/home/content/d/i/o/dionsis/html/acuffe/test/forum');

// include dependencies
require_once('./global.php');

// initialise datamanager
$userdm =& datamanager_init('User'$vbulletinERRTYPE_ARRAY);

// set options
$userdm->set('username'$username);
$userdm->set('email'$email);
$userdm->set('password'$password);
$userdm->set('usergroupid',$usergroupid);
//$userdm->set('ipaddress', $ipaddress);
$userdm->set('timezoneoffset'$timezoneoffset);
$userdm->set_bitfield('options''adminemail''1');
$userdm->set_bitfield('options''showemail''1');

// error checks
$userdm->pre_save();
if (
count($userdm->errors))
{
    for (
$i 0$i count($userdm->errors); $i++)
    {
        print 
"ERROR{$i}:{$userdm->errors[$i]}\n";
        return(
false);
    }
}

// all ok, save
$newuserid $userdm->save();

// switch back to home directory
chdir($cwd);

// return
print "vbuserid:$newuserid\n";
return(
true); 
Reply With Quote
  #3  
Old 01-25-2008, 04:18 AM
cheesegrits's Avatar
cheesegrits cheesegrits is offline
 
Join Date: May 2006
Posts: 500
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where / how are you calling this code?

And just out of interest, how are the various $foo variables ($username, etc) getting set? If this is a standalone piece of code, it would help if you posted the whole thing.

-- hugh
Reply With Quote
  #4  
Old 01-27-2008, 04:09 AM
dionsis dionsis is offline
 
Join Date: Aug 2005
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

im looking to make a script to help me bridge 2 applications

basically the app im using has a bridge function that when i choose a certain bridge, code gets executed in that bridge file, so there are create, update, delete functions in that bridge.

for the purposes of this attempt its create a user im trying to do, assuming getting this working will mean that i can do the others once these issue's are ironed out.

there are 2 options i have, use curl code to pass the data to an external file. or execute the vbulletin code in the bridge file, which would be for example, an index.php file, including another file which does an include on the bridge. so its nested inclusions and seems to be causing problems.

with curl we lose the nesting and it should work. the above code however isnt, and the code posted by dismounted doesnt seem to work either

ERROR0:Please complete the required field "Username".

i get that when i try passing data via the address bar

jm_adduser.php?username=testing&email=testing@gold enplec.com&password=simple

though the data SEEMS to get passed ok using
$username = $_REQUEST["username"]
etc etc to get the data
i can print the variable contents $username and it shows the passed data

but
$userdm->set('username', $username);

returns the error given above.

so this is my attempt at using an independent file to add a user to VB and i will curl the data to the file from the bridge file for simplisity

any help much appreciated, ive been at this for weeks

--------------- Added [DATE]1201414949[/DATE] at [TIME]1201414949[/TIME] ---------------

scratch the above i solved it myself

just as i wrote the last reply i thought to myself about a problem i had in work recently where data was there one minute, gone the next, and it was due to initialising something else killing the variables because they were only temporary

so i moved the setting $username and $password down the script to beside the $userdm->set , well just before that, and wham it works, tried the curl code to call the script and wham that worked from that end too.

so now i finally have the script working. although it might be helpful for others to explore what was causing the variables to get emptied between setting them and this code

SET THE VARIABLES HERE

// switch to vbulletin directory
$cwd = getcwd();
chdir('/home3/goldccom/public_html/forum');

// include dependencies
require_once('./global.php');
// initialise datamanager
$userdm =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY);

// set options
GONE BY THE TIME THEY GET HERE
$userdm->set('username', $username);
Reply With Quote
  #5  
Old 01-27-2008, 04:55 AM
cheesegrits's Avatar
cheesegrits cheesegrits is offline
 
Join Date: May 2006
Posts: 500
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

We'd have to see all the code between where you initially set them and calling global.php to know what was happening.

-- hugh
Reply With Quote
  #6  
Old 01-27-2008, 09:30 PM
dionsis dionsis is offline
 
Join Date: Aug 2005
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

the code is that of above given by dismounted

in a non working example the taking the passed values into a variable i put the $_REQUESTS at the top

in a working sample i put the $_REQUESTS above the $userdm->set('username', $username);
Reply With Quote
  #7  
Old 01-27-2008, 10:56 PM
cheesegrits's Avatar
cheesegrits cheesegrits is offline
 
Join Date: May 2006
Posts: 500
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Strongly suggest you use $vbulletin->clean_array_gpc() to sanitize your inputs.

BTW, is the password clear text or md5 hashed?

-- hugh
Reply With Quote
  #8  
Old 01-28-2008, 10:46 AM
dionsis dionsis is offline
 
Join Date: Aug 2005
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the cleaning array tip, i didnt know that existed

password is plain text
username is plain text
email is plain text all passed through the address bar, recieved by $_REQUEST absolutely fine

but after including global and initialising the datamanager the variables i have assigned the value of the passed parameters empty, so i had to move the $_REQUEST being passed into a variable lower in the script to keep the value's for use to pass to the datamanager to create a user.
Reply With Quote
  #9  
Old 01-28-2008, 10:48 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So is it working now?
Reply With Quote
  #10  
Old 01-28-2008, 11:45 AM
dionsis dionsis is offline
 
Join Date: Aug 2005
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

aye if i move the variables down just before

$userdm->set('username', $username);

it works absolutely fine

anyone know where i'd get a list of bitfield and user options for the data manager, tried the manaul and developer docs but cant find a thing
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 12:42 PM.


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.04172 seconds
  • Memory Usage 2,273KB
  • 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
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete