Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
List of changed var/array/function names
Brad
Join Date: Nov 2001
Posts: 4,765

 

Show Printable Version Email this Page Subscription
Brad Brad is offline 06-06-2005, 10:00 PM

A lot of things changed in 3.5 and you might find yourself lost for awhile as you figure out how to work with the new var/array/function names. This list should help you port your old 3.0.x hacks quicker, if you have anything to add to the list reply to this thread and I will edit the first post!

Note that some of these might not work in some parts of the new code, OOP changes a lot of things, in some cases you might be using $this-> or some other alternative to get to these.

On the front end they will work for the most part. Do remember that there are hooks littered in the 'build' functions like the one that builds postbit. For an example of working with such hooks you can check out a plug-in I released, I spend 5 minutes wondering why $post would not work until I realized I was begin an idiot!

Anyway check out the .xml file: https://vborg.vbsupport.ru/showthread.php?t=82623

Turned out I needed to use $this->post because that hook was inside of a function! Doh!

[high]The big list...[/high]

3.0.x version of the var will be on the left, 3.5 on the right as so:

3.0.x => 3.5

[high]Global[/high]

$DB_site-> => $db->
$bbuserinfo[] => $vbulletin->userinfo[]
$vboptions[] => $vbulletin->options[]
$_GET/$_REQUEST/$_POST/$_COOKIE => $vbulletin->GPC[]
globalize() => $vbulletin->input->clean_array_gpc()
Reply With Quote
  #2  
Old 06-07-2005, 04:12 PM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$DB_site->query(); => $db->query_read();
Reply With Quote
  #3  
Old 06-07-2005, 04:22 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm ... not always.
Only for SELECT.
For REPLACE/UPDATE/INSERT it would be query_write(), to support mySQL 4.1 Master/Slave.
To keep compatibility, query() is also available and will call the correct connection.
Reply With Quote
  #4  
Old 06-08-2005, 12:51 AM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yea I'll need to add that one, will cause alot of questions when this goes public, thanks guys and keep adding them as you find them
Reply With Quote
  #5  
Old 06-08-2005, 03:50 PM
Wayne Luke's Avatar
Wayne Luke Wayne Luke is offline
Senior Member
 
Join Date: Jan 2002
Location: Southern California
Posts: 1,694
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The following was written by Kier for the developers. He has agreed to release it 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:
PHP Code:
function foo()
{
    global 
$forumcache$vbulletin$vboptions;

    
$forumcache =& $vbulletin->forumcache;
    
$vboptions =& $vbulletin->options;

    foreach (
$forumcache AS $forumid => $forum)
    {
        if (
$vboptions['something'])
        {
            
// do stuff
        
}
    }

Rather, the code should look like this:
PHP Code:
function foo()
{
    global 
$vbulletin;

    foreach (
$vbulletin->forumcache AS $forumid => $forum)
    {
        if (
$vbulletin->options['something'])
        {
            
// do something
        
}
    }

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.
PHP Code:
function foo()
{
    global 
$vbulletin;

    
$items $vbulletin->db->query_read("SELECT * FROM " TABLE_PREFIX "user");
    while (
$item $vbulletin->db->fetch_array($items))
    {
        
// do stuff
    
}
    
$vbulletin->db->free_result($items);

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.
PHP Code:
$db->query_read("SELECT * FROM customer WHERE clue > 0"); 
$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.
PHP Code:
$db->query_write("UPDATE customer SET description = 'Clueless' WHERE clue <= 0"); 

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:
PHP Code:
$item $db->query_first("
    SELECT * FROM table
    WHERE foo = '" 
$db->escape_string($foo) . "'
    AND bar LIKE('%" 
$db->escape_string_like($bar) . "%')
"
); 
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
PHP Code:
if (isset($datastore_item)) 
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
PHP Code:
if ($vbulletin->datastore_item !== null
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.
Reply With Quote
  #6  
Old 06-09-2005, 07:51 PM
Revan's Avatar
Revan Revan is offline
 
Join Date: Jan 2004
Location: Norway
Posts: 1,671
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for this update, Wayne. It helped me answer my question about query_read vs query_write
[Removed question as more indepth studies of the files answered it]
Reply With Quote
  #7  
Old 06-09-2005, 08:00 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can use query_first() as this basically does the same as query_read() and fetch_array().
Reply With Quote
  #8  
Old 06-09-2005, 09:07 PM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can also use the old school query();, but it preforms a preg call to check for the query type (SELECT = read, everything else = write). Really you should not use query(); anymore, but there is nothing stoping you from doing it
Reply With Quote
  #9  
Old 06-09-2005, 09:17 PM
Revan's Avatar
Revan Revan is offline
 
Join Date: Jan 2004
Location: Norway
Posts: 1,671
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah I see, thanks
I really wish they didn't add support for the old query(), this will only lead to lazy coders writing shi'ite stuff that keeps using these old, outdated versions, forcing vB to sacrifice performance in order to determine the correct function which again leads to a performance hit. .
I guess this means I will have to be more selective and conservative with the stuff I install, as I like things running fast and smooth
Reply With Quote
  #10  
Old 06-09-2005, 09:36 PM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

god everything i have worked for has to be rewritten, damn u!!!!

also is $vbulletin->bbuserinfo[] now used in templates and where is official vbulletin.com documentation?
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 09:39 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.09773 seconds
  • Memory Usage 2,313KB
  • Queries Executed 23 (?)
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
  • (8)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)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