Ah yes, sorry for omitting that. LMDIR is a variant of the vB CWD and the impex IDIR. Those definitions call getcwd() and if it returns something, they use that value else '.' - LMDIR is set to the full path to the vB forum directory (/home2/username/www/forum in my case) as defined in the config file. When I execute the script I am in this directory.
I didn't mention it previously only because it didn't seem relevant. I get the error even when I reduce the require_once statement to:
Code:
require_once( './global.php' );
and comment out all of the statements that refer to my stuff, so you have this:
Code:
require_once( './global.php' );
//require_once( LMDIR . '/DatabaseOps.php' );
//require_once( LMDIR . '/AddNewUser.php' );
//require_once( LMDIR . '/AddNewCategory.php' );
//require_once( LMDIR . '/AddNewForum.php' );
//require_once( LMDIR . '/AddNewThreadPost.php' );
Which I found puzzling. At the top of my file I also followed the vB support recommendations thus:
Code:
/*
* Constants
*
* These definitions are used as per the
* recommendations of vbulletin support
*/
define( 'VB_AREA', 'External' );
define( 'SKIP_SESSIONCREATE', 1 );
define( 'SKIP_USERINFO', 1 );
And thought that perhaps this was causing the problem, but I am not familiar enough with exactly what these do to take a guess. I did rifle through the code a little and discovered that VB_AREA affects which sections of code are executed during page rendering. That said, it seems like you'd still need to include the global script even with these above three definitions. And having said that, one thought that I had was the opposite: that you actually do
not need the global script since you are defining yourself to be External and you are skipping the session and user stuff.
Eh, there I go again talking about code I know little about ... kinda like talking out of my backside. And I don't like doing that. Anyway, I needed to get something up and working so I tried various derivations as any programmer ultimately does. And as I mentioned I commented out
all of the aforementioned require_once statements and that - to my surprise - returned the correct result set with no errors. But I dunno ... just didn't seem "right" somehow, so I conducted a search on vb.org ... not much turned up, so I decided to post and ask those who are in-the-know.
Thanks again!
--------------- Added [DATE]1304524776[/DATE] at [TIME]1304524776[/TIME] ---------------
Quote:
Originally Posted by kh99
I think that's just because you haven't used any vb stuff in that code you posted, just the mysql stuff that goes directly to the database.
ETA: also, there's more than one global.php, so maybe the example script you looked at used a different one than you're including (there's on in admincp, for instance).
|
Touche' - good point. You are correct. The direct mysql stuff would work regardless of the vB error since it doesn't use any of the vB code to do its work. Duh.
I set the directory to be the top-level vB directory prior to the global include. And I am in that top-level vB directory when I type "php LMigrate.php"...
Thank you for the feedback, much appreciated!
--------------- Added [DATE]1304534406[/DATE] at [TIME]1304534406[/TIME] ---------------
Ok I figured out what the problem was, but don't know enough about the vB code to say why. The problem does indeed lie with these lines of code:
Code:
/*
* Constants
*
* These definitions are used as per the
* recommendations of vbulletin support
*/
define( 'VB_AREA', 'External' );
define( 'SKIP_SESSIONCREATE', 1 );
define( 'SKIP_USERINFO', 1 );
Specifically the SKIP_USERINFO line. That is, if I comment out only that one definition, then I don't see the vB error. So....can anyone explain what that does exactly so as to cause this error? And do I really need these lines of code if the plan is to run from the vB top-level forum directory and include the global source plus relevant sources from the includes directory? Ergo, what exactly does it mean to run a script without "loading the vB backend"?
Thanks!
--------------- Added [DATE]1304550656[/DATE] at [TIME]1304550656[/TIME] ---------------
Quote:
Originally Posted by kh99
This is a script you wrote yourself (as opposed to one of the vb scripts)? I think you have to define $phrasegroups as an array (and probably define a couple other arrays as well) before including global.php (see the top of any vb page script, like maybe showthread.php)
|
FINAL UPDATE: kh99 was indeed correct in the end. Simply by adding a few definitions of various templates the error went away, thus:
PHP Code:
$phrasegroups = array();
$specialtemplates = array();
$globaltemplates = array();
$actiontemplates = array();
Ended up being the difference maker. Just wanted to share this nugget of knowledge with others who might find it useful in the future.
'Still don't know exactly what SKIP_USERINFO does, but I'll get back to that. Right now I've got other higher priority stuff to work on, such as completing the migration. (!) There is another fellow Lefora user who is fed up and wants to bail, and I've agreed to help.
But I digress.
Thanks again!