Branch: Tag:

2001-08-28

2001-08-28 15:48:01 by Per Hedbor <ph@opera.com>

Fixed a replicate variable. Got rid of the 'shared' database, since it was more or less a clone of the 'replicate' database anyway (in it's intentions). Fixed [Bug 2075 (#2075)]

Rev: server/arg_cache_plugins/replicate.pike:1.4
Rev: server/base_server/global_variables.pike:1.82
Rev: server/base_server/module.pike:1.129
Rev: server/base_server/prototypes.pike:1.36
Rev: server/base_server/roxen.pike:1.718
Rev: server/config_interface/dbs/browser.pike:1.22
Rev: server/config_interface/dbs/index.html:1.9
Rev: server/config_interface/dbs/new_db.pike:1.7
Rev: server/config_interface/sites/create_site.pike:1.8
Rev: server/config_interface/sites/create_site_with_template.pike:1.20
Rev: server/etc/modules/DBManager.pmod:1.26
Rev: server/etc/test/tests/db/RoxenTest_dbmanager.pike:1.5
Rev: server/modules/configuration/config_tags.pike:1.161
Rev: server/modules/security/auth_httpcookie.pike:1.8
Rev: server/modules/tags/accessed.pike:1.45

4:   #include <stat.h>   #include <config.h>   #include <module_constants.h> - constant cvs_version="$Id: prototypes.pike,v 1.35 2001/08/24 19:02:43 nilsson Exp $"; + constant cvs_version="$Id: prototypes.pike,v 1.36 2001/08/28 15:47:59 per Exp $";      class Variable   {
809:    //! database.   }    - static mapping(string:int) user_sql_inited = ([]); + static mapping(string:function(void:void)) user_sql_inited = ([]);   static Sql.Sql user_mysql;   static void init_user_sql(string table)   { -  +  string db = all_constants()->REPLICATE?"replicate":"local";    if( !user_mysql ) -  user_mysql = master()->resolv("DBManager.get")( "shared" ); +  user_mysql = master()->resolv("DBManager.get")( db );    if(catch(user_mysql->query( "SELECT module FROM "+    table+" WHERE module=''")))    {
825:    " value blob, "    " raw int not null, "    " INDEX foo (module,name,user))" ); -  master()->resolv("DBManager.is_module_table")( 0, "shared", table, +  master()->resolv("DBManager.is_module_table")( 0, db, table,    "Contains metadata about users. "    "Userdatabases can store information here "    "at the request of other modules, or they "    "can keep their own state in this table" );    } -  user_sql_inited[ table ] = 1; +  user_sql_inited[ table ]= +  lambda(){user_mysql = master()->resolv("DBManager.get")( db );};   }      //! @appears Group
858:    //! A numerical GID, or -1 if not applicable   }    + #ifdef THREADS + static Thread.Mutex mutex; + #endif +    //! @appears User   class User( UserDB database )   {
929:      #define INIT_SQL() do{ \    if(!table) table = replace(database->my_configuration()->name," ","_")+"_user_variables"; \ -  if(!user_sql_inited[ table ] )init_user_sql( table ); \ +  if(!user_sql_inited[ table ] )init_user_sql( table );else user_sql_inited[ table ](); \    } while( 0 )       -  + #ifdef THREADS + #define LOCK() mixed ___key = mutex->lock() + #else + #define LOCK() + #endif       static string module_name( RoxenModule module )    {
959:    {    delete_var( module, index );    mixed oval = value; +  LOCK();    INIT_SQL();    int encoded;   
969:    value = encode_value( value );    encoded = 1;    } +     user_mysql->query(    "INSERT INTO "+table+" (module,name,user,value,raw) "    "VALUES ("+module_name( module )+", %s, %s, %s, %d)",
981:    //! Return the value of a variable previously set with @[set_var]    {    array rows; +  LOCK();    INIT_SQL(); -  +     rows = user_mysql->query( "SELECT * FROM "+table+ -  " WHERE (module="+module_name( module ) -  +" AND name=%s AND user=%s)", +  " WHERE module="+module_name( module ) +  +" AND name=%s AND user=%s",    index, name() );    if( !sizeof( rows ) )    return 0;
999:    void delete_var( RoxenModule module, string index )    //! Delete a variable previously created with @[set_var]    { +  LOCK();    INIT_SQL();    user_mysql->query( "DELETE FROM "+table+" WHERE (module="+    module_name( module )+    " AND name=%s AND user=%s)", index, name() );    }   #undef INIT_SQL -  + #undef LOCK   }      class UserDB