Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/Models/Note.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* @property int $id
* @property string $text
* @property string $name
* @property int $crc32
*
* @mixin Builder<Note>
*/
Expand All @@ -21,14 +20,12 @@ class Note extends Model
public $timestamps = false;

protected $fillable = [
'crc32',
'name',
'text',
];

protected $casts = [
'id' => 'integer',
'crc32' => 'integer',
];

/**
Expand Down
20 changes: 1 addition & 19 deletions app/Utils/NoteCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,12 @@ class NoteCreator
public $time;
public $text;

private $crc32;

public function __construct()
{
$this->buildid = null;
$this->name = '';
$this->time = '';
$this->text = '';
$this->crc32 = '';
}

/** Get the CRC32 */
public function computeCrc32()
{
if (strlen($this->crc32) > 0) {
return $this->crc32;
}
// Compute the CRC32 for the note.
$text = pdo_real_escape_string($this->text);
$name = pdo_real_escape_string($this->name);
$this->crc32 = crc32($text . $name);
return $this->crc32;
}

/**
Expand All @@ -60,11 +44,9 @@ public function computeCrc32()
public function create()
{
// Create the note if it doesn't already exist.
$this->computeCrc32();
$note = Note::firstOrCreate(['crc32' => $this->crc32], [
$note = Note::firstOrCreate([
'name' => $this->name,
'text' => $this->text,
'crc32' => $this->crc32,
]);

// Create the build2note record.
Expand Down
1 change: 0 additions & 1 deletion app/cdash/tests/test_removebuilds.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ public function testBuildRemovalWorksAsExpected(): void
$note_id = DB::table('note')->insertGetId([
'text' => 'note for test_removebuildds',
'name' => 'test_removebuilds.log',
'crc32' => $crc32,
]);
$testoutput_id = DB::table('testoutput')->insertGetId([
'output' => 'testoutput for test_removebuildds',
Expand Down
16 changes: 16 additions & 0 deletions database/migrations/2025_06_17_140642_drop_note_crc32.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration {
public function up(): void
{
DB::statement('ALTER TABLE note DROP COLUMN IF EXISTS crc32');
DB::statement('CREATE INDEX ON note USING HASH (text)');
}

public function down(): void
{
}
};
21 changes: 0 additions & 21 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3654,21 +3654,6 @@ parameters:
count: 1
path: app/Utils/LdapUtils.php

-
message: '''
#^Call to deprecated function pdo_real_escape_string\(\)\:
04/01/2023$#
'''
identifier: function.deprecated
count: 2
path: app/Utils/NoteCreator.php

-
message: '#^Method App\\Utils\\NoteCreator\:\:computeCrc32\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: app/Utils/NoteCreator.php

-
message: '#^Method App\\Utils\\NoteCreator\:\:create\(\) has no return type specified\.$#'
identifier: missingType.return
Expand All @@ -3681,12 +3666,6 @@ parameters:
count: 1
path: app/Utils/NoteCreator.php

-
message: '#^Property App\\Utils\\NoteCreator\:\:\$crc32 has no type specified\.$#'
identifier: missingType.property
count: 1
path: app/Utils/NoteCreator.php

-
message: '#^Property App\\Utils\\NoteCreator\:\:\$name has no type specified\.$#'
identifier: missingType.property
Expand Down
3 changes: 0 additions & 3 deletions tests/Feature/GraphQL/NoteTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,16 @@ protected function setUp(): void
$this->note1 = Note::create([
'name' => Str::uuid()->toString(),
'text' => Str::uuid()->toString(),
'crc32' => random_int(0, 100000),
]);

$this->note2 = Note::create([
'name' => Str::uuid()->toString(),
'text' => Str::uuid()->toString(),
'crc32' => random_int(0, 100000),
]);

$this->note3 = Note::create([
'name' => Str::uuid()->toString(),
'text' => Str::uuid()->toString(),
'crc32' => random_int(0, 100000),
]);

$this->public_project->builds()->create([
Expand Down