From 5159340bc662e4235a55c3cb3f90d1239e7189b3 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 20 Nov 2009 05:56:02 +0000 Subject: Updated version info --- lib/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/common.php b/lib/common.php index 732c22bfd..9b3ded037 100644 --- a/lib/common.php +++ b/lib/common.php @@ -22,7 +22,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } //exit with 200 response, if this is checking fancy from the installer if (isset($_REQUEST['p']) && $_REQUEST['p'] == 'check-fancy') { exit; } -define('STATUSNET_VERSION', '0.9.0dev'); +define('STATUSNET_VERSION', '0.9.0rc1'); define('LACONICA_VERSION', STATUSNET_VERSION); // compatibility define('STATUSNET_CODENAME', 'Stand'); -- cgit v1.2.3-54-g00ecf From c0d4e0990ff4dfaa8eb6b8864be7bb07ea64551d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 20 Nov 2009 03:38:24 -0500 Subject: revert adding avatar IMG to jabber output; shows entire URL in some Jabber clients --- lib/jabber.php | 1 - 1 file changed, 1 deletion(-) (limited to 'lib') diff --git a/lib/jabber.php b/lib/jabber.php index a8e295ea5..01aed8ffa 100644 --- a/lib/jabber.php +++ b/lib/jabber.php @@ -176,7 +176,6 @@ function jabber_format_entry($profile, $notice) $xs = new XMLStringer(); $xs->elementStart('html', array('xmlns' => 'http://jabber.org/protocol/xhtml-im')); $xs->elementStart('body', array('xmlns' => 'http://www.w3.org/1999/xhtml')); - $xs->element("img", array('src'=> $profile->avatarUrl(AVATAR_MINI_SIZE))); $xs->element('a', array('href' => $profile->profileurl), $profile->nickname); $xs->text(": "); -- cgit v1.2.3-54-g00ecf From 224d82793c769c06d1e4f39c19cd5f2e9cf519b0 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 20 Nov 2009 02:50:43 -0800 Subject: Revert "Added 'login' command that gives you a link that can be used to login to the website" This reverts commit b9d40f723bce8e01ddcbbb989bd7035b92cd9af8. Conflicts: actions/login.php classes/statusnet.ini db/08to09.sql db/08to09_pg.sql db/statusnet_pg.sql lib/command.php lib/commandinterpreter.php --- actions/login.php | 9 ++++++--- classes/Login_token.php | 42 ------------------------------------------ db/08to09.sql | 11 +---------- db/08to09_pg.sql | 12 +----------- db/statusnet.sql | 10 ---------- db/statusnet_pg.sql | 12 +----------- lib/command.php | 27 --------------------------- lib/commandinterpreter.php | 6 ------ lib/router.php | 2 -- 9 files changed, 9 insertions(+), 122 deletions(-) delete mode 100644 classes/Login_token.php (limited to 'lib') diff --git a/actions/login.php b/actions/login.php index cee29fd09..cd1326813 100644 --- a/actions/login.php +++ b/actions/login.php @@ -79,8 +79,6 @@ class LoginAction extends Action $this->clientError(_('Already logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->checkLogin(); - } else if (isset($args['user_id']) && isset($args['token'])){ - $this->checkLogin($args['user_id'],$args['token']); } else { common_ensure_session(); $this->showForm(); @@ -97,7 +95,7 @@ class LoginAction extends Action * @return void */ - function checkLogin($user_id=null, $token=null) + function checkLogin() { if(isset($token) && isset($user_id)){ //Token based login (from the LoginCommand) @@ -139,6 +137,11 @@ class LoginAction extends Action $user = common_check_user($nickname, $password); } + $nickname = common_canonical_nickname($this->trimmed('nickname')); + $password = $this->arg('password'); + + $user = common_check_user($nickname, $password); + if (!$user) { $this->showForm(_('Incorrect username or password.')); return; diff --git a/classes/Login_token.php b/classes/Login_token.php deleted file mode 100644 index bd6381f90..000000000 --- a/classes/Login_token.php +++ /dev/null @@ -1,42 +0,0 @@ -. - */ - -if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } - -require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; - -class Login_token extends Memcached_DataObject -{ - ###START_AUTOCODE - /* the code below is auto generated do not remove the above tag */ - - public $__table = 'login_token'; // table name - public $user_id; // int(4) primary_key not_null - public $token; // char(32) not_null - public $created; // datetime() not_null - public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP - - /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Login_token',$k,$v); } - - /* the code above is auto generated do not remove the tag below */ - ###END_AUTOCODE -} diff --git a/db/08to09.sql b/db/08to09.sql index 64640f4ce..8d463fab4 100644 --- a/db/08to09.sql +++ b/db/08to09.sql @@ -72,13 +72,4 @@ create table location_namespace ( created datetime not null comment 'date the record was created', modified timestamp comment 'date this record was modified' -) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; - -create table login_token ( - user_id integer not null comment 'user owning this token' references user (id), - token char(32) not null comment 'token useable for logging in', - created datetime not null comment 'date this record was created', - modified timestamp comment 'date this record was modified', - - constraint primary key (user_id) -) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; \ No newline at end of file diff --git a/db/08to09_pg.sql b/db/08to09_pg.sql index 7aaf3a7a0..de6a82209 100644 --- a/db/08to09_pg.sql +++ b/db/08to09_pg.sql @@ -39,15 +39,6 @@ create table profile_role ( ); -create table login_token ( - user_id integer not null /* comment 'user owning this token'*/ references "user" (id), - token char(32) not null /* comment 'token useable for logging in'*/, - created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created'*/, - modified timestamp /* comment 'date this record was modified'*/, - - primary key (user_id) -); - DROP index fave_user_id_idx; CREATE index fave_user_id_idx on fave (user_id,modified); @@ -58,5 +49,4 @@ DROP index subscription_subscribed_idx; CREATE index subscription_subscribed_idx ON subscription (subscribed,created); DROP index notice_profile_id_idx; -CREATE index notice_profile_id_idx ON notice (profile_id,created,id); - +CREATE index notice_profile_id_idx ON notice (profile_id,created,id); \ No newline at end of file diff --git a/db/statusnet.sql b/db/statusnet.sql index 18abcdfdb..f7b3b113b 100644 --- a/db/statusnet.sql +++ b/db/statusnet.sql @@ -575,13 +575,3 @@ create table location_namespace ( modified timestamp comment 'date this record was modified' ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; - -create table login_token ( - user_id integer not null comment 'user owning this token' references user (id), - token char(32) not null comment 'token useable for logging in', - created datetime not null comment 'date this record was created', - modified timestamp comment 'date this record was modified', - - constraint primary key (user_id) -) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; - diff --git a/db/statusnet_pg.sql b/db/statusnet_pg.sql index 927925753..27b189e28 100644 --- a/db/statusnet_pg.sql +++ b/db/statusnet_pg.sql @@ -568,14 +568,4 @@ create table profile_role ( primary key (profile_id, role) -); - -create table login_token ( - user_id integer not null /* comment 'user owning this token'*/ references "user" (id), - token char(32) not null /* comment 'token useable for logging in'*/, - created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created'*/, - modified timestamp /* comment 'date this record was modified'*/, - - primary key (user_id) -); - +); \ No newline at end of file diff --git a/lib/command.php b/lib/command.php index 7e98156b6..bcc551c81 100644 --- a/lib/command.php +++ b/lib/command.php @@ -579,32 +579,6 @@ class OnCommand extends Command } } -class LoginCommand extends Command -{ - function execute($channel) - { - $login_token = Login_token::staticGet('user_id',$this->user->id); - if($login_token){ - $login_token->delete(); - } - $login_token = new Login_token(); - $login_token->user_id = $this->user->id; - $login_token->token = common_good_rand(16); - $login_token->created = common_sql_now(); - $result = $login_token->insert(); - if (!$result) { - common_log_db_error($login_token, 'INSERT', __FILE__); - $channel->error($this->user, sprintf(_('Could not create login token for %s'), - $this->user->nickname)); - return; - } - $channel->output($this->user, - sprintf(_('This link is useable only once, and is good for only 2 minutes: %s'), - common_local_url('login', - array('user_id'=>$login_token->user_id, 'token'=>$login_token->token)))); - } -} - class SubscriptionsCommand extends Command { function execute($channel) @@ -692,7 +666,6 @@ class HelpCommand extends Command "reply # - reply to notice with a given id\n". "reply - reply to the last notice from user\n". "join - join group\n". - "login - Get a link to login to the web interface\n". "drop - leave group\n". "stats - get your stats\n". "stop - same as 'off'\n". diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php index 665015afc..25f2e4b3e 100644 --- a/lib/commandinterpreter.php +++ b/lib/commandinterpreter.php @@ -41,12 +41,6 @@ class CommandInterpreter return null; } return new HelpCommand($user); - case 'login': - if ($arg) { - return null; - } else { - return new LoginCommand($user); - } case 'subscribers': if ($arg) { return null; diff --git a/lib/router.php b/lib/router.php index b22185126..beb98eb04 100644 --- a/lib/router.php +++ b/lib/router.php @@ -88,8 +88,6 @@ class Router $m->connect('doc/:title', array('action' => 'doc')); - $m->connect('main/login?user_id=:user_id&token=:token', array('action'=>'login'), array('user_id'=> '[0-9]+', 'token'=>'.+')); - // main stuff is repetitive $main = array('login', 'logout', 'register', 'subscribe', -- cgit v1.2.3-54-g00ecf From 979e0a14aeaa5617e843c155ae1a1928d0f6c398 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 20 Nov 2009 16:34:01 -0800 Subject: Disable XHTML Content-Type negotiation... You've foiled our plans for the last time! XHTML mode breaks a lot of JS and has been causing trouble for Safari and Chrome, especially with the fancier new UI-side plugins like realtime and maps. --- lib/htmloutputter.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index c2ec83c28..d267526c8 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -34,9 +34,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { require_once INSTALLDIR.'/lib/xmloutputter.php'; -define('PAGE_TYPE_PREFS', - 'text/html,application/xhtml+xml,'. - 'application/xml;q=0.3,text/xml;q=0.2'); +// Can include XHTML options but these are too fragile in practice. +define('PAGE_TYPE_PREFS', 'text/html'); /** * Low-level generator for HTML -- cgit v1.2.3-54-g00ecf From 2fabf586c77ca64562f2f126cf7a734fc4459c54 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 24 Nov 2009 09:38:16 -0800 Subject: Break TableDef, ColumnDef classes to separate files so autoloader can find them. With $config['db']['schemacheck'] set to 'script' in live deployment, Schema class wasn't being preloaded for us; the uses of TableDef by plugins for DataObject configuration would then fail because the class wasn't loaded. Broken to separate files, the autoloader can find all classes in either case. PHP Fatal error: Class 'TableDef' not found in /var/www/statusnet/plugins/OpenID/User_openid.php on line 43, referer: http://identi.ca/brionv/all --- lib/columndef.php | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/schema.php | 168 ----------------------------------------------------- lib/tabledef.php | 63 ++++++++++++++++++++ 3 files changed, 232 insertions(+), 168 deletions(-) create mode 100644 lib/columndef.php create mode 100644 lib/tabledef.php (limited to 'lib') diff --git a/lib/columndef.php b/lib/columndef.php new file mode 100644 index 000000000..1bae6b33b --- /dev/null +++ b/lib/columndef.php @@ -0,0 +1,169 @@ +. + * + * @category Database + * @package StatusNet + * @author Evan Prodromou + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * A class encapsulating the structure of a column in a table. + * + * @category Database + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class ColumnDef +{ + /** name of the column. */ + public $name; + /** type of column, e.g. 'int', 'varchar' */ + public $type; + /** size of the column. */ + public $size; + /** boolean flag; can it be null? */ + public $nullable; + /** + * type of key: null = no key; 'PRI' => primary; + * 'UNI' => unique key; 'MUL' => multiple values. + */ + public $key; + /** default value if any. */ + public $default; + /** 'extra' stuff. Returned by MySQL, largely + * unused. */ + public $extra; + /** auto increment this field if no value is specific for it during an insert **/ + public $auto_increment; + + /** + * Constructor. + * + * @param string $name name of the column + * @param string $type type of the column + * @param int $size size of the column + * @param boolean $nullable can this be null? + * @param string $key type of key + * @param value $default default value + * @param value $extra unused + */ + + function __construct($name=null, $type=null, $size=null, + $nullable=true, $key=null, $default=null, + $extra=null, $auto_increment=false) + { + $this->name = strtolower($name); + $this->type = strtolower($type); + $this->size = $size+0; + $this->nullable = $nullable; + $this->key = $key; + $this->default = $default; + $this->extra = $extra; + $this->auto_increment = $auto_increment; + } + + /** + * Compares this columndef with another to see + * if they're functionally equivalent. + * + * @param ColumnDef $other column to compare + * + * @return boolean true if equivalent, otherwise false. + */ + + function equals($other) + { + return ($this->name == $other->name && + $this->_typeMatch($other) && + $this->_defaultMatch($other) && + $this->_nullMatch($other) && + $this->key == $other->key && + $this->auto_increment == $other->auto_increment); + } + + /** + * Does the type of this column match the + * type of the other column? + * + * Checks the type and size of a column. Tries + * to ignore differences between synonymous + * data types, like 'integer' and 'int'. + * + * @param ColumnDef $other other column to check + * + * @return boolean true if they're about equivalent + */ + + private function _typeMatch($other) + { + switch ($this->type) { + case 'integer': + case 'int': + return ($other->type == 'integer' || + $other->type == 'int'); + break; + default: + return ($this->type == $other->type && + $this->size == $other->size); + } + } + + /** + * Does the default behaviour of this column match + * the other? + * + * @param ColumnDef $other other column to check + * + * @return boolean true if defaults are effectively the same. + */ + + private function _defaultMatch($other) + { + return ((is_null($this->default) && is_null($other->default)) || + ($this->default == $other->default)); + } + + /** + * Does the null behaviour of this column match + * the other? + * + * @param ColumnDef $other other column to check + * + * @return boolean true if these columns 'null' the same. + */ + + private function _nullMatch($other) + { + return ((!is_null($this->default) && !is_null($other->default) && + $this->default == $other->default) || + ($this->nullable == $other->nullable)); + } +} diff --git a/lib/schema.php b/lib/schema.php index 560884d9f..11e2b6f60 100644 --- a/lib/schema.php +++ b/lib/schema.php @@ -547,171 +547,3 @@ class Schema return $sql; } } - -/** - * A class encapsulating the structure of a table. - * - * @category Database - * @package StatusNet - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - */ - -class TableDef -{ - /** name of the table */ - public $name; - /** array of ColumnDef objects for the columns. */ - public $columns; - - /** - * Constructor. - * - * @param string $name name of the table - * @param array $columns columns in the table - */ - - function __construct($name=null,$columns=null) - { - $this->name = $name; - $this->columns = $columns; - } -} - -/** - * A class encapsulating the structure of a column in a table. - * - * @category Database - * @package StatusNet - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - */ - -class ColumnDef -{ - /** name of the column. */ - public $name; - /** type of column, e.g. 'int', 'varchar' */ - public $type; - /** size of the column. */ - public $size; - /** boolean flag; can it be null? */ - public $nullable; - /** - * type of key: null = no key; 'PRI' => primary; - * 'UNI' => unique key; 'MUL' => multiple values. - */ - public $key; - /** default value if any. */ - public $default; - /** 'extra' stuff. Returned by MySQL, largely - * unused. */ - public $extra; - /** auto increment this field if no value is specific for it during an insert **/ - public $auto_increment; - - /** - * Constructor. - * - * @param string $name name of the column - * @param string $type type of the column - * @param int $size size of the column - * @param boolean $nullable can this be null? - * @param string $key type of key - * @param value $default default value - * @param value $extra unused - */ - - function __construct($name=null, $type=null, $size=null, - $nullable=true, $key=null, $default=null, - $extra=null, $auto_increment=false) - { - $this->name = strtolower($name); - $this->type = strtolower($type); - $this->size = $size+0; - $this->nullable = $nullable; - $this->key = $key; - $this->default = $default; - $this->extra = $extra; - $this->auto_increment = $auto_increment; - } - - /** - * Compares this columndef with another to see - * if they're functionally equivalent. - * - * @param ColumnDef $other column to compare - * - * @return boolean true if equivalent, otherwise false. - */ - - function equals($other) - { - return ($this->name == $other->name && - $this->_typeMatch($other) && - $this->_defaultMatch($other) && - $this->_nullMatch($other) && - $this->key == $other->key && - $this->auto_increment == $other->auto_increment); - } - - /** - * Does the type of this column match the - * type of the other column? - * - * Checks the type and size of a column. Tries - * to ignore differences between synonymous - * data types, like 'integer' and 'int'. - * - * @param ColumnDef $other other column to check - * - * @return boolean true if they're about equivalent - */ - - private function _typeMatch($other) - { - switch ($this->type) { - case 'integer': - case 'int': - return ($other->type == 'integer' || - $other->type == 'int'); - break; - default: - return ($this->type == $other->type && - $this->size == $other->size); - } - } - - /** - * Does the default behaviour of this column match - * the other? - * - * @param ColumnDef $other other column to check - * - * @return boolean true if defaults are effectively the same. - */ - - private function _defaultMatch($other) - { - return ((is_null($this->default) && is_null($other->default)) || - ($this->default == $other->default)); - } - - /** - * Does the null behaviour of this column match - * the other? - * - * @param ColumnDef $other other column to check - * - * @return boolean true if these columns 'null' the same. - */ - - private function _nullMatch($other) - { - return ((!is_null($this->default) && !is_null($other->default) && - $this->default == $other->default) || - ($this->nullable == $other->nullable)); - } -} diff --git a/lib/tabledef.php b/lib/tabledef.php new file mode 100644 index 000000000..3aace123b --- /dev/null +++ b/lib/tabledef.php @@ -0,0 +1,63 @@ +. + * + * @category Database + * @package StatusNet + * @author Evan Prodromou + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * A class encapsulating the structure of a table. + * + * @category Database + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class TableDef +{ + /** name of the table */ + public $name; + /** array of ColumnDef objects for the columns. */ + public $columns; + + /** + * Constructor. + * + * @param string $name name of the table + * @param array $columns columns in the table + */ + + function __construct($name=null,$columns=null) + { + $this->name = $name; + $this->columns = $columns; + } +} -- cgit v1.2.3-54-g00ecf From 3556861596652b82e607db62c9c28ef379657779 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 24 Nov 2009 19:11:34 +0000 Subject: Fix SSL options for Twitter bridge HTTP requests --- lib/oauthclient.php | 1 + plugins/TwitterBridge/twitterbasicauthclient.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/oauthclient.php b/lib/oauthclient.php index 1a86e2460..b22fd7897 100644 --- a/lib/oauthclient.php +++ b/lib/oauthclient.php @@ -197,6 +197,7 @@ class OAuthClient 'timeout' => 120, 'follow_redirects' => true, 'ssl_verify_peer' => false, + 'ssl_verify_host' => false )); // Twitter is strict about accepting invalid "Expect" headers diff --git a/plugins/TwitterBridge/twitterbasicauthclient.php b/plugins/TwitterBridge/twitterbasicauthclient.php index d1cf45aec..7ee8d7d4c 100644 --- a/plugins/TwitterBridge/twitterbasicauthclient.php +++ b/plugins/TwitterBridge/twitterbasicauthclient.php @@ -183,7 +183,8 @@ class TwitterBasicAuthClient 'follow_redirects' => true, 'connect_timeout' => 120, 'timeout' => 120, - 'ssl_verifypeer' => false, + 'ssl_verify_peer' => false, + 'ssl_verify_host' => false )); if ($auth) { -- cgit v1.2.3-54-g00ecf From 4b59cf0e3f4acc688a513c4cd31e8eb8c74e708c Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 24 Nov 2009 15:29:47 -0800 Subject: Fix regression in OMB sending with queues enabled -- items never got dequeued, leading to ever-growing queue and big delays. Success return code from omb_broadcast_message was dropped in commit ec88d2650ea4371cf53229171851747b31587e4b (Aug 10 2009) which switched us to libomb backend. With queues enabled, this would lead to the notice being readded to the outgoing OMB queue for redelivery as the queue system thought the send failed. The resends caused extra load and confusion for third-party sites, and more worryingly just plugged up our own queue so legit messages were badly delayed. This commit should restore the previous state, where we fire-and-forget; that is, we're not actually checking to see if all remote subscribers received the message successfully and there will be no resends. --- lib/omb.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/omb.php b/lib/omb.php index cd6d6e1b2..49496b774 100644 --- a/lib/omb.php +++ b/lib/omb.php @@ -102,7 +102,7 @@ function omb_broadcast_notice($notice) common_debug('Finished to ' . $rp->postnoticeurl, __FILE__); } - return; + return true; } function omb_broadcast_profile($profile) -- cgit v1.2.3-54-g00ecf From 6d5d63636a30654d92db5903972ccd6bf816a5cd Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 25 Nov 2009 11:20:41 -0800 Subject: Drop error message on setlocale() failure; this is harmless, since we actually have a working locale set up. --- lib/util.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index 5bf4f6091..6946f60fe 100644 --- a/lib/util.php +++ b/lib/util.php @@ -58,18 +58,17 @@ function common_init_language() // (say, ga_ES for Galego/Galician) it seems to take it. common_init_locale("en_US"); + // Note that this setlocale() call may "fail" but this is harmless; + // gettext will still select the right language. $language = common_language(); $locale_set = common_init_locale($language); + setlocale(LC_CTYPE, 'C'); // So we do not have to make people install the gettext locales $path = common_config('site','locale_path'); bindtextdomain("statusnet", $path); bind_textdomain_codeset("statusnet", "UTF-8"); textdomain("statusnet"); - - if(!$locale_set) { - common_log(LOG_INFO, 'Language requested:' . $language . ' - locale could not be set. Perhaps that system locale is not installed.', __FILE__); - } } function common_timezone() -- cgit v1.2.3-54-g00ecf From b771a8bb2124d4e48df2e3d3d3078c4de1da3483 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 25 Nov 2009 22:10:55 +0000 Subject: Fix regression in remote subscription; added hasRole() shadow method on Remote_profile. DB_DataObject hides errors by silently returning null for any non-existent method call, making it harder to tell what the heck's going on... the rights check for blocked remote users returned null for the check for subscribe rights, thus eval'ing to false. We now log a note in this circumstance, which would have cut about 3 hours off of the debug time. --- classes/Remote_profile.php | 10 ++++++++++ lib/oauthstore.php | 1 + 2 files changed, 11 insertions(+) (limited to 'lib') diff --git a/classes/Remote_profile.php b/classes/Remote_profile.php index 9f7bfeadc..0a1676a6a 100644 --- a/classes/Remote_profile.php +++ b/classes/Remote_profile.php @@ -43,4 +43,14 @@ class Remote_profile extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + + function hasRight($right) + { + $profile = Profile::staticGet($this->id); + if ($profile) { + return $profile->hasright($right); + } else { + throw new Exception("Missing profile"); + } + } } diff --git a/lib/oauthstore.php b/lib/oauthstore.php index b04bcbb8b..e34bf8a5e 100644 --- a/lib/oauthstore.php +++ b/lib/oauthstore.php @@ -463,6 +463,7 @@ class StatusNetOAuthDataStore extends OAuthDataStore $subscriber = $this->_getAnyProfile($subscriber_uri); if (!$subscriber->hasRight(Right::SUBSCRIBE)) { + common_log(LOG_INFO, __METHOD__ . ": remote subscriber banned ($subscriber_uri subbing to $subscribed_user_uri)"); return _('You have been banned from subscribing.'); } -- cgit v1.2.3-54-g00ecf From 11abd4bfb70179faad3b4b0509b68403ddfc1ed9 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 25 Nov 2009 15:21:51 -0800 Subject: Catch and report exceptions from notice_to_omb_notice() instead of letting the OMB queue handler die. --- lib/omb.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/omb.php b/lib/omb.php index 49496b774..e2a6d9f3f 100644 --- a/lib/omb.php +++ b/lib/omb.php @@ -67,7 +67,14 @@ function omb_hmac_sha1() function omb_broadcast_notice($notice) { - $omb_notice = notice_to_omb_notice($notice); + try { + $omb_notice = notice_to_omb_notice($notice); + } catch (Exception $e) { + // @fixme we should clean up or highlight the problem item + common_log(LOG_ERR, 'Invalid OMB outgoing notice for notice ' . $notice->id); + common_log(LOG_ERR, 'Error status '.$e); + return true; + } /* Get remote users subscribed to this profile. */ $rp = new Remote_profile(); -- cgit v1.2.3-54-g00ecf From 2b6cf0d8b6b276eeccb623ec7886effd75423aeb Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 25 Nov 2009 13:38:59 -0800 Subject: Revert "Allow plugin DB_DataObject classes to not have to use the .ini file by overriding keys(), table(), and sequenceKey() for them" This reverts commit a373d07ae00b878f47970f2e4a7d86c6ec3a65cf. Conflicts: classes/statusnet.ini lib/schema.php plugins/Authentication/AuthenticationPlugin.php plugins/OpenID/OpenIDPlugin.php plugins/UserFlag/UserFlagPlugin.php --- classes/Plugin_DataObject.php | 195 ------------------------ lib/schema.php | 20 --- plugins/Authentication/AuthenticationPlugin.php | 13 +- plugins/Authentication/User_username.php | 22 +-- plugins/OpenID/OpenIDPlugin.php | 20 ++- plugins/OpenID/User_openid.php | 22 +-- plugins/OpenID/User_openid_trustroot.php | 20 +-- plugins/UserFlag/UserFlagPlugin.php | 11 +- plugins/UserFlag/User_flag_profile.php | 21 +-- 9 files changed, 47 insertions(+), 297 deletions(-) delete mode 100644 classes/Plugin_DataObject.php (limited to 'lib') diff --git a/classes/Plugin_DataObject.php b/classes/Plugin_DataObject.php deleted file mode 100644 index d5cecf0f7..000000000 --- a/classes/Plugin_DataObject.php +++ /dev/null @@ -1,195 +0,0 @@ -. - */ - -if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } - -require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; - -abstract class Plugin_DataObject extends Memcached_DataObject -{ - function table() { - static $table = null; - if($table == null) { - $table = array(); - $DB = $this->getDatabaseConnection(); - $dbtype = $DB->phptype; - $tableDef = $this->tableDef(); - foreach($tableDef->columns as $columnDef){ - switch(strtoupper($columnDef->type)) { - /*shamelessly copied from DB_DataObject_Generator*/ - case 'INT': - case 'INT2': // postgres - case 'INT4': // postgres - case 'INT8': // postgres - case 'SERIAL4': // postgres - case 'SERIAL8': // postgres - case 'INTEGER': - case 'TINYINT': - case 'SMALLINT': - case 'MEDIUMINT': - case 'BIGINT': - $type = DB_DATAOBJECT_INT; - if ($columnDef->size == 1) { - $type += DB_DATAOBJECT_BOOL; - } - break; - - case 'REAL': - case 'DOUBLE': - case 'DOUBLE PRECISION': // double precision (firebird) - case 'FLOAT': - case 'FLOAT4': // real (postgres) - case 'FLOAT8': // double precision (postgres) - case 'DECIMAL': - case 'MONEY': // mssql and maybe others - case 'NUMERIC': - case 'NUMBER': // oci8 - $type = DB_DATAOBJECT_INT; // should really by FLOAT!!! / MONEY... - break; - - case 'YEAR': - $type = DB_DATAOBJECT_INT; - break; - - case 'BIT': - case 'BOOL': - case 'BOOLEAN': - - $type = DB_DATAOBJECT_BOOL; - // postgres needs to quote '0' - if ($dbtype == 'pgsql') { - $type += DB_DATAOBJECT_STR; - } - break; - - case 'STRING': - case 'CHAR': - case 'VARCHAR': - case 'VARCHAR2': - case 'TINYTEXT': - - case 'ENUM': - case 'SET': // not really but oh well - - case 'POINT': // mysql geometry stuff - not really string - but will do.. - - case 'TIMESTAMPTZ': // postgres - case 'BPCHAR': // postgres - case 'INTERVAL': // postgres (eg. '12 days') - - case 'CIDR': // postgres IP net spec - case 'INET': // postgres IP - case 'MACADDR': // postgress network Mac address. - - case 'INTEGER[]': // postgres type - case 'BOOLEAN[]': // postgres type - - $type = DB_DATAOBJECT_STR; - break; - - case 'TEXT': - case 'MEDIUMTEXT': - case 'LONGTEXT': - - $type = DB_DATAOBJECT_STR + DB_DATAOBJECT_TXT; - break; - - - case 'DATE': - $type = DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE; - break; - - case 'TIME': - $type = DB_DATAOBJECT_STR + DB_DATAOBJECT_TIME; - break; - - - case 'DATETIME': - - $type = DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME; - break; - - case 'TIMESTAMP': // do other databases use this??? - - $type = ($dbtype == 'mysql') ? - DB_DATAOBJECT_MYSQLTIMESTAMP : - DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME; - break; - - - case 'BLOB': /// these should really be ignored!!!??? - case 'TINYBLOB': - case 'MEDIUMBLOB': - case 'LONGBLOB': - - case 'CLOB': // oracle character lob support - - case 'BYTEA': // postgres blob support.. - $type = DB_DATAOBJECT_STR + DB_DATAOBJECT_BLOB; - break; - - default: - throw new Exception("Cannot handle datatype: $columnDef->type"); - } - if(! $columnDef->nullable) { - $type+=DB_DATAOBJECT_NOTNULL; - } - $table[$columnDef->name]=$type; - } - } - return $table; - } - - function keys() { - static $keys = null; - if($keys == null) { - $keys = array(); - $tableDef = $this->tableDef(); - foreach($tableDef->columns as $columnDef){ - if($columnDef->key != null){ - $keys[] = $columnDef->name; - } - } - } - return $keys; - } - - function sequenceKey() { - static $sequenceKey = null; - if($sequenceKey == null) { - $sequenceKey = array(false,false); - $tableDef = $this->tableDef(); - foreach($tableDef->columns as $columnDef){ - if($columnDef->key == 'PRI' && $columnDef->auto_increment){ - $sequenceKey=array($columnDef->name,true); - } - } - } - return $sequenceKey; - } - - /** - * Get the TableDef object that represents the table backing this class - * Ideally, this function would a static function, but PHP doesn't allow - * abstract static functions - * @return TableDef TableDef instance - */ - abstract function tableDef(); -} - diff --git a/lib/schema.php b/lib/schema.php index 11e2b6f60..df7cb65f5 100644 --- a/lib/schema.php +++ b/lib/schema.php @@ -372,26 +372,6 @@ class Schema return true; } - /** - * Ensures that the table that backs a given - * Plugin_DataObject class exists. - * - * If the table does not yet exist, it will - * create the table. If it does exist, it will - * alter the table to match the column definitions. - * - * @param Plugin_DataObject $dataObjectClass - * - * @return boolean success flag - */ - - public function ensureDataObject($dataObjectClass) - { - $obj = new $dataObjectClass(); - $tableDef = $obj->tableDef(); - return $this->ensureTable($tableDef->name,$tableDef->columns); - } - /** * Ensures that a table exists with the given * name and the given column definitions. diff --git a/plugins/Authentication/AuthenticationPlugin.php b/plugins/Authentication/AuthenticationPlugin.php index cd1de1149..a76848b04 100644 --- a/plugins/Authentication/AuthenticationPlugin.php +++ b/plugins/Authentication/AuthenticationPlugin.php @@ -2,7 +2,7 @@ /** * StatusNet, the distributed open-source microblogging tool * - * Superclass for plugins that do authentication + * Superclass for plugins that do authentication and/or authorization * * PHP version 5 * @@ -204,7 +204,16 @@ abstract class AuthenticationPlugin extends Plugin function onCheckSchema() { $schema = Schema::get(); - $schema->ensureDataObject('User_username'); + $schema->ensureTable('user_username', + array(new ColumnDef('provider_name', 'varchar', + '255', false, 'PRI'), + new ColumnDef('username', 'varchar', + '255', false, 'PRI'), + new ColumnDef('user_id', 'integer', + null, false), + new ColumnDef('created', 'datetime', + null, false), + new ColumnDef('modified', 'timestamp'))); return true; } diff --git a/plugins/Authentication/User_username.php b/plugins/Authentication/User_username.php index 6826f2681..f30f60d83 100644 --- a/plugins/Authentication/User_username.php +++ b/plugins/Authentication/User_username.php @@ -2,9 +2,9 @@ /** * Table Definition for user_username */ -require_once INSTALLDIR.'/classes/Plugin_DataObject.php'; +require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class User_username extends Plugin_DataObject +class User_username extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -43,22 +43,4 @@ class User_username extends Plugin_DataObject return false; } } - - /** - * Get the TableDef object that represents the table backing this class - * @return TableDef TableDef instance - */ - function tableDef() - { - return new TableDef($this->__table, - array(new ColumnDef('provider_name', 'varchar', - '255', false, 'PRI'), - new ColumnDef('username', 'varchar', - '255', false, 'PRI'), - new ColumnDef('user_id', 'integer', - null, false), - new ColumnDef('created', 'datetime', - null, false), - new ColumnDef('modified', 'timestamp'))); - } } diff --git a/plugins/OpenID/OpenIDPlugin.php b/plugins/OpenID/OpenIDPlugin.php index 6dd8a3f5a..9b0a4cd45 100644 --- a/plugins/OpenID/OpenIDPlugin.php +++ b/plugins/OpenID/OpenIDPlugin.php @@ -281,8 +281,24 @@ class OpenIDPlugin extends Plugin function onCheckSchema() { $schema = Schema::get(); - $schema->ensureDataObject('User_openid'); - $schema->ensureDataObject('User_openid_trustroot'); + $schema->ensureTable('user_openid', + array(new ColumnDef('canonical', 'varchar', + '255', false, 'PRI'), + new ColumnDef('display', 'varchar', + '255', false), + new ColumnDef('user_id', 'integer', + null, false, 'MUL'), + new ColumnDef('created', 'datetime', + null, false), + new ColumnDef('modified', 'timestamp'))); + $schema->ensureTable('user_openid_trustroot', + array(new ColumnDef('trustroot', 'varchar', + '255', false, 'PRI'), + new ColumnDef('user_id', 'integer', + null, false, 'PRI'), + new ColumnDef('created', 'datetime', + null, false), + new ColumnDef('modified', 'timestamp'))); return true; } diff --git a/plugins/OpenID/User_openid.php b/plugins/OpenID/User_openid.php index c3624118e..338e0f6e9 100644 --- a/plugins/OpenID/User_openid.php +++ b/plugins/OpenID/User_openid.php @@ -2,9 +2,9 @@ /** * Table Definition for user_openid */ -require_once INSTALLDIR.'/classes/Plugin_DataObject.php'; +require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class User_openid extends Plugin_DataObject +class User_openid extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -33,22 +33,4 @@ class User_openid extends Plugin_DataObject return ($cnt > 0); } - - /** - * Get the TableDef object that represents the table backing this class - * @return TableDef TableDef instance - */ - function tableDef() - { - return new TableDef($this->__table, - array(new ColumnDef('canonical', 'varchar', - '255', false, 'PRI'), - new ColumnDef('display', 'varchar', - '255', false), - new ColumnDef('user_id', 'integer', - null, false, 'MUL'), - new ColumnDef('created', 'datetime', - null, false), - new ColumnDef('modified', 'timestamp'))); - } } diff --git a/plugins/OpenID/User_openid_trustroot.php b/plugins/OpenID/User_openid_trustroot.php index b208dddfd..4654b72df 100644 --- a/plugins/OpenID/User_openid_trustroot.php +++ b/plugins/OpenID/User_openid_trustroot.php @@ -2,9 +2,9 @@ /** * Table Definition for user_openid_trustroot */ -require_once INSTALLDIR.'/classes/Plugin_DataObject.php'; +require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class User_openid_trustroot extends Plugin_DataObject +class User_openid_trustroot extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -26,20 +26,4 @@ class User_openid_trustroot extends Plugin_DataObject { return Memcached_DataObject::pkeyGet('User_openid_trustroot', $kv); } - - /** - * Get the TableDef object that represents the table backing this class - * @return TableDef TableDef instance - */ - function tableDef() - { - return new TableDef($this->__table, - array(new ColumnDef('trustroot', 'varchar', - '255', false, 'PRI'), - new ColumnDef('user_id', 'integer', - null, false, 'PRI'), - new ColumnDef('created', 'datetime', - null, false), - new ColumnDef('modified', 'timestamp'))); - } } diff --git a/plugins/UserFlag/UserFlagPlugin.php b/plugins/UserFlag/UserFlagPlugin.php index 97b999a2f..1f1f19957 100644 --- a/plugins/UserFlag/UserFlagPlugin.php +++ b/plugins/UserFlag/UserFlagPlugin.php @@ -48,7 +48,16 @@ class UserFlagPlugin extends Plugin $schema = Schema::get(); // For storing user-submitted flags on profiles - $schema->ensureDataObject('User_flag_profile'); + + $schema->ensureTable('user_flag_profile', + array(new ColumnDef('profile_id', 'integer', null, + false, 'PRI'), + new ColumnDef('user_id', 'integer', null, + false, 'PRI'), + new ColumnDef('created', 'datetime', null, + false, 'MUL'), + new ColumnDef('cleared', 'datetime', null, + true, 'MUL'))); return true; } diff --git a/plugins/UserFlag/User_flag_profile.php b/plugins/UserFlag/User_flag_profile.php index 2fb27912d..30bd4ae68 100644 --- a/plugins/UserFlag/User_flag_profile.php +++ b/plugins/UserFlag/User_flag_profile.php @@ -21,9 +21,9 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/classes/Plugin_DataObject.php'; +require_once INSTALLDIR . '/classes/Memcached_DataObject.php'; -class User_flag_profile extends Plugin_DataObject +class User_flag_profile extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -65,21 +65,4 @@ class User_flag_profile extends Plugin_DataObject return !empty($ufp); } - - /** - * Get the TableDef object that represents the table backing this class - * @return TableDef TableDef instance - */ - function tableDef() - { - return new TableDef($this->__table, - array(new ColumnDef('profile_id', 'integer', null, - false, 'PRI'), - new ColumnDef('user_id', 'integer', null, - false, 'PRI'), - new ColumnDef('created', 'datetime', null, - false, 'MUL'), - new ColumnDef('cleared', 'datetime', null, - true, 'MUL'))); - } } -- cgit v1.2.3-54-g00ecf From b933f5bb1557972d250530eea7ececd712303763 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 27 Nov 2009 12:28:15 -0800 Subject: request id on logs... pid + random id per web request + username + method + url --- lib/util.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index 6946f60fe..fa74c2f86 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1050,8 +1050,32 @@ function common_log_line($priority, $msg) return date('Y-m-d H:i:s') . ' ' . $syslog_priorities[$priority] . ': ' . $msg . "\n"; } +function common_request_id() +{ + $pid = getmypid(); + if (php_sapi_name() == 'cli') { + return $pid; + } else { + static $req_id = null; + if (!isset($req_id)) { + $req_id = substr(md5(mt_rand()), 0, 8); + } + if (isset($_SERVER['REQUEST_URI'])) { + $url = $_SERVER['REQUEST_URI']; + } + $method = $_SERVER['REQUEST_METHOD']; + if (common_logged_in()) { + $user = common_current_user()->nickname; + } else { + $user = 'anon'; + } + return "$pid.$req_id $user $method $url"; + } +} + function common_log($priority, $msg, $filename=null) { + $msg = '[' . common_request_id() . '] ' . $msg; $logfile = common_config('site', 'logfile'); if ($logfile) { $log = fopen($logfile, "a"); -- cgit v1.2.3-54-g00ecf From 914242e22452255adad69419e324f36717243f93 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 27 Nov 2009 13:29:33 -0800 Subject: Drop the username from the log id for now; seems to trigger an error loop in some circumstances --- lib/util.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index fa74c2f86..99a0a1db3 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1064,12 +1064,7 @@ function common_request_id() $url = $_SERVER['REQUEST_URI']; } $method = $_SERVER['REQUEST_METHOD']; - if (common_logged_in()) { - $user = common_current_user()->nickname; - } else { - $user = 'anon'; - } - return "$pid.$req_id $user $method $url"; + return "$pid.$req_id $method $url"; } } -- cgit v1.2.3-54-g00ecf