Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
Coding in 3.5 (useful for people coming over from 3.0.x)
Brad
Join Date: Nov 2001
Posts: 4,765

Washington
by Brad Brad is offline 23 Jan 2006

The following was written by Kier for the developers. He has agreed to release it here.

This was posted by Wayne Luke in this post last June. I feel it's important information lost in an old thread so I've re-posted here.


Variables in the $vbulletin (vB_Registry) class

Just about all the variables that used to get set up by init.php have now been migrated to the $vbulletin class.

When migrating the old code, I don't want to see this sort of thing unless there's a specific reason for it:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Rather, the code should look like this:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Database

The MySQL database class has been totally rewritten, and the object is now called $db, rather than the old $DB_site.

You can also reference the database object via $vbulletin->db, so there is no real need to put $db into the list of globals in functions.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Outside of function scope however, continue to use $db rather than $vbulletin->db.

Whereas we used to have a single $DB_site->query() function to run SQL queries, there are now three public functions to execute SQL. They are:

$db->query_read
Use this function to execute SELECT and SHOW queries only. If the user is using MySQL replication, these queries will execute on their slave server.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

$db->query_write
Use this function to execute UPDATE, ALTER and all other data-modifying queries. query_write() will execute on the master server in a replication situation.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


addslashes() and addslashes_like() should be dropped in query strings, as it's problematic for some non-MySQL systems. Right now, the correct way to replace these functions is to use the newly defined functions in the database class, like this:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Please also note that when escaping quotes for Javascript strings, you should no longer use 'addslashes()', but rather use 'js_addslashes()'.

Datastore

All items from the datastore now get fed directly into the $vbulletin class.
They become $vbulletin->itemname.

If their title is in the $unserialize array in the datastore class, they will be automatically unserialized when they are fetched.

Note that the code currently has a lot of code that is equivalent to

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

That will not work any more, as the datastore item variables are initialized with the datastore class.

Therefore, instead of checking 'isset' you will need to check

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Bitfields
The old $_BITFIELDS, $_FORUMOPTIONS, $_USEROPTIONS etc. arrays no longer exist as individual entities. They are now part of the $vbulletin data registry object and go by different names. All the data they contained is still there, but you'll need to talk to them differently.

If you look at the top of includes/class_core.php I have left a 'translation lookup table' so that it's easier to see where the data you are looking for has gone.

To avoid too much $object->array[key1][key2][key3][key4] stuff, there are references set up to allow you to talk to deep elements quickly. For example, $vbulletin->bf_ugp_adminpermissions is a reference to $vbulletin->bf_ugp['adminpermissions']... it makes more sense when you start using them

Oh... 'ugp' stands for usergroup permissions.

vB_Input Class

If you read includes/class_core.php, you'll notice that there's a class called vB_Input. This class deals with input into vBulletin and stuff that's related to the superglobal arrays ($_REQUEST, $_ENV, $_SERVER etc.)

Misc

As lots of variables have been shuffled around, you'll need to keep your eyes open for them. For example, $scriptpath is now $vbulletin->scriptpath and $nozip is now $vbulletin->nozip.

I strongly suggest that you read and familiarize yourself with the new init.php and the contents of includes/class_core.php before diving in.
Views: 3029
Reply With Quote
Comments
  #2  
Old 23 Jan 2006, 10:49
Developer's Avatar
Developer Developer is offline
 
Join Date: Sep 2005
Real name: Ahmed || Devo.
Very Good Tutorial i like it so much
__________________
Developer,,
"Know thing about everything ... Know everything about thing"

I was here as a coder, and i am there as a student
Reply With Quote
  #3  
Old 23 Jan 2006, 11:36
Ranma2k Ranma2k is offline
 
Join Date: Dec 2001
Real name: Waiel
Thanks Brad
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

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


New To Site? Need Help?

All times are GMT. The time now is 16:16.

Layout Options | Width: Wide Color: