pkp / pkp-lib

The library used by PKP's applications OJS, OMP and OPS, open source software for scholarly publishing.
https://pkp.sfu.ca
GNU General Public License v3.0
299 stars 444 forks source link

Dissimilarity in session migration comparing with Laravel's session migration #10055

Closed touhidurabir closed 3 months ago

touhidurabir commented 3 months ago

Describe the bug With the merge of pkp/pkp-lib#9566 , we have moved the whole session/cookie management utilising the Laravel's session toolset . As a result the sessions table migration also set as per what default laravel's session migration ships with . However some Dissimilarities has beep slipped into the session migration .

The latest default session migration from Laravel like

Schema::create('sessions', function (Blueprint $table) {
    $table->string('id')->primary();
    $table->foreignId('user_id')->nullable()->index();
    $table->string('ip_address', 45)->nullable();
    $table->text('user_agent')->nullable();
    $table->longText('payload');
    $table->integer('last_activity')->index();
});

where OJS/OMP/OPS session migration looks like

Schema::create('sessions', function (Blueprint $table) {
    $table->comment('Session data for logged-in users.');
    $table->string('id')->primary();

    $table->bigInteger('user_id')->nullable();
    $table->foreign('user_id', 'sessions_user_id')->references('user_id')->on('users')->onDelete('cascade');
    $table->index(['user_id'], 'sessions_user_id');

    $table->string('ip_address', 45)->nullable();
    $table->string('user_agent', 255)->nullable();
    $table->bigInteger('last_activity')->index();
    $table->text('payload');

    $table->unique(['id'], 'sessions_pkey');
});

few differences are

  1. $table->text('user_agent')->nullable(); vs. $table->string('user_agent', 255)->nullable(); (text / string(...,255))
  2. $table->longText('payload'); vs. $table->text('payload'); (longText / text)
  3. $table->integer('last_activity')->index(); vs. $table->bigInteger('last_activity')->index(); (integer / bigInteger)
  4. extra index $table->unique(['id'], 'sessions_pkey');, which triggers a bug in MariaDB 10.4

These dissimilarities probably not going to cause any issue but better to sync it with what laravel ships with as whole session/cookie toolset starting from 3.5.0 is based on Laravel's toolset .

some more details at https://github.com/pkp/pkp-lib/issues/9566#issuecomment-2163313257

PR pkp-lib --> https://github.com/pkp/pkp-lib/pull/10057 ojs --> https://github.com/pkp/ojs/pull/4316

touhidurabir commented 3 months ago

resolved by https://github.com/pkp/pkp-lib/pull/10057