オルガが止まらない
このコミットが含まれているのは:
コミット
8d5b4a7254
|
@ -340,11 +340,11 @@ class File extends Managed_DataObject
|
|||
$origname = preg_replace('/[^A-Za-z0-9\.\_]/', '_', $origname);
|
||||
|
||||
$nickname = $profile->getNickname();
|
||||
$datestamp = strftime('%Y%m%d', time());
|
||||
$datestamp = date('Ymd');
|
||||
do {
|
||||
// generate new random strings until we don't run into a filename collision.
|
||||
$random = strtolower(common_confirmation_code(16));
|
||||
$filename = "$nickname-$datestamp-$origname-$random.$ext";
|
||||
$filename = "{$nickname}-{$datestamp}-{$origname}-{$random}.{$ext}";
|
||||
} while (file_exists(self::path($filename)));
|
||||
return $filename;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ class File_redirection extends Managed_DataObject
|
|||
public $redirections; // int(4)
|
||||
public $httpcode; // int(4)
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $redir_url;
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
|
|
|
@ -636,7 +636,9 @@ class Memcached_DataObject extends Safe_DataObject
|
|||
$pval = array();
|
||||
|
||||
foreach ($types as $key => $type) {
|
||||
assert(!empty($key));
|
||||
if (empty($key)) {
|
||||
doom("\$keyは空です。", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
if ($type == 'U') {
|
||||
if (empty($this->$key)) {
|
||||
|
@ -652,7 +654,9 @@ class Memcached_DataObject extends Safe_DataObject
|
|||
}
|
||||
}
|
||||
|
||||
assert(count($pkey) > 0);
|
||||
if (count($pkey) > 0) {
|
||||
doom("配列\$pkeyの中に、誰もいませんよ。", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
// XXX: should work for both compound and scalar pkeys
|
||||
$pvals = implode(',', $pval);
|
||||
|
|
|
@ -3232,12 +3232,15 @@ class Notice extends Managed_DataObject
|
|||
$notice = new Notice();
|
||||
|
||||
$fkeyname = $notice->tableName().'_'.$field.'_fkey';
|
||||
assert(isset($newschemadef['foreign keys'][$fkeyname]));
|
||||
assert($newschemadef['foreign keys'][$fkeyname]);
|
||||
if (!isset($newschemadef['foreign keys'][$fkeyname])) {
|
||||
doom("'foreign keys'を見つけられません。", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
$foreign_key = $newschemadef['foreign keys'][$fkeyname];
|
||||
$fkeytable = $foreign_key[0];
|
||||
assert(isset($foreign_key[1][$field]));
|
||||
if (!isset($foreign_key[1][$field])) {
|
||||
doom("\$foreign_key[1][\$field]は存在しません。", __FILE__, __LINE__);
|
||||
}
|
||||
$fkeycol = $foreign_key[1][$field];
|
||||
|
||||
printfnq("* {$fkeyname} ({$field} => {$fkeytable}.{$fkeycol})\n");
|
||||
|
|
|
@ -222,7 +222,9 @@ class Subscription extends Managed_DataObject
|
|||
|
||||
// note we checked for existence above
|
||||
|
||||
assert(!empty($sub));
|
||||
if (empty($sub)) {
|
||||
doom("登録していません。", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
$result = $sub->delete();
|
||||
|
||||
|
|
11
debug.php
11
debug.php
|
@ -16,4 +16,15 @@
|
|||
return $st;
|
||||
}
|
||||
}
|
||||
|
||||
// 簡単に問題をデバッグする為、ファイルと行列は必須です
|
||||
function doom (string $mess, string $file, int $line) {
|
||||
if (0 === error_reporting()) {
|
||||
$mess;
|
||||
return;
|
||||
}
|
||||
throw new \ErrorException($mess, 0, E_ALL, $file, $line);
|
||||
}
|
||||
|
||||
set_error_handler("doom");
|
||||
?>
|
||||
|
|
|
@ -425,7 +425,7 @@ class HTTP_Request2_Response
|
|||
public function getBody()
|
||||
{
|
||||
if (0 == strlen($this->body) || !$this->bodyEncoded
|
||||
|| !in_array(strtolower($this->getHeader('content-encoding')), array('gzip', 'deflate'))
|
||||
|| !in_array(strtolower($this->getHeader('content-encoding') ?? ""), array('gzip', 'deflate'))
|
||||
) {
|
||||
return $this->body;
|
||||
|
||||
|
@ -436,7 +436,7 @@ class HTTP_Request2_Response
|
|||
}
|
||||
|
||||
try {
|
||||
switch (strtolower($this->getHeader('content-encoding'))) {
|
||||
switch (strtolower($this->getHeader('content-encoding') ?? "")) {
|
||||
case 'gzip':
|
||||
$decoded = self::decodeGzip($this->body);
|
||||
break;
|
||||
|
|
|
@ -468,7 +468,7 @@ class Mail_RFC822 {
|
|||
while (strlen($address['address']) > 0) {
|
||||
$parts = explode(',', $address['address']);
|
||||
$addresses[] = $this->_splitCheck($parts, ',');
|
||||
$address['address'] = trim(substr($address['address'], strlen(end($addresses) . ',')));
|
||||
$address['address'] = trim(substr($address['address'], strlen($addresses[array_key_last($addresses)] . ',')));
|
||||
}
|
||||
} else {
|
||||
$addresses[] = $address['address'];
|
||||
|
|
|
@ -529,7 +529,7 @@ class PEAR
|
|||
$skipmsg = false)
|
||||
{
|
||||
// The error is yet a PEAR error object
|
||||
if (is_object($message)) {
|
||||
if (is_object($message) && $message instanceof PEAR_Error) {
|
||||
$code = $message->getCode();
|
||||
$userinfo = $message->getUserInfo();
|
||||
$error_class = $message->getType();
|
||||
|
@ -540,12 +540,16 @@ class PEAR
|
|||
if (
|
||||
$object !== null &&
|
||||
isset($object->_expected_errors) &&
|
||||
count($object->_expected_errors) > 0 &&
|
||||
count($exp = end($object->_expected_errors))
|
||||
count($object->_expected_errors) > 0
|
||||
) {
|
||||
$exp = [];
|
||||
if (gettype($object->_expected_errors) == "object") {
|
||||
$exp = get_mangled_object_vars($object->_expected_errors);
|
||||
}
|
||||
$exp = $exp[array_key_last($exp)];
|
||||
if ($exp[0] === "*" ||
|
||||
(is_int(reset($exp)) && in_array($code, $exp)) ||
|
||||
(is_string(reset($exp)) && in_array($message, $exp))
|
||||
(is_int($exp[0]) && in_array($code, $exp)) ||
|
||||
(is_string($exp[0]) && in_array($message, $exp))
|
||||
) {
|
||||
$mode = PEAR_ERROR_RETURN;
|
||||
}
|
||||
|
@ -775,8 +779,7 @@ function _PEAR_call_destructors()
|
|||
if (is_array($_PEAR_destructor_object_list) &&
|
||||
sizeof($_PEAR_destructor_object_list))
|
||||
{
|
||||
reset($_PEAR_destructor_object_list);
|
||||
|
||||
$_PEAR_destructor_object_list = $_PEAR_destructor_object_list[0];
|
||||
$destructLifoExists = PEAR::getStaticProperty('PEAR', 'destructlifo');
|
||||
|
||||
if ($destructLifoExists) {
|
||||
|
|
|
@ -910,7 +910,7 @@ class Validate
|
|||
$method = $opt['type'];
|
||||
unset($opt['type']);
|
||||
|
||||
if (sizeof($opt) == 1 && is_array(reset($opt))) {
|
||||
if (sizeof($opt) == 1 && is_array($opt)) {
|
||||
$opt = array_pop($opt);
|
||||
}
|
||||
$valid[$var_name] = call_user_func(['Validate', $method], $val2check, $opt);
|
||||
|
|
|
@ -524,9 +524,10 @@ class Action extends HTMLOutputter // lawsuit
|
|||
$this->endDocument('json');
|
||||
break;
|
||||
default:
|
||||
common_log(LOG_ERR, 'Handled serverError (' . _ve($code) . ') but cannot output into desired format (' . _ve($this->format) . '): ' . _ve($msg));
|
||||
$action = new ServerErrorAction($msg, $code);
|
||||
$action->execute();
|
||||
break;
|
||||
//common_log(LOG_ERR, 'Handled serverError (' . _ve($code) . ') but cannot output into desired format (' . _ve($this->format) . '): ' . _ve($msg));
|
||||
//$action = new ServerErrorAction($msg, $code);
|
||||
//$action->execute();
|
||||
}
|
||||
|
||||
exit((int)$code);
|
||||
|
|
|
@ -150,7 +150,9 @@ class ActivityImporter extends QueueHandler
|
|||
$group = $oprofile->localGroup();
|
||||
}
|
||||
|
||||
assert(!empty($group));
|
||||
if (empty($group)) {
|
||||
doom("\$groupは空です。", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
if ($user->isMember($group)) {
|
||||
// TRANS: Client exception thrown when trying to join a group the importing user is already a member of.
|
||||
|
|
|
@ -78,7 +78,9 @@ class AdminPanelAction extends Action
|
|||
|
||||
// ...because they're logged in
|
||||
|
||||
assert(!empty($user));
|
||||
if (empty($user)) {
|
||||
doom("\$userは空です。", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
// It must be a "real" login, not saved cookie login
|
||||
|
||||
|
|
|
@ -142,7 +142,9 @@ class ApiGNUsocialOAuthDataStore extends OAuthDataStore
|
|||
$rt->type = 0; // request
|
||||
|
||||
$app = Oauth_application::getByConsumerKey($consumer->key);
|
||||
assert(!empty($app));
|
||||
if (empty($app)) {
|
||||
doom("Oauthに失敗しました。", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
if ($rt->find(true) && $rt->state == 1 && $rt->verifier == $verifier) { // authorized
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class InvalidFilenameException extends ServerException
|
|||
public $widgetOpts;
|
||||
public $scoped;
|
||||
|
||||
public $filename = null;
|
||||
public $filename = "";
|
||||
|
||||
public function __construct($filename)
|
||||
{
|
||||
|
|
|
@ -189,13 +189,15 @@ class MediaFile
|
|||
*/
|
||||
public static function getHashOfFile(string $filepath, $filehash = null)
|
||||
{
|
||||
assert(!empty($filepath), __METHOD__ . ': filepath cannot be null');
|
||||
if (empty($filepath)) {
|
||||
doom("__METHOD__ . ': filepath cannot be null", __FILE__, __LINE__);
|
||||
}
|
||||
if (!file_exists($filepath)) {
|
||||
throw new ServerException($filepath."が存在しません。");
|
||||
doom($filepath."が存在しません。", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
if (!is_readable($filepath)) {
|
||||
throw new ServerException($filepath."の許可に失敗。");
|
||||
doom($filepath."の許可に失敗。", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
if ($filehash === null) {
|
||||
|
|
|
@ -56,7 +56,9 @@ class AccountProfileBlock extends ProfileBlock
|
|||
$this->user = $this->profile->getUser();
|
||||
} catch (NoSuchUserException $e) {
|
||||
// The profile presented is non-local
|
||||
assert(!$this->profile->isLocal());
|
||||
if ($this->profile->isLocal()) {
|
||||
doom("リモートアカウントです。", __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,18 +86,20 @@ class AvatarLink
|
|||
return $alink;
|
||||
}
|
||||
|
||||
// yuck!
|
||||
static function mediatype($filename) {
|
||||
$parts = explode('.', $filename);
|
||||
$ext = strtolower(end($parts));
|
||||
if ($ext == 'jpeg') {
|
||||
$ext = strtolower(array_slice($parts, -1)[0]);
|
||||
|
||||
if ($ext === 'jpeg') {
|
||||
$ext = 'jpg';
|
||||
}
|
||||
// hope we don't support any others
|
||||
$types = array('png', 'gif', 'jpg', 'jpeg');
|
||||
if (in_array($ext, $types)) {
|
||||
|
||||
$valex = ['png', 'gif', 'jpg', 'jpeg'];
|
||||
|
||||
if (in_array($ext, $valex)) {
|
||||
return 'image/' . $ext;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,10 @@ mb_internal_encoding('UTF-8');
|
|||
require_once INSTALLDIR . '/lib/util/framework.php';
|
||||
|
||||
try {
|
||||
GNUsocial::init(@$server, @$path, @$conffile);
|
||||
$server = null;
|
||||
$path = null;
|
||||
$conffile = null;
|
||||
GNUsocial::init($server, $path, $conffile);
|
||||
} catch (NoConfigException $e) {
|
||||
// XXX: Throw a conniption if database not installed
|
||||
// XXX: Find a way to use htmlwriter for this instead of handcoded markup
|
||||
|
|
|
@ -78,7 +78,9 @@ function mail_send($recipients, $headers, $body)
|
|||
$headers['Content-Type'] = 'text/plain; charset=UTF-8';
|
||||
}
|
||||
|
||||
assert($backend); // throws an error if it's bad
|
||||
if ($backend === null) { // throws an error if it's bad
|
||||
doom("メールバックエンドにエラー。", __FILE__, __LINE__);
|
||||
}
|
||||
$sent = $backend->send($recipients, $headers, $body);
|
||||
if ($_PEAR->isError($sent)) {
|
||||
throw new EmailException($sent->getMessage(), !is_null($send->getCode()) ? $sent->getCode() : 0);
|
||||
|
|
|
@ -73,7 +73,9 @@ class ManagedAction extends Action
|
|||
protected function handlePost()
|
||||
{
|
||||
// This will only be run if the Action has the property canPost==true
|
||||
assert($this->canPost);
|
||||
if (!$this->canPost) {
|
||||
doom("投稿出来ません。", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
// check for this before token since all POST and FILES data
|
||||
// is losts when size is exceeded
|
||||
|
|
|
@ -1658,7 +1658,9 @@ function common_sql_weight($column, $dropoff)
|
|||
|
||||
function common_redirect(string $url, int $code = 307): void
|
||||
{
|
||||
assert(in_array($code, [301, 302, 303, 307]));
|
||||
if (!in_array($code, [301, 302, 303, 307])) {
|
||||
doom($code."は転送コードではありません。", __FILE__, __LINE__);
|
||||
}
|
||||
http_response_code($code);
|
||||
header("Location: {$url}");
|
||||
header("Connection: close");
|
||||
|
@ -2010,12 +2012,16 @@ function common_accept_to_prefs($accept, $def = '*/*')
|
|||
}
|
||||
|
||||
$prefs = [];
|
||||
|
||||
$parts = explode(',', $accept);
|
||||
|
||||
foreach ($parts as $part) {
|
||||
// FIXME: doesn't deal with params like 'text/html; level=1'
|
||||
@list($value, $qpart) = explode(';', trim($part));
|
||||
$p = explode(';', trim($part));
|
||||
$value = 0;
|
||||
if (count($p) >= 2) {
|
||||
list($value, $qpart) = $p;
|
||||
}
|
||||
|
||||
$match = [];
|
||||
if (!isset($qpart)) {
|
||||
$prefs[$value] = 1;
|
||||
|
@ -2716,40 +2722,49 @@ function common_send_file(string $filepath, string $mimetype, string $filename,
|
|||
header("Content-Type: {$mimetype}");
|
||||
header("Content-Disposition: {$disposition}; filename=\"{$filename}\"");
|
||||
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
|
||||
|
||||
if (is_string(common_config('site', 'x-static-delivery'))) {
|
||||
$tmp = explode(INSTALLDIR, $filepath);
|
||||
$relative_path = end($tmp);
|
||||
common_debug("Using Static Delivery with header: '" .
|
||||
common_config('site', 'x-static-delivery') . ": {$relative_path}'");
|
||||
header(common_config('site', 'x-static-delivery') . ": {$relative_path}");
|
||||
handleStaticDelivery($filepath);
|
||||
} else {
|
||||
header("Content-Description: File Transfer");
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
|
||||
$filesize = filesize($filepath);
|
||||
|
||||
if (file_exists($filepath)) {
|
||||
http_response_code(200);
|
||||
header("Content-Length: {$filesize}");
|
||||
// header('Cache-Control: private, no-transform, no-store, must-revalidate');
|
||||
|
||||
$ret = @readfile($filepath);
|
||||
|
||||
if ($ret === false) {
|
||||
http_response_code(404);
|
||||
common_log(LOG_ERR, "Couldn't read file at {$filepath}.");
|
||||
} elseif ($ret !== $filesize) {
|
||||
http_response_code(500);
|
||||
common_log(LOG_ERR, "The lengths of the file as recorded on the DB (or on disk) for the file " .
|
||||
"{$filepath} differ from what was sent to the user ({$filesize} vs {$ret}).");
|
||||
}
|
||||
} else {
|
||||
http_response_code(404);
|
||||
common_log(LOG_ERR, "File doesn't exist at {$filepath}.");
|
||||
}
|
||||
handleDynamicDelivery($filepath);
|
||||
}
|
||||
}
|
||||
|
||||
function handleStaticDelivery(string $filepath): void
|
||||
{
|
||||
$tmp = explode(INSTALLDIR, $filepath);
|
||||
$relative_path = array_pop($tmp);
|
||||
common_debug("Using Static Delivery with header: '".common_config('site', 'x-static-delivery') . ": {$relative_path}'");
|
||||
header(common_config('site', 'x-static-delivery').": {$relative_path}");
|
||||
}
|
||||
|
||||
|
||||
function handleDynamicDelivery(string $filepath): void
|
||||
{
|
||||
header("Content-Description: File Transfer");
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
|
||||
if (file_exists($filepath)) {
|
||||
http_response_code(HTTP_OK);
|
||||
header("Content-Length: ".filesize($filepath));
|
||||
// header('Cache-Control: private, no-transform, no-store, must-revalidate');
|
||||
|
||||
$ret = readfile($filepath);
|
||||
|
||||
if ($ret === false) {
|
||||
http_response_code(HTTP_NOT_FOUND);
|
||||
throw new ServerException("Couldn't read file at {$filepath}.");
|
||||
} elseif ($ret !== filesize($filepath)) {
|
||||
http_response_code(HTTP_INTERNAL_SERVER_ERROR);
|
||||
throw new ServerException("The lengths of the file as recorded on the DB (or on disk) for the file {$filepath}.");
|
||||
}
|
||||
} else {
|
||||
http_response_code(HTTP_NOT_FOUND);
|
||||
throw new ServerException("File doesn't exist at {$filepath}.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function html_sprintf()
|
||||
{
|
||||
$args = func_get_args();
|
||||
|
|
|
@ -218,9 +218,12 @@ class xmloutputter
|
|||
*/
|
||||
public function elementStartNS(array $ns, string $tag, $attrs = null): void
|
||||
{
|
||||
reset($ns); // array pointer to 0
|
||||
$uri = key($ns);
|
||||
$this->xw->startElementNS($ns[$uri], $tag, $uri);
|
||||
$keys = array_keys($ns);
|
||||
$uri = $keys[0];
|
||||
$prefix = $ns[$uri];
|
||||
|
||||
$this->xw->startElementNS($prefix, $tag, $uri);
|
||||
|
||||
if (is_array($attrs)) {
|
||||
foreach ($attrs as $name => $value) {
|
||||
$this->xw->writeAttribute($name, $value);
|
||||
|
|
|
@ -53,7 +53,9 @@ class ActivityVerbPostModule extends ActivityVerbHandlerModule
|
|||
// FIXME: Set this to abstract public in classes/modules/ActivityHandlerModule.php when all plugins have migrated!
|
||||
protected function saveObjectFromActivity(Activity $act, Notice $stored, array $options=array())
|
||||
{
|
||||
assert($this->isMyActivity($act));
|
||||
if (!$this->isMyActivity($act)) {
|
||||
doom("あなたのアクティビティではありません。", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
$stored->object_type = ActivityUtils::resolveUri($act->objects[0]->type);
|
||||
if (common_valid_http_url($act->objects[0]->link)) {
|
||||
|
|
|
@ -248,7 +248,9 @@ class FavoriteModule extends ActivityVerbHandlerModule
|
|||
// FIXME: Set this to abstract public in lib/modules/ActivityHandlerPlugin.php when all plugins have migrated!
|
||||
protected function saveObjectFromActivity(Activity $act, Notice $stored, array $options=array())
|
||||
{
|
||||
assert($this->isMyActivity($act));
|
||||
if (!$this->isMyActivity($act)) {
|
||||
doom("あなたのアクティビティではありません。", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
// We must have an objects[0] here because in isMyActivity we require the count to be == 1
|
||||
$actobj = $act->objects[0];
|
||||
|
|
|
@ -212,7 +212,9 @@ class AtompubfavoritefeedAction extends ApiAuthAction
|
|||
// Favorite plugin handles these as ActivityHandlerModule through Notice->saveActivity
|
||||
// which in turn uses "StoreActivityObject" event.
|
||||
Event::handle('StartAtomPubNewActivity', array(&$activity, $this->scoped, &$notice));
|
||||
assert($notice instanceof Notice);
|
||||
if (!($notice instanceof Notice)) {
|
||||
doom("\$noticeオブジェクトはNoticeのインスタンスではありません。", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
$act = $notice->asActivity();
|
||||
|
||||
|
|
|
@ -87,7 +87,9 @@ class ShareModule extends ActivityVerbHandlerModule
|
|||
// FIXME: Set this to abstract public in lib/modules/ActivityHandlerPlugin.php when all plugins have migrated!
|
||||
protected function saveObjectFromActivity(Activity $act, Notice $stored, array $options=array())
|
||||
{
|
||||
assert($this->isMyActivity($act));
|
||||
if (!$this->isMyActivity($act)) {
|
||||
doom("他人のノートを良いねに出来ません。", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
// The below algorithm is mainly copied from the previous Ostatus_profile->processShare()
|
||||
|
||||
|
|
|
@ -148,13 +148,8 @@ class TwitterImport
|
|||
$notice->url = $statusUri;
|
||||
$notice->verb = ActivityVerb::POST;
|
||||
$notice->object_type = ActivityObject::NOTE;
|
||||
$notice->created = strftime(
|
||||
'%Y-%m-%d %H:%M:%S',
|
||||
strtotime($status->created_at)
|
||||
);
|
||||
|
||||
$notice->created = date("Y-m-d H:i:s", strtotime($status->created_at));
|
||||
$notice->source = 'twitter';
|
||||
|
||||
$notice->reply_to = null;
|
||||
|
||||
$replyTo = twitter_id($status, 'in_reply_to_status_id');
|
||||
|
|
|
@ -694,7 +694,9 @@ function migrateProfilePrefs()
|
|||
|
||||
foreach ($prefs as $namespace=>$mods) {
|
||||
echo "$namespace... ";
|
||||
assert(is_array($mods));
|
||||
if (!is_array($mods)) {
|
||||
doom("\$modsは配列ではありません。", __FILE__, __LINE__);
|
||||
}
|
||||
$p = new Profile_prefs();
|
||||
$p->namespace = $namespace;
|
||||
// find all entries in all modified topics given in this namespace
|
||||
|
|
読み込み中…
新しいイシューから参照