<commit_before><?php
/**
 * Table Definition for status_network
 *
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2009, StatusNet, Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }

class Status_network extends Safe_DataObject
{
    ###START_AUTOCODE
    /* the code below is auto generated do not remove the above tag */

    public $__table = 'status_network';                  // table name
    public $site_id;                         // int(4) primary_key not_null
    public $nickname;                        // varchar(64)   unique_key not_null
    public $hostname;                        // varchar(255)  unique_key
    public $pathname;                        // varchar(255)  unique_key
    public $dbhost;                          // varchar(255)
    public $dbuser;                          // varchar(255)
    public $dbpass;                          // varchar(255)
    public $dbname;                          // varchar(255)
    public $sitename;                        // varchar(255)
    public $theme;                           // varchar(255)
    public $logo;                            // varchar(255)
    public $created;                         // datetime()   not_null
    public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP

    /* Static get */
    function staticGet($k,$v=NULL) {
        $i = DB_DataObject::staticGet('Status_network',$k,$v);

        // Don't use local process cache; if we're fetching multiple
        // times it's because we're reloading it in a long-running
        // process; we need a fresh copy!
        global $_DB_DATAOBJECT;
        unset($_DB_DATAOBJECT['CACHE']['status_network']);
        return $i;
    }

    /* the code above is auto generated do not remove the tag below */
    ###END_AUTOCODE

    static $cache = null;
    static $cacheInitialized = false;
    static $base = null;
    static $wildcard = null;

    /**
     * @param string $dbhost
     * @param string $dbuser
     * @param string $dbpass
     * @param string $dbname
     * @param array $servers memcached servers to use for caching config info
     */
    static function setupDB($dbhost, $dbuser, $dbpass, $dbname, $servers)
    {
        global $config;

        $config['db']['database_'.$dbname] = "mysqli://$dbuser:$dbpass@$dbhost/$dbname";
        $config['db']['ini_'.$dbname] = INSTALLDIR.'/classes/status_network.ini';
        $config['db']['table_status_network'] = $dbname;

        if (class_exists('Memcache')) {
            self::$cache = new Memcache();

            // If we're a parent command-line process we need
            // to be able to close out the connection after
            // forking, so disable persistence.
            //
            // We'll turn it back on again the second time
            // through which will either be in a child process,
            // or a single-process script which is switching
            // configurations.
            $persist = php_sapi_name() != 'cli' || self::$cacheInitialized;
            if (is_array($servers)) {
                foreach($servers as $server) {
                    self::$cache->addServer($server, 11211, $persist);
                }
            } else {
                self::$cache->addServer($servers, 11211, $persist);
            }
            self::$cacheInitialized = true;
        }

        self::$base = $dbname;
    }

    static function cacheKey($k, $v) {
        return 'statusnet:' . self::$base . ':status_network:'.$k.':'.$v;
    }

    static function memGet($k, $v)
    {
        if (!self::$cache) {
            return self::staticGet($k, $v);
        }

        $ck = self::cacheKey($k, $v);

        $sn = self::$cache->get($ck);

        if (empty($sn)) {
            $sn = self::staticGet($k, $v);
            if (!empty($sn)) {
                self::$cache->set($ck, clone($sn));
            }
        }

        return $sn;
    }

    function decache()
    {
        if (self::$cache) {
            $keys = array('nickname', 'hostname', 'pathname');
            foreach ($keys as $k) {
                $ck = self::cacheKey($k, $this->$k);
                self::$cache->delete($ck);
            }
        }
    }

    function update($orig=null)
    {
        if (is_object($orig)) {
            $orig->decache(); # might be different keys
        }
        return parent::update($orig);
    }

    /**
     * DB_DataObject doesn't allow updating keys (even non-primary)
     */
    function updateKeys(&$orig)
    {
        $this->_connect();
        foreach (array('hostname', 'pathname') as $k) {
            if (strcmp($this->$k, $orig->$k) != 0) {
                $parts[] = $k . ' = ' . $this->_quote($this->$k);
            }
        }
        if (count($parts) == 0) {
            // No changes
            return true;
        }

        $toupdate = implode(', ', $parts);

        $table = common_database_tablename($this->tableName());
        $qry = 'UPDATE ' . $table . ' SET ' . $toupdate .
            ' WHERE nickname = ' . $this->_quote($this->nickname);
        $orig->decache();
        $result = $this->query($qry);
        if ($result) {
            $this->encache();
        }<commit_msg>Status_network::encache() doesn't exist<commit_after><?php
/**
 * Table Definition for status_network
 *
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2009, StatusNet, Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }

class Status_network extends Safe_DataObject
{
    ###START_AUTOCODE
    /* the code below is auto generated do not remove the above tag */

    public $__table = 'status_network';                  // table name
    public $site_id;                         // int(4) primary_key not_null
    public $nickname;                        // varchar(64)   unique_key not_null
    public $hostname;                        // varchar(255)  unique_key
    public $pathname;                        // varchar(255)  unique_key
    public $dbhost;                          // varchar(255)
    public $dbuser;                          // varchar(255)
    public $dbpass;                          // varchar(255)
    public $dbname;                          // varchar(255)
    public $sitename;                        // varchar(255)
    public $theme;                           // varchar(255)
    public $logo;                            // varchar(255)
    public $created;                         // datetime()   not_null
    public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP

    /* Static get */
    function staticGet($k,$v=NULL) {
        $i = DB_DataObject::staticGet('Status_network',$k,$v);

        // Don't use local process cache; if we're fetching multiple
        // times it's because we're reloading it in a long-running
        // process; we need a fresh copy!
        global $_DB_DATAOBJECT;
        unset($_DB_DATAOBJECT['CACHE']['status_network']);
        return $i;
    }

    /* the code above is auto generated do not remove the tag below */
    ###END_AUTOCODE

    static $cache = null;
    static $cacheInitialized = false;
    static $base = null;
    static $wildcard = null;

    /**
     * @param string $dbhost
     * @param string $dbuser
     * @param string $dbpass
     * @param string $dbname
     * @param array $servers memcached servers to use for caching config info
     */
    static function setupDB($dbhost, $dbuser, $dbpass, $dbname, $servers)
    {
        global $config;

        $config['db']['database_'.$dbname] = "mysqli://$dbuser:$dbpass@$dbhost/$dbname";
        $config['db']['ini_'.$dbname] = INSTALLDIR.'/classes/status_network.ini';
        $config['db']['table_status_network'] = $dbname;

        if (class_exists('Memcache')) {
            self::$cache = new Memcache();

            // If we're a parent command-line process we need
            // to be able to close out the connection after
            // forking, so disable persistence.
            //
            // We'll turn it back on again the second time
            // through which will either be in a child process,
            // or a single-process script which is switching
            // configurations.
            $persist = php_sapi_name() != 'cli' || self::$cacheInitialized;
            if (is_array($servers)) {
                foreach($servers as $server) {
                    self::$cache->addServer($server, 11211, $persist);
                }
            } else {
                self::$cache->addServer($servers, 11211, $persist);
            }
            self::$cacheInitialized = true;
        }

        self::$base = $dbname;
    }

    static function cacheKey($k, $v) {
        return 'statusnet:' . self::$base . ':status_network:'.$k.':'.$v;
    }

    static function memGet($k, $v)
    {
        if (!self::$cache) {
            return self::staticGet($k, $v);
        }

        $ck = self::cacheKey($k, $v);

        $sn = self::$cache->get($ck);

        if (empty($sn)) {
            $sn = self::staticGet($k, $v);
            if (!empty($sn)) {
                self::$cache->set($ck, clone($sn));
            }
        }

        return $sn;
    }

    function decache()
    {
        if (self::$cache) {
            $keys = array('nickname', 'hostname', 'pathname');
            foreach ($keys as $k) {
                $ck = self::cacheKey($k, $this->$k);
                self::$cache->delete($ck);
            }
        }
    }

    function update($orig=null)
    {
        if (is_object($orig)) {
            $orig->decache(); # might be different keys
        }
        return parent::update($orig);
    }

    /**
     * DB_DataObject doesn't allow updating keys (even non-primary)
     */
    function updateKeys(&$orig)
    {
        $this->_connect();
        foreach (array('hostname', 'pathname') as $k) {
            if (strcmp($this->$k, $orig->$k) != 0) {
                $parts[] = $k . ' = ' . $this->_quote($this->$k);
            }
        }
        if (count($parts) == 0) {
            // No changes
            return true;
        }

        $toupdate = implode(', ', $parts);

        $table = common_database_tablename($this->tableName());
        $qry = 'UPDATE ' . $table . ' SET ' . $toupdate .
            ' WHERE nickname = ' . $this->_quote($this->nickname);
        $orig->decache();
        $result = $this->query($qry);
        $this->decache();
        
{'fraction_non_alphanumeric': 0.13162335470806616, 'fraction_numerical': 0.00809989875126561, 'mean_word_length': 1.7994803967879074, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4907446', 'n_tokens_mistral': 3407, 'n_tokens_neox': 3274, 'n_words': 940}