*/
function handle(array $args=array())
{
- //common_log(LOG_DEBUG, 'Autocomplete data: ' . json_encode($this->tags));
+ //common_debug('Autocomplete data: ' . json_encode($this->tags));
if ($this->tags) {
print(json_encode($this->tags));
exit(0);
public static function deleteFromProfile(Profile $target, $original=true) {
try {
$avatars = self::getProfileAvatars($target);
+
foreach ($avatars as $avatar) {
+ assert($avatar instanceof Avatar);
+
if ($avatar->original && !$original) {
continue;
}
+
$avatar->delete();
}
} catch (NoAvatarException $e) {
}
$size = "{$width}x{$height}";
+
if (!isset(self::$_avatars[$target->id])) {
self::$_avatars[$target->id] = array();
} elseif (isset(self::$_avatars[$target->id][$size])){
}
$avatar = null;
+
if (Event::handle('StartProfileGetAvatar', array($target, $width, &$avatar))) {
$avatar = self::pkeyGet(
array(
'height' => $height,
)
);
+
Event::handle('EndProfileGetAvatar', array($target, $width, &$avatar));
}
}
if ($path[0] != '/') {
- $path = '/'.$path;
+ $path = '/' . $path;
}
$server = common_config('avatar', 'server');
static $sizenames = array(AVATAR_PROFILE_SIZE => 'profile',
AVATAR_STREAM_SIZE => 'stream',
AVATAR_MINI_SIZE => 'mini');
- return Theme::path('default-avatar-'.$sizenames[$size].'.png');
+ return Theme::path('default-avatar-' . $sizenames[$size] . '.png');
}
static function newSize(Profile $target, $width) {
} else {
$msg = sprintf("DB query (%0.3fs): %s", $delta, $clean);
}
- common_log(LOG_DEBUG, $msg);
+ common_debug($msg);
}
if ($fail) {
$scripts[] = $script;
}
foreach ($scripts as $script) {
- common_log(LOG_DEBUG, $script->textContent);
+ common_debug($script->textContent);
$script->parentNode->removeChild($script);
}
if ($timeout > 0 && empty($sockets)) {
// If we had no listeners, sleep until the pollers' next requested wakeup.
- common_log(LOG_DEBUG, "Sleeping $timeout seconds until next poll cycle...");
+ common_debug("Sleeping $timeout seconds until next poll cycle...");
$this->logState('sleep');
sleep($timeout);
}
}
} else if (common_config('queue', 'debug_memory')) {
$fmt = number_format($usage);
- common_log(LOG_DEBUG, "Memory usage $fmt");
+ common_debug("Memory usage $fmt");
}
}
}
foreach ($this->tables as $table => $def) {
$checksum = $this->checksum($def);
if (empty($checksums[$table])) {
- common_log(LOG_DEBUG, "No previous schema_version for $table: updating to $checksum");
+ common_debug("No previous schema_version for $table: updating to $checksum");
} else if ($checksums[$table] == $checksum) {
- common_log(LOG_DEBUG, "Last schema_version for $table up to date: $checksum");
+ common_debug("Last schema_version for $table up to date: $checksum");
continue;
} else {
- common_log(LOG_DEBUG, "Last schema_version for $table is {$checksums[$table]}: updating to $checksum");
+ common_debug("Last schema_version for $table is {$checksums[$table]}: updating to $checksum");
}
//$this->conn->query('BEGIN');
$this->schema->ensureTable($table, $def);
return $checksums;
} catch (Exception $e) {
// no dice!
- common_log(LOG_DEBUG, "Possibly schema_version table doesn't exist yet.");
+ common_debug("Possibly schema_version table doesn't exist yet.");
}
PEAR::popErrorHandling();
}
} catch (Exception $e) {
// no dice!
- common_log(LOG_DEBUG, "Possibly schema_version table doesn't exist yet.");
+ common_debug("Possibly schema_version table doesn't exist yet.");
}
PEAR::popErrorHandling();
$this->checksums[$table] = $checksum;
$_perfCounters[$key] = array($val);
}
if (common_config('site', 'logperf_detail')) {
- common_log(LOG_DEBUG, "PERF COUNTER HIT: $key $val");
+ common_debug("PERF COUNTER HIT: $key $val");
}
}
}
if (isset($_startTime)) {
$endTime = microtime(true);
$diff = round(($endTime - $_startTime) * 1000);
- common_log(LOG_DEBUG, "PERF runtime: ${diff}ms");
+ common_debug("PERF runtime: ${diff}ms");
}
$counters = $_perfCounters;
ksort($counters);
foreach ($counters as $key => $values) {
$count = count($values);
$unique = count(array_unique($values));
- common_log(LOG_DEBUG, "PERF COUNTER: $key $count ($unique unique)");
+ common_debug("PERF COUNTER: $key $count ($unique unique)");
}
}
}
*/
public function handleInput($socket)
{
- common_log(LOG_DEBUG, "Servicing the AIM queue.");
+ common_debug("Servicing the AIM queue.");
$this->stats('aim_process');
$this->conn->receive();
}
{
switch ($notice->object_type) {
case Happening::OBJECT_TYPE:
- common_log(LOG_DEBUG, "Deleting event from notice...");
+ common_debug("Deleting event from notice...");
$happening = Happening::fromNotice($notice);
$happening->delete();
break;
case RSVP::POSITIVE:
case RSVP::NEGATIVE:
case RSVP::POSSIBLE:
- common_log(LOG_DEBUG, "Deleting rsvp from notice...");
+ common_debug("Deleting rsvp from notice...");
$rsvp = RSVP::fromNotice($notice);
- common_log(LOG_DEBUG, "to delete: $rsvp->id");
+ common_debug("to delete: $rsvp->id");
$rsvp->delete();
break;
default:
- common_log(LOG_DEBUG, "Not deleting related, wtf...");
+ common_debug("Not deleting related, wtf...");
}
}
$notice = $this->rsvp->getNotice();
// NB: this will delete the rsvp, too
if (!empty($notice)) {
- common_log(LOG_DEBUG, "Deleting notice...");
+ common_debug("Deleting notice...");
$notice->delete();
} else {
- common_log(LOG_DEBUG, "Deleting RSVP alone...");
+ common_debug("Deleting RSVP alone...");
$this->rsvp->delete();
}
} catch (ClientException $ce) {
$this->user = $this->auth_user;
$this->notice = Notice::getKV($this->arg('id'));
if ($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);
}
$this->user = $this->auth_user;
$this->notice = Notice::getKV($this->arg('id'));
if ($this->notice->repeat_of != '' ) {
- common_log(LOG_DEBUG, 'Trying to unFave '.$this->notice->id);
- common_log(LOG_DEBUG, 'Will unFave '.$this->notice->repeat_of.' instead');
+ common_debug('Trying to unFave '.$this->notice->id);
+ common_debug('Will unFave '.$this->notice->repeat_of.' instead');
$real_notice_id = $this->notice->repeat_of;
$this->notice = Notice::getKV($real_notice_id);
}
class GravatarPlugin extends Plugin
{
- function onEndProfileGetAvatar($profile, $size, &$avatar)
+ function onEndProfileGetAvatar(Profile $profile, $size, &$avatar)
{
if (empty($avatar)) {
try {
function gravatar_url($email, $size)
{
- $url = "https://secure.gravatar.com/avatar.php?gravatar_id=".
- md5(strtolower($email)).
- "&default=".urlencode(Avatar::defaultImage($size)).
- "&size=".$size;
+ $url = 'https://secure.gravatar.com/avatar.php?gravatar_id=' .
+ md5(strtolower($email)) .
+ '&default=' . urlencode(Avatar::defaultImage($size)) .
+ '&size=' . $size;
return $url;
}
* @return void
*/
public function handleInput($socket) {
- common_log(LOG_DEBUG, 'Servicing the IRC queue.');
+ common_debug('Servicing the IRC queue.');
$this->stats('irc_process');
try {
if ($oprofile instanceof Ostatus_profile) {
$oprofile->processFeed($feed, 'push');
} else {
- common_log(LOG_DEBUG, "No ostatus profile for incoming feed $feedsub->uri");
+ common_debug("No ostatus profile for incoming feed $feedsub->uri");
}
}
$oprofile->query(sprintf($sql, $profile->id, $profile->id));
if ($oprofile->N == 0) {
- common_log(LOG_DEBUG, "No OStatus remote subscribees for $profile->nickname");
+ common_debug("No OStatus remote subscribees for $profile->nickname");
return true;
}
return true;
}
}
- common_log(LOG_DEBUG, "Not a user, group or people tag feed? $feed $userFeed $groupFeed $listFeed");
+ common_debug("Not a user, group or people tag feed? $feed $userFeed $groupFeed $listFeed");
}
- common_log(LOG_DEBUG, "LOST $feed");
+ common_debug("LOST $feed");
return false;
}
*/
static public function filterAttention(Profile $sender, array $attention)
{
- common_log(LOG_DEBUG, "Original reply recipients: " . implode(', ', array_keys($attention)));
+ common_debug("Original reply recipients: " . implode(', ', array_keys($attention)));
$groups = array();
$replies = array();
foreach ($attention as $recipient=>$type) {
if ($sender->isMember($group)) {
$groups[] = $group->id;
} else {
- common_log(LOG_DEBUG, sprintf('Skipping reply to local group %s as sender %d is not a member', $group->getNickname(), $sender->id));
+ common_debug(sprintf('Skipping reply to local group %s as sender %d is not a member', $group->getNickname(), $sender->id));
}
continue;
} else {
- common_log(LOG_DEBUG, "Skipping reply to bogus group $recipient");
+ common_debug("Skipping reply to bogus group $recipient");
}
}
continue;
} catch (Exception $e) {
// Neither a recognizable local nor remote user!
- common_log(LOG_DEBUG, "Skipping reply to unrecognized profile $recipient: " . $e->getMessage());
+ common_debug("Skipping reply to unrecognized profile $recipient: " . $e->getMessage());
}
}
- common_log(LOG_DEBUG, "Local reply recipients: " . implode(', ', $replies));
- common_log(LOG_DEBUG, "Local group recipients: " . implode(', ', $groups));
+ common_debug("Local reply recipients: " . implode(', ', $replies));
+ common_debug("Local group recipients: " . implode(', ', $groups));
return array($groups, $replies);
}
$discover = false;
if (!$homeuri) {
- common_log(LOG_DEBUG, __METHOD__ . " empty actor profile URI: " . var_export($activity, true));
+ common_debug(__METHOD__ . " empty actor profile URI: " . var_export($activity, true));
// TRANS: Exception.
throw new Exception(_m('No profile URI.'));
}
// @todo tags from categories
if ($profile->id) {
- common_log(LOG_DEBUG, "Updating OStatus profile $profile->id from remote info $object->id: " . var_export($object, true) . var_export($hints, true));
+ common_debug("Updating OStatus profile $profile->id from remote info $object->id: " . var_export($object, true) . var_export($hints, true));
$profile->update($orig);
}
}
$group->homepage = self::getActivityObjectHomepage($object, $hints);
if ($group->id) { // If no id, we haven't called insert() yet, so don't run update()
- common_log(LOG_DEBUG, "Updating OStatus group $group->id from remote info $object->id: " . var_export($object, true) . var_export($hints, true));
+ common_debug("Updating OStatus group $group->id from remote info $object->id: " . var_export($object, true) . var_export($hints, true));
$group->update($orig);
}
}
$tag->tagger = $tagger->profile_id;
if ($tag->id) {
- common_log(LOG_DEBUG, "Updating OStatus peopletag $tag->id from remote info $object->id: " . var_export($object, true) . var_export($hints, true));
+ common_debug("Updating OStatus peopletag $tag->id from remote info $object->id: " . var_export($object, true) . var_export($hints, true));
$tag->update($orig);
}
}
public function verify(Profile $profile)
{
if ($this->alg != 'RSA-SHA256') {
- common_log(LOG_DEBUG, "Salmon error: bad algorithm");
+ common_debug("Salmon error: bad algorithm");
return false;
}
if ($this->encoding != self::ENCODING) {
- common_log(LOG_DEBUG, "Salmon error: bad encoding");
+ common_debug("Salmon error: bad encoding");
return false;
}
try {
$magicsig = $this->getKeyPair($profile, true); // Do discovery too if necessary
} catch (Exception $e) {
- common_log(LOG_DEBUG, "Salmon error: ".$e->getMessage());
+ common_debug("Salmon error: ".$e->getMessage());
return false;
}
// Cryptographic verification test
if (!$magic_env->verify($profile)) {
- common_log(LOG_DEBUG, "Salmon signature verification failed.");
+ common_debug("Salmon signature verification failed.");
// TRANS: Client error.
$this->clientError(_m('Salmon signature verification failed.'));
}
{
parent::handle();
- common_log(LOG_DEBUG, "Got a " . $this->activity->verb);
+ common_debug("Got a " . $this->activity->verb);
try {
if (Event::handle('StartHandleSalmonTarget', array($this->activity, $this->target)) &&
Event::handle('StartHandleSalmon', array($this->activity))) {
$match = in_array($requiredTeam, $teams);
$is = $match ? 'is' : 'is not';
- common_log(LOG_DEBUG, "Remote user $is in required team $requiredTeam: [" . implode(', ', $teams) . "]");
+ common_debug("Remote user $is in required team $requiredTeam: [" . implode(', ', $teams) . "]");
return $match;
}
function saveNoticeFromActivity(Activity $activity, Profile $profile, array $options=array())
{
// @fixme
- common_log(LOG_DEBUG, "XXX activity: " . var_export($activity, true));
- common_log(LOG_DEBUG, "XXX profile: " . var_export($profile, true));
- common_log(LOG_DEBUG, "XXX options: " . var_export($options, true));
+ common_debug("XXX activity: " . var_export($activity, true));
+ common_debug("XXX profile: " . var_export($profile, true));
+ common_debug("XXX options: " . var_export($options, true));
// Ok for now, we can grab stuff from the XML entry directly.
// This won't work when reading from JSON source
}
try {
$notice = Poll::saveNew($profile, $question, $opts, $options);
- common_log(LOG_DEBUG, "Saved Poll from ActivityStream data ok: notice id " . $notice->id);
+ common_debug("Saved Poll from ActivityStream data ok: notice id " . $notice->id);
return $notice;
} catch (Exception $e) {
- common_log(LOG_DEBUG, "Poll save from ActivityStream data failed: " . $e->getMessage());
+ common_debug("Poll save from ActivityStream data failed: " . $e->getMessage());
}
} else if ($responseElements->length) {
$data = $responseElements->item(0);
}
try {
$notice = Poll_response::saveNew($profile, $poll, $selection, $options);
- common_log(LOG_DEBUG, "Saved Poll_response ok, notice id: " . $notice->id);
+ common_debug("Saved Poll_response ok, notice id: " . $notice->id);
return $notice;
} catch (Exception $e) {
- common_log(LOG_DEBUG, "Poll response save fail: " . $e->getMessage());
+ common_debug("Poll response save fail: " . $e->getMessage());
}
} else {
- common_log(LOG_DEBUG, "YYY no poll data");
+ common_debug("YYY no poll data");
}
}
}
*/
public function activityObjectOutputJson(ActivityObject $obj, array &$out)
{
- common_log(LOG_DEBUG, 'QQQ: ' . var_export($obj, true));
+ common_debug('QQQ: ' . var_export($obj, true));
if (isset($obj->pollQuestion)) {
/**
* "poll": {
array('id' => $p->id));
}
- common_log(LOG_DEBUG, "Saving poll: $p->id $p->uri");
+ common_debug("Saving poll: $p->id $p->uri");
$p->insert();
// TRANS: Notice content creating a poll.
array('id' => $pr->id));
}
- common_log(LOG_DEBUG, "Saving poll response: $pr->id $pr->uri");
+ common_debug("Saving poll response: $pr->id $pr->uri");
$pr->insert();
// TRANS: Notice content voting for a poll.
$file = $this->dir . DIRECTORY_SEPARATOR . $this->logFileName();
file_put_contents($file, $output);
} else {
- common_log(LOG_DEBUG, "PostDebug: $output");
+ common_debug("PostDebug: $output");
}
}
{
switch ($notice->object_type) {
case QnA_Question::OBJECT_TYPE:
- common_log(LOG_DEBUG, "Deleting question from notice...");
+ common_debug("Deleting question from notice...");
$question = QnA_Question::fromNotice($notice);
$question->delete();
break;
case QnA_Answer::OBJECT_TYPE:
- common_log(LOG_DEBUG, "Deleting answer from notice...");
+ common_debug("Deleting answer from notice...");
$answer = QnA_Answer::fromNotice($notice);
- common_log(LOG_DEBUG, "to delete: $answer->id");
+ common_debug("to delete: $answer->id");
$answer->delete();
break;
default:
- common_log(LOG_DEBUG, "Not deleting related, wtf...");
+ common_debug("Not deleting related, wtf...");
}
}
array('id' => $answer->id)
);
- common_log(LOG_DEBUG, "Saving answer: $answer->id, $answer->uri");
+ common_debug("Saving answer: $answer->id, $answer->uri");
$answer->insert();
$content = sprintf(
);
}
- common_log(LOG_DEBUG, "Saving question: $q->id $q->uri");
+ common_debug("Saving question: $q->id $q->uri");
$q->insert();
if (Notice::contentTooLong($q->title . ' ' . $q->uri)) {
$v->vote = $vote;
$v->created = common_sql_now();
- common_log(LOG_DEBUG, "Saving vote: $v->id $v->vote");
+ common_debug("Saving vote: $v->id $v->vote");
$v->insert();
}
(strpos($extra, 'Using temporary') !== false);
if ($evil) {
$xquery = $xobj->sanitizeQuery($query);
- common_log(LOG_DEBUG, "$extra | $xquery");
+ common_debug("$extra | $xquery");
}
}
}
return;
}
- common_log(LOG_DEBUG, $this->name() . ' - Trying to get ' . $timelineUri .
+ common_debug($this->name() . ' - Trying to get ' . $timelineUri .
' timeline for Twitter user ' . $flink->foreign_id);
$client = null;
if (TwitterOAuthClient::isPackedToken($flink->credentials)) {
$token = TwitterOAuthClient::unpackToken($flink->credentials);
$client = new TwitterOAuthClient($token->key, $token->secret);
- common_log(LOG_DEBUG, $this->name() . ' - Grabbing ' . $timelineUri . ' timeline with OAuth.');
+ common_debug($this->name() . ' - Grabbing ' . $timelineUri . ' timeline with OAuth.');
} else {
common_log(LOG_ERR, "Skipping " . $timelineUri . " timeline for " .
$flink->foreign_id . " since not OAuth.");
$lastId = Twitter_synch_status::getLastId($flink->foreign_id, $timelineUri);
- common_log(LOG_DEBUG, "Got lastId value '" . $lastId . "' for foreign id '" .
+ common_debug("Got lastId value '" . $lastId . "' for foreign id '" .
$flink->foreign_id . "' and timeline '" . $timelineUri. "'");
try {
*/
public function connect($url)
{
- common_log(LOG_DEBUG, "$this->id opening connection to $url");
+ common_debug("$this->id opening connection to $url");
$scheme = parse_url($url, PHP_URL_SCHEME);
if ($scheme == 'http') {
public function close()
{
if ($this->isConnected()) {
- common_log(LOG_DEBUG, "$this->id closing connection.");
+ common_debug("$this->id closing connection.");
fclose($this->socket);
$this->socket = null;
}
// TRANS: %1$s is the response code, %2$s is the line.
throw new Exception(sprintf(_m('Bad HTTP response code %1$s: %2$s.'),$status,$line));
}
- common_log(LOG_DEBUG, "$this->id $line");
+ common_debug("$this->id $line");
$this->state = 'headers';
}
{
if ($line == '') {
$this->state = 'active';
- common_log(LOG_DEBUG, "$this->id connection is active!");
+ common_debug("$this->id connection is active!");
} else {
- common_log(LOG_DEBUG, "$this->id read HTTP header: $line");
+ common_debug("$this->id read HTTP header: $line");
$this->responseHeaders[] = $line;
}
}
if ($notice instanceof Notice) {
$flink = Foreign_link::getByForeignID($receiver, TWITTER_SERVICE);
if ($flink instanceof Foreign_link) {
- common_log(LOG_DEBUG, "TweetInQueueHandler - Got flink so add notice ".
+ common_debug("TweetInQueueHandler - Got flink so add notice ".
$notice->id." to attentions for user ".$flink->user_id);
try {
Attention::saveNew($notice, $flink->getProfile());
$e->getMessage());
}
} else {
- common_log(LOG_DEBUG, "TweetInQueueHandler - No flink found for foreign user ".$receiver);
+ common_debug("TweetInQueueHandler - No flink found for foreign user ".$receiver);
}
}
$absolute = $base->resolve($src);
$avatarUrl = strval($absolute);
- common_log(LOG_DEBUG, "WikiHow avatar found for $profileUrl - $avatarUrl");
+ common_debug("WikiHow avatar found for $profileUrl - $avatarUrl");
$data['avatar'] = $avatarUrl;
}
{
// Process the queue for as long as needed
try {
- common_log(LOG_DEBUG, "Servicing the XMPP queue.");
+ common_debug("Servicing the XMPP queue.");
$this->stats('xmpp_process');
$this->conn->processTime(0);
} catch (XMPPHP_Exception $e) {
$this->pingid++;
}
- common_log(LOG_DEBUG, "Sending ping #{$this->pingid}");
+ common_debug("Sending ping #{$this->pingid}");
$this->conn->send("<iq from='{" . $this->plugin->daemonScreenname() . "}' to='{$this->plugin->server}' id='ping_{$this->pingid}' type='get'><ping xmlns='urn:xmpp:ping'/></iq>");
$this->lastping = $now;
return true;