Browse Source

Fix the infinite request loop in Message with mid/parentmid

pull/978/head
Timothée Jaussoin 5 years ago
parent
commit
3b6692b35d
  1. 12
      app/Message.php
  2. 1
      app/PresenceBuffer.php
  3. 1
      database/migrations/20201106101328_add_parent_mid_to_messages_table.php

12
app/Message.php

@ -229,7 +229,7 @@ class Message extends Model
->orderBy('published', 'asc')
->first();
if ($parent) {
if ($parent && $parent->mid != $this->mid) {
$this->parentmid = $parent->mid;
}
}
@ -535,8 +535,11 @@ class Message extends Model
];
// Generate a proper mid
if (empty($this->attributes['mid'])) {
if (empty($this->attributes['mid'])
|| ($this->attributes['mid'] && $this->attributes['mid'] == 1)) {
$array['mid'] = $this->getNextStatementId();
} else {
$array['mid'] = $this->attributes['mid'];
}
return $array;
@ -545,9 +548,6 @@ class Message extends Model
public function getNextStatementId()
{
$next_id = DB::select("select nextval('messages_mid_seq'::regclass)");
$val = intval($next_id['0']->nextval);
\Utils::debug('GENERATED '.$val);
return $val;
return intval($next_id['0']->nextval);
}
}

1
app/PresenceBuffer.php

@ -6,7 +6,6 @@ use Illuminate\Database\Capsule\Manager as DB;
use Moxl\Xec\Action\Disco\Request;
use Moxl\Xec\Action\Vcard\Get;
use Movim\Picture;
use App\Presence;
use App\Info;
use App\Contact;

1
database/migrations/20201106101328_add_parent_mid_to_messages_table.php

@ -26,6 +26,7 @@ class AddParentMidToMessagesTable extends Migration
$this->disableForeignKeyCheck();
$this->schema->table('messages', function (Blueprint $table) {
$table->dropForeign('messages_parentmid_foreign');
$table->dropColumn('parentmid');
$table->string('parentthread', 128)->nullable();
});

Loading…
Cancel
Save