Skip to content

Commit cd68b9c

Browse files
committed
reproduction of laravel/framework#49890
1 parent 3d6d006 commit cd68b9c

File tree

6 files changed

+143
-65
lines changed

6 files changed

+143
-65
lines changed

.env.example

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
APP_NAME=Laravel
22
APP_ENV=local
3-
APP_KEY=
3+
APP_KEY=base64:EcXczznJFhqpOEm3Pk5h8s9Q5lVJpXdjc2IJ9UbUe5s=
44
APP_DEBUG=true
55
APP_URL=http://localhost
66

77
LOG_CHANNEL=stack
88
LOG_DEPRECATIONS_CHANNEL=null
99
LOG_LEVEL=debug
1010

11-
DB_CONNECTION=mysql
11+
DB_CONNECTION=sqlite
1212
DB_HOST=127.0.0.1
1313
DB_PORT=3306
1414
DB_DATABASE=bug_report
1515
DB_USERNAME=root
1616
DB_PASSWORD=
1717

1818
BROADCAST_DRIVER=log
19-
CACHE_DRIVER=file
19+
CACHE_DRIVER=redis
2020
FILESYSTEM_DISK=local
21-
QUEUE_CONNECTION=sync
21+
QUEUE_CONNECTION=redis
2222
SESSION_DRIVER=file
2323
SESSION_LIFETIME=120
2424

README.md

Lines changed: 13 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,18 @@
1-
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
1+
# Bug Reproduction
22

3-
<p align="center">
4-
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
5-
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
6-
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
7-
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
8-
</p>
3+
A proof of concept for the misbehavior of the ShouldBeUnique mechanism
4+
with the missing model.
95

10-
## About Laravel
6+
Issue: [https://github.com/laravel/framework/issues/49890](https://github.com/laravel/framework/issues/49890)
117

12-
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
8+
Pull request with the fix: [https://github.com/laravel/framework/pull/50211](https://github.com/laravel/framework/pull/50211)
139

14-
- [Simple, fast routing engine](https://laravel.com/docs/routing).
15-
- [Powerful dependency injection container](https://laravel.com/docs/container).
16-
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
17-
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
18-
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
19-
- [Robust background job processing](https://laravel.com/docs/queues).
20-
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
10+
Execute the following:
2111

22-
Laravel is accessible, powerful, and provides tools required for large, robust applications.
23-
24-
## Learning Laravel
25-
26-
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
27-
28-
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
29-
30-
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
31-
32-
## Laravel Sponsors
33-
34-
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
35-
36-
### Premium Partners
37-
38-
- **[Vehikl](https://vehikl.com/)**
39-
- **[Tighten Co.](https://tighten.co)**
40-
- **[WebReinvent](https://webreinvent.com/)**
41-
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
42-
- **[64 Robots](https://64robots.com)**
43-
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
44-
- **[Cyber-Duck](https://cyber-duck.co.uk)**
45-
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
46-
- **[Jump24](https://jump24.co.uk)**
47-
- **[Redberry](https://redberry.international/laravel/)**
48-
- **[Active Logic](https://activelogic.com)**
49-
- **[byte5](https://byte5.de)**
50-
- **[OP.GG](https://op.gg)**
51-
52-
## Contributing
53-
54-
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
55-
56-
## Code of Conduct
57-
58-
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
59-
60-
## Security Vulnerabilities
61-
62-
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
63-
64-
## License
65-
66-
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
12+
```
13+
git clone https://github.com/naquad/laravel-bug-report-49890.git
14+
cd laravel-bug-report-49890
15+
cp .env.example .env
16+
./artisan migrate
17+
./artisan app:poc
18+
```
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Jobs\ProcessRecord;
6+
use App\Models\Record;
7+
use Illuminate\Console\Command;
8+
use Illuminate\Support\Facades\Artisan;
9+
use Illuminate\Support\Facades\Redis;
10+
11+
class PocCommand extends Command
12+
{
13+
/**
14+
* The name and signature of the console command.
15+
*
16+
* @var string
17+
*/
18+
protected $signature = 'app:poc';
19+
20+
/**
21+
* The console command description.
22+
*
23+
* @var string
24+
*/
25+
protected $description = 'ShouldBeUnique issue reproduction command.';
26+
27+
/**
28+
* Execute the console command.
29+
*/
30+
public function handle()
31+
{
32+
Redis::flushdb();
33+
Record::truncate();
34+
35+
$r = Record::create(['name' => 'test']);
36+
37+
ProcessRecord::dispatch($r);
38+
$r->delete();
39+
Artisan::call('queue:work', ['--once' => true]);
40+
41+
$keys = Redis::keys('*');
42+
if (!$keys) {
43+
$this->info('No keys found in Redis, lock removed');
44+
} else {
45+
$this->error('Keys found in Redis, lock not removed');
46+
dump($keys);
47+
}
48+
}
49+
}

app/Jobs/ProcessRecord.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace App\Jobs;
4+
5+
use App\Models\Record;
6+
use Illuminate\Bus\Queueable;
7+
use Illuminate\Contracts\Queue\ShouldBeUnique;
8+
use Illuminate\Contracts\Queue\ShouldQueue;
9+
use Illuminate\Foundation\Bus\Dispatchable;
10+
use Illuminate\Queue\InteractsWithQueue;
11+
use Illuminate\Queue\SerializesModels;
12+
13+
class ProcessRecord implements ShouldQueue, ShouldBeUnique
14+
{
15+
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
16+
17+
/**
18+
* Create a new job instance.
19+
*/
20+
public function __construct(
21+
public Record $record
22+
)
23+
{
24+
//
25+
}
26+
27+
/**
28+
* Execute the job.
29+
*/
30+
public function handle(): void
31+
{
32+
//
33+
}
34+
}

app/Models/Record.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class Record extends Model
9+
{
10+
use HasFactory;
11+
12+
public $fillable = [
13+
'name',
14+
];
15+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('records', function (Blueprint $table) {
15+
$table->id();
16+
$table->string('name')->unique();
17+
$table->timestamps();
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*/
24+
public function down(): void
25+
{
26+
Schema::dropIfExists('records');
27+
}
28+
};

0 commit comments

Comments
 (0)