From: Roland Haeder Date: Sun, 15 Feb 2015 20:50:35 +0000 (+0100) Subject: Merge branch 'nightly' of gitorious.org:social/mainline into nightly X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e528a6db559554b070202ed36968a5fb6aee1178;p=quix0rs-gnu-social.git Merge branch 'nightly' of gitorious.org:social/mainline into nightly Conflicts: lib/inboxnoticestream.php plugins/Favorite/actions/apifavoritecreate.php plugins/OStatus/actions/pushhub.php plugins/WebFinger/WebFingerPlugin.php plugins/YammerImport/lib/yammerimporter.php scripts/commandline.inc.php Signed-off-by: Roland Haeder --- e528a6db559554b070202ed36968a5fb6aee1178 diff --cc extlib/DB/DataObject.php index 1232d184df,684a98c92a..684a98c92a mode 100644,100755..100644 --- a/extlib/DB/DataObject.php +++ b/extlib/DB/DataObject.php diff --cc extlib/DB/DataObject/Cast.php index 59cc0af279,a31f536cd5..a31f536cd5 mode 100644,100755..100644 --- a/extlib/DB/DataObject/Cast.php +++ b/extlib/DB/DataObject/Cast.php diff --cc extlib/DB/DataObject/Generator.php index c06d6ed610,a712e6d9eb..a712e6d9eb mode 100644,100755..100644 --- a/extlib/DB/DataObject/Generator.php +++ b/extlib/DB/DataObject/Generator.php diff --cc extlib/DB/DataObject/createTables.php index ed2e738b78,1295d252b8..1295d252b8 mode 100644,100755..100644 --- a/extlib/DB/DataObject/createTables.php +++ b/extlib/DB/DataObject/createTables.php diff --cc plugins/Favorite/actions/apifavoritecreate.php index ea94958ebc,736bd7b0a1..8a27374053 --- a/plugins/Favorite/actions/apifavoritecreate.php +++ b/plugins/Favorite/actions/apifavoritecreate.php @@@ -50,22 -50,16 +50,21 @@@ class ApiFavoriteCreateAction extends A { var $notice = null; + protected $needPost = true; + + /** + * Take arguments for running + * - * @param array $args $_REQUEST args - * + * @return boolean success flag + */ - function prepare(array $args=array()) + protected function prepare(array $args=array()) { parent::prepare($args); - $this->user = $this->auth_user; $this->notice = Notice::getKV($this->arg('id')); - if ($this->notice->repeat_of != '' ) { + if (!empty($this->notice->repeat_of)) { - common_log(LOG_DEBUG, 'Trying to Fave '.$this->notice->id.', repeat of '.$this->notice->repeat_of); - common_log(LOG_DEBUG, 'Will Fave '.$this->notice->repeat_of.' instead'); + common_debug('Trying to Fave '.$this->notice->id.', repeat of '.$this->notice->repeat_of); + common_debug('Will Fave '.$this->notice->repeat_of.' instead'); $real_notice_id = $this->notice->repeat_of; $this->notice = Notice::getKV($real_notice_id); } @@@ -73,28 -67,9 +72,16 @@@ return true; } + /** + * Handle the request + * + * Check the format and show the user info + * - * @param array $args $_REQUEST data (unused) - * + * @return void + */ - function handle(array $args=array()) + protected function handle() { - parent::handle($args); - - if ($_SERVER['REQUEST_METHOD'] != 'POST') { - $this->clientError( - // TRANS: Client error. POST is a HTTP command. It should not be translated. - _('This method requires a POST.'), - 400, - $this->format - ); - return; - } + parent::handle(); if (!in_array($this->format, array('xml', 'json'))) { $this->clientError( diff --cc plugins/OStatus/scripts/gcfeeds.php index 94ead535fb,a95cd54dbc..f1db4b358f --- a/plugins/OStatus/scripts/gcfeeds.php +++ b/plugins/OStatus/scripts/gcfeeds.php @@@ -24,10 -27,15 +27,15 @@@ $helptext = <<find(); while ($feedsub->fetch()) { diff --cc plugins/YammerImport/lib/yammerimporter.php index 6af0302f77,0992882670..abd41dd99e --- a/plugins/YammerImport/lib/yammerimporter.php +++ b/plugins/YammerImport/lib/yammerimporter.php @@@ -161,9 -159,13 +161,13 @@@ class YammerImporte // Save "likes" as favorites... foreach ($data['faves'] as $nickname) { $user = User::getKV('nickname', $nickname); - - if ($user) { + if ($user instanceof User) { - Fave::addNew($user->getProfile(), $notice); + try { + Fave::addNew($user->getProfile(), $notice); + } catch (Exception $e) { + // failed, let's move to the next + common_debug('YammerImport failed favoriting a notice: '.$e->getMessage()); + } } } diff --cc scripts/commandline.inc.php index 0a5257cdd5,0000000000..1244187b87 mode 100644,000000..100644 --- a/scripts/commandline.inc.php +++ b/scripts/commandline.inc.php @@@ -1,247 -1,0 +1,248 @@@ +. + */ + +// -*- mode: php -*- + +# Abort if called from a web server + +if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { + print "This script must be run from the command line\n"; + exit(); +} + +define('GNUSOCIAL', true); +define('STATUSNET', true); //compatibility + +// Set various flags so we don't time out on long-running processes + +ini_set("max_execution_time", "0"); +ini_set("max_input_time", "0"); +set_time_limit(0); +mb_internal_encoding('UTF-8'); +error_reporting(0); ++# DEBUG: error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED); + +// Add extlib to our path so we can get Console_Getopt + +$_extra_path = array(INSTALLDIR.'/extlib/'); + +set_include_path(implode(PATH_SEPARATOR, $_extra_path) . PATH_SEPARATOR . get_include_path()); + +require_once 'Console/Getopt.php'; + +// Note: $shortoptions and $longoptions should be pre-defined! + +$_default_shortoptions = 'qvhc:s:p:'; + +$_default_longoptions = array('quiet', 'verbose', 'help', 'conf=', 'server=', 'path='); + +if (isset($shortoptions)) { + $shortoptions .= $_default_shortoptions; +} else { + $shortoptions = $_default_shortoptions; +} + +if (isset($longoptions)) { + $longoptions = array_merge($longoptions, $_default_longoptions); +} else { + $longoptions = $_default_longoptions; +} + +$parser = new Console_Getopt(); + +$result = $parser->getopt($argv, $shortoptions, $longoptions); + +if (PEAR::isError($result)) { + print $result->getMessage()."\n"; + exit(1); +} else { + list($options, $args) = $result; +} + +function show_help() +{ + global $helptext; + + $_default_help_text = << Use as config file + -s --server= Use as server name + -p --path= Use as path name + -h --help Show this message and quit. + +END_OF_DEFAULT; + if (isset($helptext)) { + print $helptext; + } + print $_default_help_text; + exit(0); +} + +foreach ($options as $option) { + + switch ($option[0]) { + case '--server': + case 's': + $server = $option[1]; + break; + + case '--path': + case 'p': + $path = $option[1]; + break; + + case '--conf': + case 'c': + $conffile = $option[1]; + break; + + case '--help': + case 'h': + show_help(); + } +} + +require_once INSTALLDIR . '/lib/common.php'; + +set_error_handler('common_error_handler'); + +// Set up the language infrastructure so we can localize anything that +// needs to be sent out to users, such as mail notifications. +common_init_language(); + +function _make_matches($opt, $alt) +{ + $matches = array(); + + if (strlen($opt) > 1 && 0 != strncmp($opt, '--', 2)) { + $matches[] = '--'.$opt; + } else { + $matches[] = $opt; + } + + if (!empty($alt)) { + if (strlen($alt) > 1 && 0 != strncmp($alt, '--', 2)) { + $matches[] = '--'.$alt; + } else { + $matches[] = $alt; + } + } + + return $matches; +} + +function have_option($opt, $alt=null) +{ + global $options; + + $matches = _make_matches($opt, $alt); + + foreach ($options as $option) { + if (in_array($option[0], $matches)) { + return true; + } + } + + return false; +} + +function get_option_value($opt, $alt=null) +{ + global $options; + + $matches = _make_matches($opt, $alt); + + foreach ($options as $option) { + if (in_array($option[0], $matches)) { + return $option[1]; + } + } + + return null; +} + +class NoUserArgumentException extends Exception +{ +} + +function getUser() +{ + $user = null; + + if (have_option('i', 'id')) { + $id = get_option_value('i', 'id'); + $user = User::getKV('id', $id); + if (empty($user)) { + throw new Exception("Can't find user with id '$id'."); + } + } else if (have_option('n', 'nickname')) { + $nickname = get_option_value('n', 'nickname'); + $user = User::getKV('nickname', $nickname); + if (empty($user)) { + throw new Exception("Can't find user with nickname '$nickname'"); + } + } else { + throw new NoUserArgumentException("No user argument specified."); + } + + return $user; +} + +/** "Printf not quiet" */ + +function printfnq() +{ + if (have_option('q', 'quiet')) { + return null; + } + + $cargs = func_num_args(); + + if ($cargs == 0) { + return 0; + } + + $args = func_get_args(); + $format = array_shift($args); + + return vprintf($format, $args); +} + +/** "Print when verbose" */ + +function printfv() +{ + if (!have_option('v', 'verbose')) { + return null; + } + + $cargs = func_num_args(); + + if ($cargs == 0) { + return 0; + } + + $args = func_get_args(); + $format = array_shift($args); + + return vprintf($format, $args); +}