language
stringclasses
1 value
owner
stringlengths
2
15
repo
stringlengths
2
21
sha
stringlengths
45
45
message
stringlengths
7
36.3k
path
stringlengths
1
199
patch
stringlengths
15
102k
is_multipart
bool
2 classes
Other
laravel
framework
206aae2a7a5c97a7e0af3bed8e842635504de306.json
add tests, update changelog, increase readability
tests/Filesystem/FilesystemTest.php
@@ -414,4 +414,28 @@ public function testIsFileChecksFilesProperly() $this->assertTrue($filesystem->isFile($this->tempDir.'/foo/foo.txt')); $this->assertFalse($filesystem->isFile($this->tempDir.'./foo')); } + + public function testFilesMethodReturnsFileInfoObjects() + { + mkdir($this->tempDir.'/foo'); + file_put_contents($this->tempDir.'/foo/1.txt', '1'); + file_put_contents($this->tempDir.'/foo/2.txt', '2'); + mkdir($this->tempDir.'/foo/bar'); + $files = new Filesystem(); + foreach ($files->files($this->tempDir.'/foo') as $file) { + $this->assertInstanceOf(\SplFileInfo::class, $file); + } + unset($files); + } + + public function testAllFilesReturnsFileInfoObjects() + { + file_put_contents($this->tempDir.'/foo.txt', 'foo'); + file_put_contents($this->tempDir.'/bar.txt', 'bar'); + $files = new Filesystem(); + $allFiles = []; + foreach ($files->allFiles($this->tempDir) as $file) { + $this->assertInstanceOf(\SplFileInfo::class, $file); + } + } }
true
Other
laravel
framework
2a6902866e4db7a0de65cbaf33a6cbd20b77834e.json
Apply fixes from StyleCI (#18873)
src/Illuminate/Foundation/Console/Kernel.php
@@ -11,7 +11,6 @@ use Illuminate\Contracts\Debug\ExceptionHandler; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Cache\Repository as Cache; -use Illuminate\Contracts\Queue\Queue as QueueContract; use Illuminate\Contracts\Console\Kernel as KernelContract; use Symfony\Component\Debug\Exception\FatalThrowableError;
true
Other
laravel
framework
2a6902866e4db7a0de65cbaf33a6cbd20b77834e.json
Apply fixes from StyleCI (#18873)
src/Illuminate/Foundation/Console/QueuedCommand.php
@@ -3,8 +3,8 @@ namespace Illuminate\Foundation\Console; use Illuminate\Bus\Queueable; -use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Contracts\Console\Kernel as KernelContract; class QueuedCommand implements ShouldQueue
true
Other
laravel
framework
51647eb701307e7682f7489b605a146e750abf0f.json
return pending dispatch for artisan::queue
src/Illuminate/Contracts/Console/Kernel.php
@@ -27,7 +27,7 @@ public function call($command, array $parameters = []); * * @param string $command * @param array $parameters - * @return int + * @return \Illuminate\Foundation\Bus\PendingDispatch */ public function queue($command, array $parameters = []);
true
Other
laravel
framework
51647eb701307e7682f7489b605a146e750abf0f.json
return pending dispatch for artisan::queue
src/Illuminate/Foundation/Console/Kernel.php
@@ -226,13 +226,11 @@ public function call($command, array $parameters = [], $outputBuffer = null) * * @param string $command * @param array $parameters - * @return void + * @return \Illuminate\Foundation\Bus\PendingDispatch */ public function queue($command, array $parameters = []) { - $this->app[QueueContract::class]->push( - new QueuedCommand(func_get_args()) - ); + return QueuedCommand::dispatch(func_get_args()); } /**
true
Other
laravel
framework
51647eb701307e7682f7489b605a146e750abf0f.json
return pending dispatch for artisan::queue
src/Illuminate/Foundation/Console/QueuedCommand.php
@@ -2,11 +2,15 @@ namespace Illuminate\Foundation\Console; +use Illuminate\Bus\Queueable; +use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Console\Kernel as KernelContract; class QueuedCommand implements ShouldQueue { + use Dispatchable, Queueable; + /** * The data to pass to the Artisan command. *
true
Other
laravel
framework
17327b7bbe461e7afa6a24436aeeb398cb9c7750.json
add prefix to database queue driver
src/Illuminate/Queue/DatabaseQueue.php
@@ -308,7 +308,7 @@ public function deleteReserved($queue, $id) */ protected function getQueue($queue) { - return $queue ?: $this->default; + return $this->getQueuePrefix().($queue ?: $this->default); } /**
false
Other
laravel
framework
354b5799e35f8ffb4732dcdd8b7bc8d1ef79a6a4.json
Apply fixes from StyleCI (#18853)
tests/Routing/RouteRegistrarTest.php
@@ -322,5 +322,4 @@ public function destroy() class RouteRegistrarMiddlewareStub { - }
false
Other
laravel
framework
92f5f7de3e30affe5ea5468bedd004759f785b48.json
Break long words in emails (#18827)
src/Illuminate/Mail/resources/views/html/themes/default.css
@@ -13,6 +13,12 @@ body { margin: 0; width: 100% !important; -webkit-text-size-adjust: none; + -ms-word-break: break-all; + word-break: break-all; + word-break: break-word; + -webkit-hyphens: auto; + -moz-hyphens: auto; + hyphens: auto; } p,
false
Other
laravel
framework
33c96f9fc254c6422a1ba6762f0b36ba4acd12ff.json
Apply fixes from StyleCI (#18834)
src/Illuminate/Foundation/Console/Presets/Bootstrap.php
@@ -2,9 +2,6 @@ namespace Illuminate\Foundation\Console\Presets; -use Illuminate\Support\Arr; -use Illuminate\Filesystem\Filesystem; - class Bootstrap extends Preset { /**
false
Other
laravel
framework
7d64dee369fcfd9e576ced09a7c666e9827b10c1.json
Replace duplicated method with result (#18828)
src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php
@@ -66,7 +66,7 @@ protected function loadConfigurationFiles(Application $app, RepositoryContract $ throw new Exception('Unable to load the "app" configuration file.'); } - foreach ($this->getConfigurationFiles($app) as $key => $path) { + foreach ($files as $key => $path) { $repository->set($key, require $path); } }
false
Other
laravel
framework
7c283c201d04f3ee949dc89600a5aa0e4bbb80f1.json
Use @isset directive (#18817)
src/Illuminate/Mail/resources/views/html/message.blade.php
@@ -10,13 +10,13 @@ {{ $slot }} {{-- Subcopy --}} - @if (isset($subcopy)) + @isset($subcopy) @slot('subcopy') @component('mail::subcopy') {{ $subcopy }} @endcomponent @endslot - @endif + @endisset {{-- Footer --}} @slot('footer')
true
Other
laravel
framework
7c283c201d04f3ee949dc89600a5aa0e4bbb80f1.json
Use @isset directive (#18817)
src/Illuminate/Mail/resources/views/markdown/layout.blade.php
@@ -1,9 +1,9 @@ {!! strip_tags($header) !!} {!! strip_tags($slot) !!} -@if (isset($subcopy)) +@isset($subcopy) {!! strip_tags($subcopy) !!} -@endif +@endisset {!! strip_tags($footer) !!}
true
Other
laravel
framework
7c283c201d04f3ee949dc89600a5aa0e4bbb80f1.json
Use @isset directive (#18817)
src/Illuminate/Mail/resources/views/markdown/message.blade.php
@@ -10,13 +10,13 @@ {{ $slot }} {{-- Subcopy --}} - @if (isset($subcopy)) + @isset($subcopy) @slot('subcopy') @component('mail::subcopy') {{ $subcopy }} @endcomponent @endslot - @endif + @endisset {{-- Footer --}} @slot('footer')
true
Other
laravel
framework
7c283c201d04f3ee949dc89600a5aa0e4bbb80f1.json
Use @isset directive (#18817)
src/Illuminate/Notifications/resources/views/email.blade.php
@@ -17,7 +17,7 @@ @endforeach {{-- Action Button --}} -@if (isset($actionText)) +@isset($actionText) <?php switch ($level) { case 'success': @@ -33,7 +33,7 @@ @component('mail::button', ['url' => $actionUrl, 'color' => $color]) {{ $actionText }} @endcomponent -@endif +@endisset {{-- Outro Lines --}} @foreach ($outroLines as $line) @@ -49,10 +49,10 @@ @endif <!-- Subcopy --> -@if (isset($actionText)) +@isset($actionText) @component('mail::subcopy') If you’re having trouble clicking the "{{ $actionText }}" button, copy and paste the URL below into your web browser: [{{ $actionUrl }}]({{ $actionUrl }}) @endcomponent -@endif +@endisset @endcomponent
true
Other
laravel
framework
4ee7aa8c1ff3cbea1441ef0b4c2968eaf4a3c0d5.json
Add 'proccessing' message to queue worker output Related to 2328c7a318c22396ea0b99df6c576f8eae7c90e6
src/Illuminate/Queue/Console/WorkCommand.php
@@ -9,6 +9,7 @@ use Illuminate\Queue\WorkerOptions; use Illuminate\Queue\Events\JobFailed; use Illuminate\Queue\Events\JobProcessed; +use Illuminate\Queue\Events\JobProcessing; class WorkCommand extends Command { @@ -122,12 +123,16 @@ protected function gatherWorkerOptions() */ protected function listenForEvents() { + $this->laravel['events']->listen(JobProcessing::class, function ($event) { + $this->writeOutput($event->job, 'starting'); + }); + $this->laravel['events']->listen(JobProcessed::class, function ($event) { - $this->writeOutput($event->job, false); + $this->writeOutput($event->job, 'success'); }); $this->laravel['events']->listen(JobFailed::class, function ($event) { - $this->writeOutput($event->job, true); + $this->writeOutput($event->job, 'failed'); $this->logFailedJob($event); }); @@ -137,15 +142,21 @@ protected function listenForEvents() * Write the status output for the queue worker. * * @param \Illuminate\Contracts\Queue\Job $job - * @param bool $failed + * @param string $status * @return void */ - protected function writeOutput(Job $job, $failed) + protected function writeOutput(Job $job, $status) { - if ($failed) { - $this->output->writeln('<error>['.Carbon::now()->format('Y-m-d H:i:s').'] Failed:</error> '.$job->resolveName()); - } else { - $this->output->writeln('<info>['.Carbon::now()->format('Y-m-d H:i:s').'] Processed:</info> '.$job->resolveName()); + switch ($status) { + case 'starting': + $this->output->writeln('<comment>['.Carbon::now()->format('Y-m-d H:i:s').'] Processing:</comment> '.$job->resolveName()); + break; + case 'success': + $this->output->writeln('<info>['.Carbon::now()->format('Y-m-d H:i:s').'] Processed:</info> '.$job->resolveName()); + break; + case 'failed': + $this->output->writeln('<error>['.Carbon::now()->format('Y-m-d H:i:s').'] Failed:</error> '.$job->resolveName()); + break; } }
false
Other
laravel
framework
7392014bee4601a054f070f95451037d99df4ce7.json
Set connection while retrieving models (#18769)
src/Illuminate/Database/Eloquent/Builder.php
@@ -225,7 +225,9 @@ public function orWhere($column, $operator = null, $value = null) */ public function hydrate(array $items) { - $instance = $this->model->newInstance(); + $instance = $this->model->newInstance()->setConnection( + $this->query->getConnection()->getName() + ); return $instance->newCollection(array_map(function ($item) use ($instance) { return $instance->newFromBuilder($item); @@ -459,8 +461,7 @@ public function get($columns = ['*']) public function getModels($columns = ['*']) { return $this->model->hydrate( - $this->query->get($columns)->all(), - $this->model->getConnectionName() + $this->query->get($columns)->all() )->all(); }
true
Other
laravel
framework
7392014bee4601a054f070f95451037d99df4ce7.json
Set connection while retrieving models (#18769)
tests/Database/DatabaseEloquentBuilderTest.php
@@ -386,11 +386,10 @@ public function testGetModelsProperlyHydratesModels() $records[] = ['name' => 'taylor', 'age' => 26]; $records[] = ['name' => 'dayle', 'age' => 28]; $builder->getQuery()->shouldReceive('get')->once()->with(['foo'])->andReturn(new BaseCollection($records)); - $model = m::mock('Illuminate\Database\Eloquent\Model[getTable,getConnectionName,hydrate]'); + $model = m::mock('Illuminate\Database\Eloquent\Model[getTable,hydrate]'); $model->shouldReceive('getTable')->once()->andReturn('foo_table'); $builder->setModel($model); - $model->shouldReceive('getConnectionName')->once()->andReturn('foo_connection'); - $model->shouldReceive('hydrate')->once()->with($records, 'foo_connection')->andReturn(new Collection(['hydrated'])); + $model->shouldReceive('hydrate')->once()->with($records)->andReturn(new Collection(['hydrated'])); $models = $builder->getModels(['foo']); $this->assertEquals($models, ['hydrated']);
true
Other
laravel
framework
7392014bee4601a054f070f95451037d99df4ce7.json
Set connection while retrieving models (#18769)
tests/Database/DatabaseEloquentIntegrationTest.php
@@ -1061,6 +1061,14 @@ public function testBelongsToManyCustomPivot() $this->assertEquals('Jule Doe', $johnWithFriends->friends->find(4)->pivot->friend->name); } + public function testIsAfterRetrievingTheSameModel() + { + $saved = EloquentTestUser::create(['id' => 1, 'email' => 'taylorotwell@gmail.com']); + $retrieved = EloquentTestUser::find(1); + + $this->assertTrue($saved->is($retrieved)); + } + /** * Helpers... */
true
Other
laravel
framework
398e3f2e8ccd3414e9e3ebc2a733ff1cda0ea375.json
add method for setting middleware to the resource
src/Illuminate/Routing/PendingResourceRegistration.php
@@ -147,4 +147,17 @@ public function parameter($previous, $new) return $this; } + + /** + * Set a middleware to the resource. + * + * @param mixed $middleware + * @return \Illuminate\Routing\PendingResourceRegistration + */ + public function middleware($middleware) + { + $this->options['middleware'] = $middleware; + + return $this; + } }
true
Other
laravel
framework
398e3f2e8ccd3414e9e3ebc2a733ff1cda0ea375.json
add method for setting middleware to the resource
tests/Routing/RouteRegistrarTest.php
@@ -241,6 +241,14 @@ public function testCanOverrideParametersOnRegisteredResource() $this->assertContains('topic', $this->router->getRoutes()->getByName('posts.show')->uri); } + public function testCanSetMiddlewareOnRegisteredResource() + { + $this->router->resource('users', 'Illuminate\Tests\Routing\RouteRegistrarControllerStub') + ->middleware('Illuminate\Tests\Routing\RouteRegistrarMiddlewareStub'); + + $this->seeMiddleware('Illuminate\Tests\Routing\RouteRegistrarMiddlewareStub'); + } + public function testCanSetRouteName() { $this->router->as('users.index')->get('users', function () { @@ -311,3 +319,8 @@ public function destroy() return 'deleted'; } } + +class RouteRegistrarMiddlewareStub +{ + +}
true
Other
laravel
framework
bc115363d9940f10d58cbca2e65bb83027a620eb.json
fix docblocks, remove unnecessary array checks
src/Illuminate/Routing/PendingResourceRegistration.php
@@ -108,18 +108,14 @@ public function names(array $names) } /** - * Set the methods the controller should exclude. + * Set the route name for controller action. * * @param string $method * @param string $name * @return \Illuminate\Routing\PendingResourceRegistration */ public function name($method, $name) { - if (! isset($this->options['names'])) { - $this->options['names'] = []; - } - $this->options['names'][$method] = $name; return $this; @@ -147,10 +143,6 @@ public function parameters(array $parameters) */ public function parameter($previous, $new) { - if (! isset($this->options['parameters'])) { - $this->options['parameters'] = []; - } - $this->options['parameters'][$previous] = $new; return $this;
false
Other
laravel
framework
b226c759a4d208ab2215c4e7bfde7cf8ba98f5ea.json
remove unnecessary import
tests/Routing/RouteRegistrarTest.php
@@ -3,7 +3,6 @@ namespace Illuminate\Tests\Routing; use Mockery as m; -use Illuminate\Support\Str; use Illuminate\Http\Request; use Illuminate\Routing\Router; use PHPUnit\Framework\TestCase;
false
Other
laravel
framework
777fdc46630978a26ddc605d728c4df91a81d920.json
return PendingResourceRegistration when registering resources which registeres them on destruction possibly limiting/excluding methods
src/Illuminate/Routing/PendingResourceRegistration.php
@@ -0,0 +1,90 @@ +<?php + +namespace Illuminate\Routing; + +class PendingResourceRegistration +{ + /** + * The resource name. + * + * @var string + */ + protected $name; + + /** + * The resource controller. + * + * @var string + */ + protected $controller; + + /** + * The resource options. + * + * @var string + */ + protected $options = []; + + /** + * The resource registrar. + * + * @var \Illuminate\Routing\ResourceRegistrar + */ + protected $registrar; + + /** + * Create a new pending resource registration instance. + * + * @param \Illuminate\Routing\ResourceRegistrar $registrar + * @return void + */ + public function __construct(ResourceRegistrar $registrar) + { + $this->registrar = $registrar; + } + + /** + * Handle the object's destruction. + * + * @return void + */ + public function __destruct() + { + $this->registrar->register($this->name, $this->controller, $this->options); + } + + /** + * The name, controller and options to use when ready to register. + * + * @param string $name + * @param string $controller + * @param array $options + * @return void + */ + public function remember($name, $controller, array $options) + { + $this->name = $name; + $this->controller = $controller; + $this->options = $options; + } + + /** + * Set the methods the controller should apply to. + * + * @param array|string|dynamic $methods + */ + public function only($methods) + { + $this->options['only'] = is_array($methods) ? $methods : func_get_args(); + } + + /** + * Set the methods the controller should exclude. + * + * @param array|string|dynamic $methods + */ + public function except($methods) + { + $this->options['except'] = is_array($methods) ? $methods : func_get_args(); + } +}
true
Other
laravel
framework
777fdc46630978a26ddc605d728c4df91a81d920.json
return PendingResourceRegistration when registering resources which registeres them on destruction possibly limiting/excluding methods
src/Illuminate/Routing/ResourceRegistrar.php
@@ -62,6 +62,22 @@ public function __construct(Router $router) $this->router = $router; } + /** + * Route a resource to a controller lazy. + * + * @param string $name + * @param string $controller + * @param array $options + * @return \Illuminate\Routing\PendingResourceRegistration + */ + public function lazy($name, $controller, array $options = []) + { + $registrar = new PendingResourceRegistration($this); + $registrar->remember($name, $controller, $options); + + return $registrar; + } + /** * Route a resource to a controller. *
true
Other
laravel
framework
777fdc46630978a26ddc605d728c4df91a81d920.json
return PendingResourceRegistration when registering resources which registeres them on destruction possibly limiting/excluding methods
src/Illuminate/Routing/RouteRegistrar.php
@@ -86,11 +86,11 @@ public function attribute($key, $value) * @param string $name * @param string $controller * @param array $options - * @return void + * @return \Illuminate\Routing\PendingResourceRegistration */ public function resource($name, $controller, array $options = []) { - $this->router->resource($name, $controller, $this->attributes + $options); + return $this->router->resource($name, $controller, $this->attributes + $options); } /**
true
Other
laravel
framework
777fdc46630978a26ddc605d728c4df91a81d920.json
return PendingResourceRegistration when registering resources which registeres them on destruction possibly limiting/excluding methods
src/Illuminate/Routing/Router.php
@@ -245,7 +245,7 @@ public function resources(array $resources) * @param string $name * @param string $controller * @param array $options - * @return void + * @return \Illuminate\Routing\PendingResourceRegistration */ public function resource($name, $controller, array $options = []) { @@ -255,7 +255,7 @@ public function resource($name, $controller, array $options = []) $registrar = new ResourceRegistrar($this); } - $registrar->register($name, $controller, $options); + return $registrar->lazy($name, $controller, $options); } /**
true
Other
laravel
framework
48cf1e1af27e91a27ed47c6e49905889307c6751.json
Apply fixes from StyleCI (#18762)
src/Illuminate/Foundation/Testing/Concerns/InteractsWithExceptionHandling.php
@@ -39,12 +39,21 @@ protected function withoutExceptionHandling() $this->previousExceptionHandler = app(ExceptionHandler::class); $this->app->instance(ExceptionHandler::class, new class implements ExceptionHandler { - public function __construct() {} - public function report(Exception $e) {} - public function render($request, Exception $e) { + public function __construct() + { + } + + public function report(Exception $e) + { + } + + public function render($request, Exception $e) + { throw $e; } - public function renderForConsole($output, Exception $e) { + + public function renderForConsole($output, Exception $e) + { (new ConsoleApplication)->renderException($e, $output); } });
false
Other
laravel
framework
a171f44594c248afe066fee74fad640765b12da0.json
Add withoutExceptionHandling method for testing.
src/Illuminate/Foundation/Testing/Concerns/InteractsWithExceptionHandling.php
@@ -0,0 +1,54 @@ +<?php + +namespace Illuminate\Foundation\Testing\Concerns; + +use Exception; +use Illuminate\Contracts\Debug\ExceptionHandler; +use Symfony\Component\Console\Application as ConsoleApplication; + +trait InteractsWithExceptionHandling +{ + /** + * The previous exception handler. + * + * @var ExceptionHandler|null + */ + protected $previousExceptionHandler; + + /** + * Restore exception handling. + * + * @return $this + */ + protected function withExceptionHandling() + { + if ($this->previousExceptionHandler) { + $this->app->instance(ExceptionHandler::class, $this->previousExceptionHandler); + } + + return $this; + } + + /** + * Disable exception handling for the test. + * + * @return $this + */ + protected function withoutExceptionHandling() + { + $this->previousExceptionHandler = app(ExceptionHandler::class); + + $this->app->instance(ExceptionHandler::class, new class implements ExceptionHandler { + public function __construct() {} + public function report(Exception $e) {} + public function render($request, Exception $e) { + throw $e; + } + public function renderForConsole($output, Exception $e) { + (new ConsoleApplication)->renderException($e, $output); + } + }); + + return $this; + } +}
true
Other
laravel
framework
a171f44594c248afe066fee74fad640765b12da0.json
Add withoutExceptionHandling method for testing.
src/Illuminate/Foundation/Testing/TestCase.php
@@ -15,6 +15,7 @@ abstract class TestCase extends BaseTestCase Concerns\InteractsWithAuthentication, Concerns\InteractsWithConsole, Concerns\InteractsWithDatabase, + Concerns\InteractsWithExceptionHandling, Concerns\InteractsWithSession, Concerns\MocksApplicationServices;
true
Other
laravel
framework
a513aaa2da69d1d8619c10568b3c13e4e250c825.json
Update AuthenticatesUsers.php (#18746) Additional checking for non string properties
src/Illuminate/Foundation/Auth/AuthenticatesUsers.php
@@ -59,7 +59,8 @@ public function login(Request $request) protected function validateLogin(Request $request) { $this->validate($request, [ - $this->username() => 'required', 'password' => 'required', + $this->username() => 'required|string', + 'password' => 'required|string', ]); }
false
Other
laravel
framework
ceab3cc25cb7257c273b81dbf06f0c4e00fade90.json
Handle case when $this->events is null
src/Illuminate/Mail/Mailer.php
@@ -207,7 +207,9 @@ public function send($view, array $data = [], $callback = null) $this->sendSwiftMessage($message->getSwiftMessage()); - $this->events->dispatch(new Events\MessageSent($message->getSwiftMessage())); + if ($this->events) { + $this->events->dispatch(new Events\MessageSent($message->getSwiftMessage())); + } } /**
false
Other
laravel
framework
134df8712b28fdee7f83d2793dafeb6950b79f39.json
Add @empty Changelog Line (#18743)
CHANGELOG-5.4.md
@@ -8,6 +8,7 @@ - Added support for attaching an image to Slack attachments `$attachment->image($url)`([#18664](https://github.com/laravel/framework/pull/18664)) - Added `Validator::extendDependent()` to allow adding custom rules that depend on other fields ([#18654](https://github.com/laravel/framework/pull/18654)) - Added support for `--parent` option on `make:controller` ([#18606](https://github.com/laravel/framework/pull/18606)) +- Added `@empty()` directive ([#18738](https://github.com/laravel/framework/pull/18738)) ### Fixed - Fixed an issue with `Collection::groupBy()` when the provided value is a boolean ([#18674](https://github.com/laravel/framework/pull/18674))
false
Other
laravel
framework
9a16e9f625e8b31072aaa7cb9a70f0f6e88456f4.json
Trigger new MessageSent event
src/Illuminate/Mail/Events/MessageSent.php
@@ -0,0 +1,24 @@ +<?php + +namespace Illuminate\Mail\Events; + +class MessageSent +{ + /** + * The Swift message instance. + * + * @var \Swift_Message + */ + public $message; + + /** + * Create a new event instance. + * + * @param \Swift_Message $message + * @return void + */ + public function __construct($message) + { + $this->message = $message; + } +}
true
Other
laravel
framework
9a16e9f625e8b31072aaa7cb9a70f0f6e88456f4.json
Trigger new MessageSent event
src/Illuminate/Mail/Mailer.php
@@ -206,6 +206,8 @@ public function send($view, array $data = [], $callback = null) } $this->sendSwiftMessage($message->getSwiftMessage()); + + $this->events->dispatch(new Events\MessageSent($message->getSwiftMessage())); } /**
true
Other
laravel
framework
b27f967b43e9b1bb54fc68bb07e65023e866d0c7.json
Fix job release on exception Without this change the worker does not account for changes to the job state done in the JobExceptionOccurred event listener except for when the job was deleted. If there is a need to release the job back onto the queue with a different delay than the one set on the worker, the job would be released with the worker delay. If the job needs to be failed by the JobExceptionOccurred event listener that is not possible and will be ignored by the worker. A job should not be released back onto the queue if the job has been handled in the JobExceptionOccurred event listener by failing, deleting or releasing it with a specific delay. The event listener should have full controller over what happens with the job for what concerns deleting, failing and deleting the job.
src/Illuminate/Queue/Worker.php
@@ -328,7 +328,9 @@ protected function handleJobException($connectionName, $job, WorkerOptions $opti // If we catch an exception, we will attempt to release the job back onto the queue // so it is not lost entirely. This'll let the job be retried at a later time by // another listener (or this same one). We will re-throw this exception after. - if (! $job->isDeleted()) { + // Do not release the job back onto the queue if the job is either deleted, failed + // or if the job has already been released from the JobExceptionOccurred event listener. + if (! ($job->isReleased() || $job->isDeleted() || $job->hasFailed())) { $job->release($options->delay); } }
true
Other
laravel
framework
b27f967b43e9b1bb54fc68bb07e65023e866d0c7.json
Fix job release on exception Without this change the worker does not account for changes to the job state done in the JobExceptionOccurred event listener except for when the job was deleted. If there is a need to release the job back onto the queue with a different delay than the one set on the worker, the job would be released with the worker delay. If the job needs to be failed by the JobExceptionOccurred event listener that is not possible and will be ignored by the worker. A job should not be released back onto the queue if the job has been handled in the JobExceptionOccurred event listener by failing, deleting or releasing it with a specific delay. The event listener should have full controller over what happens with the job for what concerns deleting, failing and deleting the job.
tests/Queue/QueueWorkerTest.php
@@ -257,9 +257,11 @@ class WorkerFakeJob public $callback; public $deleted = false; public $releaseAfter; + public $released = false; public $maxTries; public $attempts = 0; public $failedWith; + public $failed = false; public $connectionName; public function __construct($callback = null) @@ -296,24 +298,38 @@ public function isDeleted() public function release($delay) { + $this->released = true; + $this->releaseAfter = $delay; } + public function isReleased() + { + return $this->released; + } + public function attempts() { return $this->attempts; } public function markAsFailed() { - // + $this->failed = true; } public function failed($e) { + $this->markAsFailed(); + $this->failedWith = $e; } + public function hasFailed() + { + return $this->failed; + } + public function setConnectionName($name) { $this->connectionName = $name;
true
Other
laravel
framework
f8f2540a575178fbd06cf02865d900f347ee08b2.json
Fix job release on exception Without this change the worker does not account for changes to the job state done in the JobExceptionOccurred event listener except for when the job was deleted. If there is a need to release the job back onto the queue with a different delay than the one set on the worker, the job would be released with the worker delay. If the job needs to be failed by the JobExceptionOccurred event listener that is not possible and will be ignored by the worker. A job should not be released back onto the queue if the job has been handled in the JobExceptionOccurred event listener by failing, deleting or releasing it with a specific delay. The event listener should have full controller over what happens with the job for what concerns deleting, failing and deleting the job.
src/Illuminate/Queue/Worker.php
@@ -328,7 +328,9 @@ protected function handleJobException($connectionName, $job, WorkerOptions $opti // If we catch an exception, we will attempt to release the job back onto the queue // so it is not lost entirely. This'll let the job be retried at a later time by // another listener (or this same one). We will re-throw this exception after. - if (! $job->isDeleted()) { + // Do not release the job back onto the queue if the job is either deleted, failed + // or if the job has already been released from the JobExceptionOccurred event listener. + if (! ($job->isReleased() || $job->isDeleted() || $job->hasFailed())) { $job->release($options->delay); } }
true
Other
laravel
framework
f8f2540a575178fbd06cf02865d900f347ee08b2.json
Fix job release on exception Without this change the worker does not account for changes to the job state done in the JobExceptionOccurred event listener except for when the job was deleted. If there is a need to release the job back onto the queue with a different delay than the one set on the worker, the job would be released with the worker delay. If the job needs to be failed by the JobExceptionOccurred event listener that is not possible and will be ignored by the worker. A job should not be released back onto the queue if the job has been handled in the JobExceptionOccurred event listener by failing, deleting or releasing it with a specific delay. The event listener should have full controller over what happens with the job for what concerns deleting, failing and deleting the job.
tests/Queue/QueueWorkerTest.php
@@ -257,9 +257,11 @@ class WorkerFakeJob public $callback; public $deleted = false; public $releaseAfter; + public $released = false; public $maxTries; public $attempts = 0; public $failedWith; + public $failed = false; public $connectionName; public function __construct($callback = null) @@ -296,24 +298,38 @@ public function isDeleted() public function release($delay) { + $this->released = true; + $this->releaseAfter = $delay; } + public function isReleased() + { + return $this->released; + } + public function attempts() { return $this->attempts; } public function markAsFailed() { - // + $this->failed = true; } public function failed($e) { + $this->markAsFailed(); + $this->failedWith = $e; } + public function hasFailed() + { + return $this->failed; + } + public function setConnectionName($name) { $this->connectionName = $name;
true
Other
laravel
framework
7b33de43808f2f9f6c199c30e5ebffbb76362c22.json
fix typo and use local variable
tests/Foundation/FoundationExceptionsHandlerTest.php
@@ -18,7 +18,7 @@ class FoundationExceptionsHandlerTest extends TestCase protected $handler; - protected $rquest; + protected $request; public function setUp() {
false
Other
laravel
framework
4a4a6f6a79fdb3a29445dd8b0614f59bdd1e833c.json
remove unused class from test
tests/Foundation/FoundationExceptionsHandlerTest.php
@@ -6,7 +6,6 @@ use Mockery as m; use PHPUnit\Framework\TestCase; use Illuminate\Container\Container; -use Illuminate\Foundation\Application; use Illuminate\Config\Repository as Config; use Illuminate\Foundation\Exceptions\Handler; @@ -87,5 +86,4 @@ public function testReturnsJsonWithoutStackTraceWhenAjaxRequestAndDebugFalse() $this->assertNotContains('"line"', $response); $this->assertNotContains('"trace"', $response); } - }
false
Other
laravel
framework
786b7821e0009a4288bff032443f2b1a273ee459.json
adjust test response
src/Illuminate/Foundation/Testing/TestResponse.php
@@ -289,11 +289,10 @@ public function assertExactJson(array $data) /** * Assert that the response contains the given JSON fragment. * - * @param array $data - * @param bool $negate + * @param array $data * @return $this */ - public function assertJsonFragment(array $data, $negate = false) + public function assertJsonFragment(array $data) { $actual = json_encode(Arr::sortRecursive( (array) $this->decodeResponseJson() @@ -302,23 +301,13 @@ public function assertJsonFragment(array $data, $negate = false) foreach (Arr::sortRecursive($data) as $key => $value) { $expected = substr(json_encode([$key => $value]), 1, -1); - if ($negate) { - PHPUnit::assertFalse( - Str::contains($actual, $expected), - 'Found unexpected JSON fragment: '.PHP_EOL.PHP_EOL. - "[{$expected}]".PHP_EOL.PHP_EOL. - 'within'.PHP_EOL.PHP_EOL. - "[{$actual}]." - ); - } else { - PHPUnit::assertTrue( - Str::contains($actual, $expected), - 'Unable to find JSON fragment: '.PHP_EOL.PHP_EOL. - "[{$expected}]".PHP_EOL.PHP_EOL. - 'within'.PHP_EOL.PHP_EOL. - "[{$actual}]." - ); - } + PHPUnit::assertTrue( + Str::contains($actual, $expected), + 'Unable to find JSON fragment: '.PHP_EOL.PHP_EOL. + "[{$expected}]".PHP_EOL.PHP_EOL. + 'within'.PHP_EOL.PHP_EOL. + "[{$actual}]." + ); } return $this; @@ -330,9 +319,23 @@ public function assertJsonFragment(array $data, $negate = false) * @param array $data * @return $this */ - public function assertJsonFragmentMissing(array $data) + public function assertJsonMissing(array $data) { - $this->assertJsonFragment($data, true); + $actual = json_encode(Arr::sortRecursive( + (array) $this->decodeResponseJson() + )); + + foreach (Arr::sortRecursive($data) as $key => $value) { + $expected = substr(json_encode([$key => $value]), 1, -1); + + PHPUnit::assertFalse( + Str::contains($actual, $expected), + 'Found unexpected JSON fragment: '.PHP_EOL.PHP_EOL. + "[{$expected}]".PHP_EOL.PHP_EOL. + 'within'.PHP_EOL.PHP_EOL. + "[{$actual}]." + ); + } return $this; }
false
Other
laravel
framework
42255bedff7637bcf3c2ee1b60c613ef3cbf8888.json
add exists as alias to has
src/Illuminate/Http/Concerns/InteractsWithInput.php
@@ -59,6 +59,17 @@ public function bearerToken() } } + /** + * Determine if the request contains a given input item key. + * + * @param string|array $key + * @return bool + */ + public function exists($key) + { + return $this->has($key); + } + /** * Determine if the request contains a given input item key. *
false
Other
laravel
framework
183bf16a2c939889f4461e237a851b55cf858f8e.json
add exists as alias to has
src/Illuminate/Http/Concerns/InteractsWithInput.php
@@ -58,6 +58,17 @@ public function bearerToken() } } + /** + * Determine if the request contains a given input item key. + * + * @param string|array $key + * @return bool + */ + public function exists($key) + { + return $this->has($key); + } + /** * Determine if the request contains a given input item key. *
false
Other
laravel
framework
e9c65cdd243d802784b193595227bfa29147f367.json
Apply fixes from StyleCI (#18709)
src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php
@@ -10,8 +10,8 @@ use Illuminate\Auth\Console\ClearResetsCommand; use Illuminate\Cache\Console\CacheTableCommand; use Illuminate\Foundation\Console\ServeCommand; -use Illuminate\Queue\Console\FailedTableCommand; use Illuminate\Foundation\Console\PresetCommand; +use Illuminate\Queue\Console\FailedTableCommand; use Illuminate\Foundation\Console\AppNameCommand; use Illuminate\Foundation\Console\JobMakeCommand; use Illuminate\Database\Console\Seeds\SeedCommand;
false
Other
laravel
framework
5801d6da046fde63bfc2db70a9ea0efb5f91e311.json
add bootstrap preset
src/Illuminate/Foundation/Console/PresetCommand.php
@@ -12,7 +12,7 @@ class PresetCommand extends Command * * @var string */ - protected $signature = 'preset { type : The preset type (fresh, react) }'; + protected $signature = 'preset { type : The preset type (fresh, bootstrap, react) }'; /** * The console command description. @@ -28,7 +28,7 @@ class PresetCommand extends Command */ public function handle() { - if (! in_array($this->argument('type'), ['fresh', 'react'])) { + if (! in_array($this->argument('type'), ['fresh', 'bootstrap', 'react'])) { throw new InvalidArgumentException('Invalid preset.'); } @@ -47,6 +47,19 @@ protected function fresh() $this->info('Front-end scaffolding removed successfully.'); } + /** + * Install the "fresh" preset. + * + * @return void + */ + protected function bootstrap() + { + Presets\Bootstrap::install(); + + $this->info('Bootstrap scaffolding installed successfully.'); + $this->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); + } + /** * Install the "react" preset. * @@ -57,6 +70,6 @@ public function react() Presets\React::install(); $this->info('React scaffolding installed successfully.'); - $this->comment('Run "npm install && npm run dev" to compile your fresh scaffolding.'); + $this->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); } }
true
Other
laravel
framework
5801d6da046fde63bfc2db70a9ea0efb5f91e311.json
add bootstrap preset
src/Illuminate/Foundation/Console/Presets/Bootstrap.php
@@ -0,0 +1,94 @@ +<?php + +namespace Illuminate\Foundation\Console\Presets; + +use Illuminate\Support\Arr; +use Illuminate\Filesystem\Filesystem; + +class Bootstrap +{ + /** + * Install the preset. + * + * @return void + */ + public static function install() + { + static::updatePackages(); + static::updateBootstrapping(); + static::removeComponent(); + static::removeNodeModules(); + } + + /** + * Update the "package.json" file. + * + * @return void + */ + protected static function updatePackages() + { + if (! file_exists(base_path('package.json'))) { + return; + } + + $packages = json_decode(file_get_contents(base_path('package.json')), true); + + $packages['devDependencies'] = static::updatePackageArray( + $packages['devDependencies'] + ); + + file_put_contents( + base_path('package.json'), + json_encode($packages, JSON_PRETTY_PRINT) + ); + } + + /** + * Update the given package array. + * + * @param array $packages + * @return array + */ + protected static function updatePackageArray(array $packages) + { + return Arr::except($packages, ['vue']); + } + + /** + * Update the example component. + * + * @return void + */ + protected static function removeComponent() + { + (new Filesystem)->deleteDirectory( + resource_path('assets/js/components') + ); + } + + /** + * Update the bootstrapping files. + * + * @return void + */ + protected static function updateBootstrapping() + { + copy(__DIR__.'/bootstrap-stubs/app.js', resource_path('assets/js/app.js')); + + copy(__DIR__.'/bootstrap-stubs/bootstrap.js', resource_path('assets/js/bootstrap.js')); + } + + /** + * Remove the installed Node modules. + * + * @return void + */ + protected static function removeNodeModules() + { + tap(new Filesystem, function ($files) { + $files->deleteDirectory(base_path('node_modules')); + + $files->delete(base_path('yarn.lock')); + }); + } +}
true
Other
laravel
framework
5801d6da046fde63bfc2db70a9ea0efb5f91e311.json
add bootstrap preset
src/Illuminate/Foundation/Console/Presets/React.php
@@ -33,13 +33,9 @@ protected static function updatePackages() $packages = json_decode(file_get_contents(base_path('package.json')), true); - unset($packages['devDependencies']['vue']); - - $packages['devDependencies'] += [ - 'babel-preset-react' => '^6.23.0', - 'react' => '^15.4.2', - 'react-dom' => '^15.4.2', - ]; + $packages['devDependencies'] = static::updatePackageArray( + $packages['devDependencies'] + ); ksort($packages['devDependencies']); @@ -49,6 +45,23 @@ protected static function updatePackages() ); } + /** + * Update the given package array. + * + * @param array $packages + * @return array + */ + protected static function updatePackageArray(array $packages) + { + unset($packages['vue']); + + return $packages += [ + 'babel-preset-react' => '^6.23.0', + 'react' => '^15.4.2', + 'react-dom' => '^15.4.2', + ]; + } + /** * Update the Webpack configuration. *
true
Other
laravel
framework
5801d6da046fde63bfc2db70a9ea0efb5f91e311.json
add bootstrap preset
src/Illuminate/Foundation/Console/Presets/bootstrap-stubs/app.js
@@ -0,0 +1,8 @@ + +/** + * First we will load all of this project's JavaScript dependencies which + * includes jQuery and other helpers. It's a great starting point when + * building simple applications where you don't need any complexity. + */ + +require('./bootstrap');
true
Other
laravel
framework
5801d6da046fde63bfc2db70a9ea0efb5f91e311.json
add bootstrap preset
src/Illuminate/Foundation/Console/Presets/bootstrap-stubs/bootstrap.js
@@ -0,0 +1,40 @@ + +window._ = require('lodash'); + +/** + * We'll load jQuery and the Bootstrap jQuery plugin which provides support + * for JavaScript based Bootstrap features such as modals and tabs. This + * code may be modified to fit the specific needs of your application. + */ + +window.$ = window.jQuery = require('jquery'); + +require('bootstrap-sass'); + +/** + * We'll load the axios HTTP library which allows us to easily issue requests + * to our Laravel back-end. This library automatically handles sending the + * CSRF token as a header based on the value of the "XSRF" token cookie. + */ + +window.axios = require('axios'); + +window.axios.defaults.headers.common = { + 'X-CSRF-TOKEN': window.Laravel.csrfToken, + 'X-Requested-With': 'XMLHttpRequest' +}; + +/** + * Echo exposes an expressive API for subscribing to channels and listening + * for events that are broadcast by Laravel. Echo and event broadcasting + * allows your team to easily build robust real-time web applications. + */ + +// import Echo from 'laravel-echo' + +// window.Pusher = require('pusher-js'); + +// window.Echo = new Echo({ +// broadcaster: 'pusher', +// key: 'your-pusher-key' +// });
true
Other
laravel
framework
5801d6da046fde63bfc2db70a9ea0efb5f91e311.json
add bootstrap preset
src/Illuminate/Foundation/Console/Presets/react-stubs/app.js
@@ -1,8 +1,8 @@ /** * First we will load all of this project's JavaScript dependencies which - * includes Vue and other libraries. It is a great starting point when - * building robust, powerful web applications using Vue and Laravel. + * includes React and other helpers. It's a great starting point while + * building robust, powerful web applications using React + Laravel. */ require('./bootstrap');
true
Other
laravel
framework
1d0fbe64e75ebedd3410f279fc120ab9281e17d0.json
Apply fixes from StyleCI (#18677)
src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php
@@ -55,8 +55,8 @@ use Illuminate\Queue\Console\ListFailedCommand as ListFailedQueueCommand; use Illuminate\Queue\Console\FlushFailedCommand as FlushFailedQueueCommand; use Illuminate\Queue\Console\ForgetFailedCommand as ForgetFailedQueueCommand; -use Illuminate\Database\Console\Migrations\ResetCommand as MigrateResetCommand; use Illuminate\Database\Console\Migrations\FreshCommand as MigrateFreshCommand; +use Illuminate\Database\Console\Migrations\ResetCommand as MigrateResetCommand; use Illuminate\Database\Console\Migrations\StatusCommand as MigrateStatusCommand; use Illuminate\Database\Console\Migrations\InstallCommand as MigrateInstallCommand; use Illuminate\Database\Console\Migrations\RefreshCommand as MigrateRefreshCommand;
false
Other
laravel
framework
f6511d477f73b3033ef2336257f4cac5f20594a0.json
add migrate:fresh command
src/Illuminate/Database/Console/Migrations/FreshCommand.php
@@ -0,0 +1,110 @@ +<?php + +namespace Illuminate\Database\Console\Migrations; + +use Illuminate\Console\Command; +use Illuminate\Console\ConfirmableTrait; +use Symfony\Component\Console\Input\InputOption; + +class FreshCommand extends Command +{ + use ConfirmableTrait; + + /** + * The console command name. + * + * @var string + */ + protected $name = 'migrate:fresh'; + + /** + * The console command description. + * + * @var string + */ + protected $description = 'Drop all tables and re-run all migrations'; + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + if (! $this->confirmToProceed()) { + return; + } + + $this->dropAllTables( + $database = $this->input->getOption('database') + ); + + $this->call('migrate', [ + '--database' => $database, + '--path' => $this->input->getOption('path'), + '--force' => $this->input->getOption('force'), + ]); + + if ($this->needsSeeding()) { + $this->runSeeder($database); + } + } + + /** + * Drop all of the database tables. + * + * @param string $database + * @return void + */ + protected function dropAllTables($database) + { + $this->laravel['db']->connection($database) + ->getSchemaBuilder() + ->dropAllTables(); + } + + /** + * Determine if the developer has requested database seeding. + * + * @return bool + */ + protected function needsSeeding() + { + return $this->option('seed') || $this->option('seeder'); + } + + /** + * Run the database seeder command. + * + * @param string $database + * @return void + */ + protected function runSeeder($database) + { + $this->call('db:seed', [ + '--database' => $database, + '--class' => $this->option('seeder') ?: 'DatabaseSeeder', + '--force' => $this->option('force'), + ]); + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return [ + ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'], + + ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], + + ['path', null, InputOption::VALUE_OPTIONAL, 'The path of migrations files to be executed.'], + + ['seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'], + + ['seeder', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder.'], + ]; + } +}
true
Other
laravel
framework
f6511d477f73b3033ef2336257f4cac5f20594a0.json
add migrate:fresh command
src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php
@@ -56,6 +56,7 @@ use Illuminate\Queue\Console\FlushFailedCommand as FlushFailedQueueCommand; use Illuminate\Queue\Console\ForgetFailedCommand as ForgetFailedQueueCommand; use Illuminate\Database\Console\Migrations\ResetCommand as MigrateResetCommand; +use Illuminate\Database\Console\Migrations\FreshCommand as MigrateFreshCommand; use Illuminate\Database\Console\Migrations\StatusCommand as MigrateStatusCommand; use Illuminate\Database\Console\Migrations\InstallCommand as MigrateInstallCommand; use Illuminate\Database\Console\Migrations\RefreshCommand as MigrateRefreshCommand; @@ -86,6 +87,7 @@ class ArtisanServiceProvider extends ServiceProvider 'Environment' => 'command.environment', 'KeyGenerate' => 'command.key.generate', 'Migrate' => 'command.migrate', + 'MigrateFresh' => 'command.migrate.fresh', 'MigrateInstall' => 'command.migrate.install', 'MigrateRefresh' => 'command.migrate.refresh', 'MigrateReset' => 'command.migrate.reset', @@ -422,6 +424,18 @@ protected function registerMigrateCommand() }); } + /** + * Register the command. + * + * @return void + */ + protected function registerMigrateFreshCommand() + { + $this->app->singleton('command.migrate.fresh', function () { + return new MigrateFreshCommand; + }); + } + /** * Register the command. *
true
Other
laravel
framework
bc91b6c997491e029c0d9bb1828cbe89d66f76ff.json
Remove unused import
src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php
@@ -2,7 +2,6 @@ namespace Illuminate\Foundation\Testing\Concerns; -use Illuminate\Http\Testing\NullMiddleware; use Illuminate\Support\Str; use Illuminate\Http\Request; use Illuminate\Foundation\Testing\TestResponse;
false
Other
laravel
framework
3879cb699f26136e227f61595c631112a050438b.json
Allow disabling of specific Middleware in tests
src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php
@@ -2,6 +2,7 @@ namespace Illuminate\Foundation\Testing\Concerns; +use Illuminate\Http\Testing\NullMiddleware; use Illuminate\Support\Str; use Illuminate\Http\Request; use Illuminate\Foundation\Testing\TestResponse; @@ -34,11 +35,26 @@ protected function withServerVariables(array $server) /** * Disable middleware for the test. * + * @param string|array $middleware * @return $this */ - public function withoutMiddleware() + public function withoutMiddleware($middleware = null) { - $this->app->instance('middleware.disable', true); + if (is_null($middleware)) { + $this->app->instance('middleware.disable', true); + + return $this; + } + + $nullMiddleware = new class { + public function handle($request, $next) { + return $next($request); + } + }; + + foreach ((array) $middleware as $abstract) { + $this->app->instance($abstract, $nullMiddleware); + } return $this; }
false
Other
laravel
framework
52664a9a7b9fcafff76b285aaaa0c156eaf72441.json
Simplify email check (#18637)
src/Illuminate/Foundation/Exceptions/Handler.php
@@ -112,8 +112,7 @@ protected function context() { return array_filter([ 'userId' => Auth::id(), - 'email' => Auth::check() && isset(Auth::user()->email) - ? Auth::user()->email : null, + 'email' => Auth::user()->email ?? null, ]); }
false
Other
laravel
framework
23b7d6b45c675bcd93e9f1fb9cd33e71779142c6.json
Add some default context to logs if we know it. If we know the user ID and email, add it to the log context for easier searching for a given users error.
src/Illuminate/Foundation/Exceptions/Handler.php
@@ -6,6 +6,7 @@ use Psr\Log\LoggerInterface; use Illuminate\Http\Response; use Illuminate\Routing\Router; +use Illuminate\Support\Facades\Auth; use Illuminate\Http\RedirectResponse; use Illuminate\Auth\AuthenticationException; use Illuminate\Contracts\Container\Container; @@ -69,7 +70,7 @@ public function report(Exception $e) throw $e; // throw the original exception } - $logger->error($e); + $logger->error($e, $this->context()); } /** @@ -98,6 +99,20 @@ protected function shouldntReport(Exception $e) })); } + /** + * Get the default context variables for logging. + * + * @return array + */ + protected function context() + { + return array_filter([ + 'userId' => Auth::id(), + 'email' => Auth::check() && isset(Auth::user()->email) + ? Auth::user()->email : null, + ]); + } + /** * Render an exception into a response. *
false
Other
laravel
framework
c1a33b865d009b2aec4d8b174db30d4bb68e95a0.json
Apply fixes from StyleCI (#18623)
src/Illuminate/Foundation/Exceptions/Handler.php
@@ -210,7 +210,7 @@ protected function prepareJsonResponse($request, Exception $e) 'line' => $e->getLine(), 'trace' => $e->getTrace(), ], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), $status, array_merge($headers, [ - 'Content-Type' => 'application/json' + 'Content-Type' => 'application/json', ])); }
false
Other
laravel
framework
5225389dfdf03d656b862bba59cebf1820e0e8f4.json
Send JSON in debug mode if the request wants JSON. Currently, when making AJAX requests with debug mode enabled, uncaught exceptions will display the full debug HTML page. With this change, the exceptions will be rendered as JSON for easier viewing in the console / dev tools.
src/Illuminate/Foundation/Exceptions/Handler.php
@@ -121,6 +121,10 @@ public function render($request, Exception $e) return $this->convertValidationExceptionToResponse($e, $request); } + if ($request->expectsJson() && config('app.debug')) { + return $this->prepareJsonResponse($request, $e); + } + return $this->prepareResponse($request, $e); } @@ -166,7 +170,7 @@ protected function convertValidationExceptionToResponse(ValidationException $e, } /** - * Prepare response containing exception render. + * Prepare a response for the given exception. * * @param \Illuminate\Http\Request $request * @param \Exception $e @@ -178,14 +182,38 @@ protected function prepareResponse($request, Exception $e) return $this->toIlluminateResponse($this->convertExceptionToResponse($e), $e); } - $e = $this->isHttpException($e) - ? $e : new HttpException(500, $e->getMessage()); + if (! $this->isHttpException($e)) { + $e = new HttpException(500, $e->getMessage()); + } return $this->toIlluminateResponse( $this->renderHttpException($e), $e ); } + /** + * Prepare a JSON response for the given exception. + * + * @param \Illuminate\Http\Request $request + * @param \Exception $e + * @return \Symfony\Component\HttpFoundation\Response + */ + protected function prepareJsonResponse($request, Exception $e) + { + $status = $this->isHttpException($e) ? $e->getStatusCode() : 500; + + $headers = $this->isHttpException($e) ? $e->getHeaders() : []; + + return response(json_encode([ + 'message' => $e->getMessage(), + 'file' => $e->getFile(), + 'line' => $e->getLine(), + 'trace' => $e->getTrace(), + ], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), $status, array_merge($headers, [ + 'Content-Type' => 'application/json' + ])); + } + /** * Render the given HttpException. *
false
Other
laravel
framework
a1226cb5ad3b4fae45b8d20d4f8d9275c759b7d2.json
Apply fixes from StyleCI (#18616)
tests/Integration/Queue/JobChainingTest.php
@@ -21,7 +21,7 @@ public function tearDown() public function test_jobs_can_be_chained_on_success() { JobChainingTestFirstJob::dispatch()->chain([ - new JobChainingTestSecondJob + new JobChainingTestSecondJob, ]); $this->assertTrue(JobChainingTestFirstJob::$ran); @@ -31,7 +31,7 @@ public function test_jobs_can_be_chained_on_success() public function test_jobs_can_be_chained_via_queue() { Queue::connection('sync')->push((new JobChainingTestFirstJob)->chain([ - new JobChainingTestSecondJob + new JobChainingTestSecondJob, ])); $this->assertTrue(JobChainingTestFirstJob::$ran); @@ -41,7 +41,7 @@ public function test_jobs_can_be_chained_via_queue() public function test_second_job_is_not_fired_if_first_was_already_deleted() { Queue::connection('sync')->push((new JobChainingTestFailingJob)->chain([ - new JobChainingTestSecondJob + new JobChainingTestSecondJob, ])); $this->assertFalse(JobChainingTestSecondJob::$ran);
false
Other
laravel
framework
96ebdd6aed761d83eeedfb3e7bf11ed5aa5cc0ff.json
Apply fixes from StyleCI (#18615)
tests/Integration/Queue/JobChainingTest.php
@@ -4,8 +4,8 @@ use Orchestra\Testbench\TestCase; use Illuminate\Support\Facades\Queue; use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Foundation\Bus\Dispatchable; /** * @group integration @@ -18,40 +18,36 @@ public function tearDown() JobChainingTestSecondJob::$ran = false; } - public function test_jobs_can_be_chained_on_success() { JobChainingTestFirstJob::dispatch()->then([ - new JobChainingTestSecondJob + new JobChainingTestSecondJob, ]); $this->assertTrue(JobChainingTestFirstJob::$ran); $this->assertTrue(JobChainingTestSecondJob::$ran); } - public function test_jobs_can_be_chained_via_queue() { Queue::connection('sync')->push((new JobChainingTestFirstJob)->then([ - new JobChainingTestSecondJob + new JobChainingTestSecondJob, ])); $this->assertTrue(JobChainingTestFirstJob::$ran); $this->assertTrue(JobChainingTestSecondJob::$ran); } - public function test_second_job_is_not_fired_if_first_was_already_deleted() { Queue::connection('sync')->push((new JobChainingTestFailingJob)->then([ - new JobChainingTestSecondJob + new JobChainingTestSecondJob, ])); $this->assertFalse(JobChainingTestSecondJob::$ran); } } - class JobChainingTestFirstJob implements ShouldQueue { use Dispatchable, Queueable; @@ -64,7 +60,6 @@ public function handle() } } - class JobChainingTestSecondJob implements ShouldQueue { use Dispatchable, Queueable; @@ -77,7 +72,6 @@ public function handle() } } - class JobChainingTestFailingJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable;
false
Other
laravel
framework
7120eed7f516d50f621be87c85bf4d2c82fee24c.json
Add additional test for chaining. This adds an additional test to make sure the second job is not fired if the first fails or is deleted.
tests/Integration/Queue/JobChainingTest.php
@@ -2,6 +2,8 @@ use Illuminate\Bus\Queueable; use Orchestra\Testbench\TestCase; +use Illuminate\Support\Facades\Queue; +use Illuminate\Queue\InteractsWithQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Contracts\Queue\ShouldQueue; @@ -26,6 +28,27 @@ public function test_jobs_can_be_chained_on_success() $this->assertTrue(JobChainingTestFirstJob::$ran); $this->assertTrue(JobChainingTestSecondJob::$ran); } + + + public function test_jobs_can_be_chained_via_queue() + { + Queue::connection('sync')->push((new JobChainingTestFirstJob)->then([ + new JobChainingTestSecondJob + ])); + + $this->assertTrue(JobChainingTestFirstJob::$ran); + $this->assertTrue(JobChainingTestSecondJob::$ran); + } + + + public function test_second_job_is_not_fired_if_first_was_already_deleted() + { + Queue::connection('sync')->push((new JobChainingTestFailingJob)->then([ + new JobChainingTestSecondJob + ])); + + $this->assertFalse(JobChainingTestSecondJob::$ran); + } } @@ -53,3 +76,14 @@ public function handle() static::$ran = true; } } + + +class JobChainingTestFailingJob implements ShouldQueue +{ + use Dispatchable, InteractsWithQueue, Queueable; + + public function handle() + { + $this->fail(); + } +}
false
Other
laravel
framework
9ae1993b124dd1a63a51939486a1a41d6ca30bea.json
remove tests that seem really strange and broken.
tests/Support/SupportCollectionTest.php
@@ -227,15 +227,6 @@ public function testArrayAccessOffsetGet() $this->assertEquals('bar', $c->offsetGet(1)); } - /** - * @expectedException \PHPUnit\Framework\Error\Notice - */ - public function testArrayAccessOffsetGetOnNonExist() - { - $c = new Collection(['foo', 'bar']); - $c->offsetGet(1000); - } - public function testArrayAccessOffsetSet() { $c = new Collection(['foo', 'foo']); @@ -247,15 +238,12 @@ public function testArrayAccessOffsetSet() $this->assertEquals('qux', $c[2]); } - /** - * @expectedException \PHPUnit\Framework\Error\Notice - */ public function testArrayAccessOffsetUnset() { $c = new Collection(['foo', 'bar']); $c->offsetUnset(1); - $c[1]; + $this->assertFalse(isset($c[1])); } public function testForgetSingleKey()
false
Other
laravel
framework
458e66e7e5e659f6a27aec7c907be97946a11679.json
Apply fixes from StyleCI (#18612)
tests/Database/DatabaseConnectionFactoryTest.php
@@ -6,7 +6,6 @@ use ReflectionProperty; use InvalidArgumentException; use PHPUnit\Framework\TestCase; -use Illuminate\Database\Connection; use Illuminate\Database\Capsule\Manager as DB; use Illuminate\Database\Connectors\ConnectionFactory;
false
Other
laravel
framework
d5a71bad602e45e54aef2c15e1cb1b8c20c46535.json
Apply fixes from StyleCI (#18611)
tests/Pagination/LengthAwarePaginatorTest.php
@@ -36,13 +36,13 @@ public function testLengthAwarePaginatorCanGiveMeRelevantPageInformation() public function testLengthAwarePaginatorCanGenerateUrls() { - $this->p->setPath('http://website.com'); - $this->p->setPageName('foo'); + $this->p->setPath('http://website.com'); + $this->p->setPageName('foo'); $this->assertEquals('http://website.com?foo=2', $this->p->url($this->p->currentPage())); - $this->assertEquals('http://website.com?foo=1', + $this->assertEquals('http://website.com?foo=1', $this->p->url($this->p->currentPage() - 1)); $this->assertEquals('http://website.com?foo=1', @@ -53,23 +53,23 @@ public function testLengthAwarePaginatorCanGenerateUrlsWithQuery() { $this->p->setPath('http://website.com?sort_by=date'); $this->p->setPageName('foo'); - - $this->assertEquals('http://website.com?sort_by=date&foo=2', + + $this->assertEquals('http://website.com?sort_by=date&foo=2', $this->p->url($this->p->currentPage())); } public function testLengthAwarePaginatorCanGenerateUrlsWithoutTrailingSlashes() { $this->p->setPath('http://website.com/test'); $this->p->setPageName('foo'); - - $this->assertEquals('http://website.com/test?foo=2', + + $this->assertEquals('http://website.com/test?foo=2', $this->p->url($this->p->currentPage())); - $this->assertEquals('http://website.com/test?foo=1', + $this->assertEquals('http://website.com/test?foo=1', $this->p->url($this->p->currentPage() - 1)); - $this->assertEquals('http://website.com/test?foo=1', + $this->assertEquals('http://website.com/test?foo=1', $this->p->url($this->p->currentPage() - 2)); } }
true
Other
laravel
framework
d5a71bad602e45e54aef2c15e1cb1b8c20c46535.json
Apply fixes from StyleCI (#18611)
tests/Pagination/PaginatorTest.php
@@ -15,32 +15,32 @@ public function testSimplePaginatorReturnsRelevantContextInformation() $this->assertTrue($p->hasPages()); $this->assertTrue($p->hasMorePages()); $this->assertEquals(['item3', 'item4'], $p->items()); - + $pageInfo = [ - 'per_page' => 2, - 'current_page' => 2, - 'next_page_url' => '/?page=3', - 'prev_page_url' => '/?page=1', - 'from' => 3, - 'to' => 4, - 'data' => ['item3', 'item4'], - ]; + 'per_page' => 2, + 'current_page' => 2, + 'next_page_url' => '/?page=3', + 'prev_page_url' => '/?page=1', + 'from' => 3, + 'to' => 4, + 'data' => ['item3', 'item4'], + ]; $this->assertEquals($pageInfo, $p->toArray()); } public function testPaginatorRemovesTrailingSlashes() { - $p = new Paginator($array = ['item1', 'item2', 'item3'], 2, 2, - ['path' => 'http://website.com/test/']); + $p = new Paginator($array = ['item1', 'item2', 'item3'], 2, 2, + ['path' => 'http://website.com/test/']); $this->assertEquals('http://website.com/test?page=1', $p->previousPageUrl()); } public function testPaginatorGeneratesUrlsWithoutTrailingSlash() { - $p = new Paginator($array = ['item1', 'item2', 'item3'], 2, 2, - ['path' => 'http://website.com/test']); + $p = new Paginator($array = ['item1', 'item2', 'item3'], 2, 2, + ['path' => 'http://website.com/test']); $this->assertEquals('http://website.com/test?page=1', $p->previousPageUrl()); }
true
Other
laravel
framework
d5a71bad602e45e54aef2c15e1cb1b8c20c46535.json
Apply fixes from StyleCI (#18611)
tests/Pagination/UrlWindowTest.php
@@ -3,8 +3,8 @@ namespace Illuminate\Tests\Pagination; use PHPUnit\Framework\TestCase; -use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\UrlWindow; +use Illuminate\Pagination\LengthAwarePaginator; class UrlWindowTest extends TestCase { @@ -36,7 +36,7 @@ public function testPresenterCanGetAUrlRangeForAWindowOfLinks() } $this->assertEquals(['first' => [1 => '/?page=1', 2 => '/?page=2'], 'slider' => $slider, 'last' => [12 => '/?page=12', 13 => '/?page=13']], $window->get()); - + /* * Test Being Near The End Of The List */ @@ -46,7 +46,7 @@ public function testPresenterCanGetAUrlRangeForAWindowOfLinks() for ($i = 5; $i <= 13; $i++) { $last[$i] = '/?page='.$i; } - + $this->assertEquals(['first' => [1 => '/?page=1', 2 => '/?page=2'], 'slider' => null, 'last' => $last], $window->get()); } }
true
Other
laravel
framework
f55331d0f47415e4da6d6bf0fc0f1f4f950acd60.json
add postgres table escaping and regression test
src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
@@ -159,7 +159,7 @@ public function compileDropIfExists(Blueprint $blueprint, Fluent $command) */ public function compileDropAllTables($tables) { - return 'drop table '.implode(',', $tables).' cascade'; + return 'drop table "'.implode('","', $tables).'" cascade'; } /**
true
Other
laravel
framework
f55331d0f47415e4da6d6bf0fc0f1f4f950acd60.json
add postgres table escaping and regression test
tests/Database/DatabasePostgresSchemaGrammarTest.php
@@ -546,6 +546,13 @@ public function testAddingMacAddress() $this->assertEquals('alter table "users" add column "foo" macaddr not null', $statements[0]); } + public function testDropAllTablesEscapesTableNames() + { + $statement = $this->getGrammar()->compileDropAllTables(['alpha', 'beta', 'gamma']); + + $this->assertEquals('drop table "alpha","beta","gamma" cascade', $statement); + } + protected function getConnection() { return m::mock('Illuminate\Database\Connection');
true
Other
laravel
framework
81608d0ee85eef48769ddcc95e9c2b3140145f5a.json
add ability to create nested model controllers - new stub for nested controllers - ‘parent’ option for make command - if we want a parent, determine the replacement values based on the model name
src/Illuminate/Routing/Console/ControllerMakeCommand.php
@@ -37,7 +37,9 @@ class ControllerMakeCommand extends GeneratorCommand */ protected function getStub() { - if ($this->option('model')) { + if ($this->option('parent')) { + return __DIR__.'/stubs/controller.nested.stub'; + } elseif ($this->option('model')) { return __DIR__.'/stubs/controller.model.stub'; } elseif ($this->option('resource')) { return __DIR__.'/stubs/controller.stub'; @@ -71,6 +73,22 @@ protected function buildClass($name) $replace = []; + if ($this->option('parent')) { + $parentModelClass = $this->parseModel($this->option('parent')); + + if (! class_exists($parentModelClass)) { + if ($this->confirm("A {$parentModelClass} model does not exist. Do you want to generate it?", true)) { + $this->call('make:model', ['name' => $parentModelClass]); + } + } + + $replace = [ + 'ParentDummyFullModelClass' => $parentModelClass, + 'ParentDummyModelClass' => class_basename($parentModelClass), + 'ParentDummyModelVariable' => lcfirst(class_basename($parentModelClass)), + ]; + } + if ($this->option('model')) { $modelClass = $this->parseModel($this->option('model')); @@ -80,11 +98,11 @@ protected function buildClass($name) } } - $replace = [ + $replace = array_merge($replace, [ 'DummyFullModelClass' => $modelClass, 'DummyModelClass' => class_basename($modelClass), 'DummyModelVariable' => lcfirst(class_basename($modelClass)), - ]; + ]); } $replace["use {$controllerNamespace}\Controller;\n"] = ''; @@ -126,6 +144,8 @@ protected function getOptions() ['model', 'm', InputOption::VALUE_OPTIONAL, 'Generate a resource controller for the given model.'], ['resource', 'r', InputOption::VALUE_NONE, 'Generate a resource controller class.'], + + ['parent', 'p', InputOption::VALUE_OPTIONAL, 'Generate a nested resource controller class.'], ]; } }
true
Other
laravel
framework
81608d0ee85eef48769ddcc95e9c2b3140145f5a.json
add ability to create nested model controllers - new stub for nested controllers - ‘parent’ option for make command - if we want a parent, determine the replacement values based on the model name
src/Illuminate/Routing/Console/stubs/controller.nested.stub
@@ -0,0 +1,94 @@ +<?php + +namespace DummyNamespace; + +use DummyFullModelClass; +use Illuminate\Http\Request; +use ParentDummyFullModelClass; +use DummyRootNamespaceHttp\Controllers\Controller; + +class DummyClass extends Controller +{ + /** + * Display a listing of the resource. + * + * @param \ParentDummyFullModelClass $ParentDummyModelVariable + * @return \Illuminate\Http\Response + */ + public function index(ParentDummyModelClass $ParentDummyModelVariable) + { + // + } + + /** + * Show the form for creating a new resource. + * + * @param \ParentDummyFullModelClass $ParentDummyModelVariable + * @return \Illuminate\Http\Response + */ + public function create(ParentDummyModelClass $ParentDummyModelVariable) + { + // + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param \ParentDummyFullModelClass $ParentDummyModelVariable + * @return \Illuminate\Http\Response + */ + public function store(Request $request, ParentDummyModelClass $ParentDummyModelVariable) + { + // + } + + /** + * Display the specified resource. + * + * @param \ParentDummyFullModelClass $ParentDummyModelVariable + * @param \DummyFullModelClass $DummyModelVariable + * @return \Illuminate\Http\Response + */ + public function show(ParentDummyModelClass $ParentDummyModelVariable, DummyModelClass $DummyModelVariable) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param \ParentDummyFullModelClass $ParentDummyModelVariable + * @param \DummyFullModelClass $DummyModelVariable + * @return \Illuminate\Http\Response + */ + public function edit(ParentDummyModelClass $ParentDummyModelVariable, DummyModelClass $DummyModelVariable) + { + // + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param \ParentDummyFullModelClass $ParentDummyModelVariable + * @param \DummyFullModelClass $DummyModelVariable + * @return \Illuminate\Http\Response + */ + public function update(Request $request, ParentDummyModelClass $ParentDummyModelVariable, DummyModelClass $DummyModelVariable) + { + // + } + + /** + * Remove the specified resource from storage. + * + * @param \ParentDummyFullModelClass $ParentDummyModelVariable + * @param \DummyFullModelClass $DummyModelVariable + * @return \Illuminate\Http\Response + */ + public function destroy(ParentDummyModelClass $ParentDummyModelVariable, DummyModelClass $DummyModelVariable) + { + // + } +}
true
Other
laravel
framework
ea134ccbdd52797d14ef05bc9467ec1fedfe6b36.json
Apply fixes from StyleCI (#18600)
tests/Database/DatabaseConnectionFactoryTest.php
@@ -6,7 +6,6 @@ use ReflectionProperty; use InvalidArgumentException; use PHPUnit\Framework\TestCase; -use Illuminate\Database\Connection; use Illuminate\Database\Capsule\Manager as DB; use Illuminate\Database\Connectors\ConnectionFactory;
false
Other
laravel
framework
d3c96686c36c0681cb01251c32f2fc3291d49c6b.json
Use stdClass (#18574)
src/Illuminate/Queue/Console/RetryCommand.php
@@ -63,7 +63,7 @@ protected function getJobIds() /** * Retry the queue job. * - * @param stdClass $job + * @param \stdClass $job * @return void */ protected function retryJob($job)
true
Other
laravel
framework
d3c96686c36c0681cb01251c32f2fc3291d49c6b.json
Use stdClass (#18574)
src/Illuminate/Queue/Jobs/DatabaseJob.php
@@ -18,7 +18,7 @@ class DatabaseJob extends Job implements JobContract /** * The database job payload. * - * @var \StdClass + * @var \stdClass */ protected $job; @@ -27,7 +27,7 @@ class DatabaseJob extends Job implements JobContract * * @param \Illuminate\Container\Container $container * @param \Illuminate\Queue\DatabaseQueue $database - * @param \StdClass $job + * @param \stdClass $job * @param string $connectionName * @param string $queue * @return void
true
Other
laravel
framework
d3c96686c36c0681cb01251c32f2fc3291d49c6b.json
Use stdClass (#18574)
src/Illuminate/Queue/Jobs/DatabaseJobRecord.php
@@ -11,14 +11,14 @@ class DatabaseJobRecord /** * The underlying job record. * - * @var \StdClass + * @var \stdClass */ protected $record; /** * Create a new job record instance. * - * @param \StdClass $record + * @param \stdClass $record * @return void */ public function __construct($record)
true
Other
laravel
framework
d3c96686c36c0681cb01251c32f2fc3291d49c6b.json
Use stdClass (#18574)
src/Illuminate/Session/DatabaseSessionHandler.php
@@ -103,7 +103,7 @@ public function read($sessionId) /** * Determine if the session is expired. * - * @param \StdClass $session + * @param \stdClass $session * @return bool */ protected function expired($session)
true
Other
laravel
framework
d3c96686c36c0681cb01251c32f2fc3291d49c6b.json
Use stdClass (#18574)
src/Illuminate/Validation/ValidationRuleParser.php
@@ -38,7 +38,7 @@ public function __construct(array $data) * Parse the human-friendly rules into a full rules array for the validator. * * @param array $rules - * @return \StdClass + * @return \stdClass */ public function explode($rules) {
true
Other
laravel
framework
d3c96686c36c0681cb01251c32f2fc3291d49c6b.json
Use stdClass (#18574)
src/Illuminate/View/Concerns/ManagesLoops.php
@@ -69,7 +69,7 @@ public function popLoop() /** * Get an instance of the last loop in the stack. * - * @return \StdClass|null + * @return \stdClass|null */ public function getLastLoop() {
true
Other
laravel
framework
af5035dafc456c61d6b993d703bc6e96d046f84b.json
Fix event dispatcher comments (#18548)
src/Illuminate/Contracts/Events/Dispatcher.php
@@ -30,7 +30,7 @@ public function hasListeners($eventName); public function subscribe($subscriber); /** - * Dispatch an event and call the listeners. + * Dispatch an event until the first non-null response is returned. * * @param string|object $event * @param mixed $payload @@ -39,7 +39,7 @@ public function subscribe($subscriber); public function until($event, $payload = []); /** - * Fire an event until the first non-null response is returned. + * Dispatch an event and call the listeners. * * @param string|object $event * @param mixed $payload
false
Other
laravel
framework
cc889335728166f2ad2bffad6e75095cdf70e7ba.json
Fix typo in Session/Store (#18530)
src/Illuminate/Session/Store.php
@@ -180,7 +180,7 @@ public function exists($key) } /** - * Checks if an a key is present and not null. + * Checks if a key is present and not null. * * @param string|array $key * @return bool
false
Other
laravel
framework
5a5278d167f8c73ea9d95b9bbc7bbae3cafcbe44.json
Remove unused parameters (#18520)
src/Illuminate/Contracts/Mail/MailQueue.php
@@ -7,23 +7,19 @@ interface MailQueue /** * Queue a new e-mail message for sending. * - * @param string|array $view - * @param array $data - * @param \Closure|string $callback + * @param string|array|MailableContract $view * @param string $queue * @return mixed */ - public function queue($view, array $data, $callback, $queue = null); + public function queue($view, $queue = null); /** * Queue a new e-mail message for sending after (n) seconds. * - * @param int $delay - * @param string|array $view - * @param array $data - * @param \Closure|string $callback + * @param \DateTime|int $delay + * @param string|array|MailableContract $view * @param string $queue * @return mixed */ - public function later($delay, $view, array $data, $callback, $queue = null); + public function later($delay, $view, $queue = null); }
true
Other
laravel
framework
5a5278d167f8c73ea9d95b9bbc7bbae3cafcbe44.json
Remove unused parameters (#18520)
src/Illuminate/Contracts/Mail/Mailer.php
@@ -16,7 +16,7 @@ public function raw($text, $callback); /** * Send a new message using a view. * - * @param string|array $view + * @param string|array|MailableContract $view * @param array $data * @param \Closure|string $callback * @return void
true
Other
laravel
framework
5a5278d167f8c73ea9d95b9bbc7bbae3cafcbe44.json
Remove unused parameters (#18520)
src/Illuminate/Mail/Mailer.php
@@ -193,7 +193,7 @@ public function render($view, array $data = []) /** * Send a new message using a view. * - * @param string|array $view + * @param string|array|MailableContract $view * @param array $data * @param \Closure|string $callback * @return void @@ -334,33 +334,29 @@ protected function setGlobalTo($message) /** * Queue a new e-mail message for sending. * - * @param string|array $view - * @param array $data - * @param \Closure|string $callback + * @param string|array|MailableContract $view * @param string|null $queue * @return mixed */ - public function queue($view, array $data = [], $callback = null, $queue = null) + public function queue($view, $queue = null) { if (! $view instanceof MailableContract) { throw new InvalidArgumentException('Only mailables may be queued.'); } - return $view->queue($this->queue); + return $view->queue(is_null($queue) ? $this->queue : $queue); } /** * Queue a new e-mail message for sending on the given queue. * * @param string $queue * @param string|array $view - * @param array $data - * @param \Closure|string $callback * @return mixed */ - public function onQueue($queue, $view, array $data, $callback) + public function onQueue($queue, $view) { - return $this->queue($view, $data, $callback, $queue); + return $this->queue($view, $queue); } /** @@ -370,47 +366,41 @@ public function onQueue($queue, $view, array $data, $callback) * * @param string $queue * @param string|array $view - * @param array $data - * @param \Closure|string $callback * @return mixed */ - public function queueOn($queue, $view, array $data, $callback) + public function queueOn($queue, $view) { - return $this->onQueue($queue, $view, $data, $callback); + return $this->onQueue($queue, $view); } /** * Queue a new e-mail message for sending after (n) seconds. * - * @param int $delay - * @param string|array $view - * @param array $data - * @param \Closure|string $callback + * @param \DateTime|int $delay + * @param string|array|MailableContract $view * @param string|null $queue * @return mixed */ - public function later($delay, $view, array $data = [], $callback = null, $queue = null) + public function later($delay, $view, $queue = null) { if (! $view instanceof MailableContract) { throw new InvalidArgumentException('Only mailables may be queued.'); } - return $view->later($delay, $this->queue); + return $view->later($delay, is_null($queue) ? $this->queue : $queue); } /** * Queue a new e-mail message for sending after (n) seconds on the given queue. * * @param string $queue - * @param int $delay + * @param \DateTime|int $delay * @param string|array $view - * @param array $data - * @param \Closure|string $callback * @return mixed */ - public function laterOn($queue, $delay, $view, array $data, $callback) + public function laterOn($queue, $delay, $view) { - return $this->later($delay, $view, $data, $callback, $queue); + return $this->later($delay, $view, $queue); } /**
true
Other
laravel
framework
ab3cfef17edb09cc55966b82b9a10d05ffae0cbd.json
Apply fixes from StyleCI (#18518)
src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
@@ -395,7 +395,7 @@ protected function typeReal(Fluent $column) { return 'real'; } - + /** * Create the column definition for a decimal type. *
false
Other
laravel
framework
12dad330ed505fa939eb50683bae795a7189246c.json
add Integration test
tests/Database/DatabaseSchemaBuilderIntegrationTest.php
@@ -0,0 +1,58 @@ +<?php + +use PHPUnit\Framework\TestCase; +use Illuminate\Database\Capsule\Manager as DB; + +class DatabaseSchemaBuilderIntegrationTest extends TestCase +{ + protected $db; + + /** + * Bootstrap database. + * + * @return void + */ + public function setUp() + { + $this->db = $db = new DB; + + $db->addConnection([ + 'driver' => 'sqlite', + 'database' => ':memory:', + ]); + + $db->setAsGlobal(); + + $container = new Illuminate\Container\Container; + $container->instance('db', $db->getDatabaseManager()); + Illuminate\Support\Facades\Facade::setFacadeApplication($container); + } + + public function tearDown() + { + Illuminate\Support\Facades\Facade::clearResolvedInstances(); + Illuminate\Support\Facades\Facade::setFacadeApplication(null); + } + + public function testDropAllTablesWorksWithForeignKeys() + { + $this->db->connection()->getSchemaBuilder()->create('table1', function ($table) { + $table->integer('id'); + $table->string('name'); + }); + + $this->db->connection()->getSchemaBuilder()->create('table2', function ($table) { + $table->integer('id'); + $table->string('user_id'); + $table->foreign('user_id')->references('id')->on('table1'); + }); + + $this->assertTrue($this->db->connection()->getSchemaBuilder()->hasTable('table1')); + $this->assertTrue($this->db->connection()->getSchemaBuilder()->hasTable('table2')); + + $this->db->connection()->getSchemaBuilder()->dropAllTables(); + + $this->assertFalse($this->db->connection()->getSchemaBuilder()->hasTable('table1')); + $this->assertFalse($this->db->connection()->getSchemaBuilder()->hasTable('table2')); + } +}
false
Other
laravel
framework
ae16e5930eaa7d9e4518edea75740f1a7ee5a472.json
remove unused command I added
src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php
@@ -61,17 +61,6 @@ public function compileCreate(Blueprint $blueprint, Fluent $command) ); } - /** - * Compile a get all tables command. - * - * @param string $schema - * @return string - */ - public function compileGetAllTables() - { - return "select name from sqlite_master where type='table'"; - } - /** * Get the foreign key syntax for a table creation statement. *
false
Other
laravel
framework
69692647947f0bf2a685a71768d55f1003e8a684.json
improve sqlite command
src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php
@@ -61,6 +61,17 @@ public function compileCreate(Blueprint $blueprint, Fluent $command) ); } + /** + * Compile a get all tables command. + * + * @param string $schema + * @return string + */ + public function compileGetAllTables() + { + return "select name from sqlite_master where type='table'"; + } + /** * Get the foreign key syntax for a table creation statement. * @@ -207,6 +218,16 @@ public function compileDropIfExists(Blueprint $blueprint, Fluent $command) return 'drop table if exists '.$this->wrapTable($blueprint); } + /** + * Compile a drop all tables command. + * + * @return string + */ + public function compileDropAllTables() + { + return "delete from sqlite_master where type in ('table', 'index', 'trigger')"; + } + /** * Compile a drop column command. * @@ -292,6 +313,26 @@ public function compileDisableForeignKeyConstraints() return 'PRAGMA foreign_keys = OFF;'; } + /** + * Compile the command to enable a writable schema. + * + * @return string + */ + public function compileEnableWriteableSchema() + { + return 'PRAGMA writable_schema = 1;'; + } + + /** + * Compile the command to disable a writable schema. + * + * @return string + */ + public function compileDisableWriteableSchema() + { + return 'PRAGMA writable_schema = 0;'; + } + /** * Create the column definition for a char type. *
true
Other
laravel
framework
69692647947f0bf2a685a71768d55f1003e8a684.json
improve sqlite command
src/Illuminate/Database/Schema/SQLiteBuilder.php
@@ -11,12 +11,10 @@ class SQLiteBuilder extends Builder */ public function dropAllTables() { - $dbPath = $this->connection->getConfig('database'); + $this->connection->select($this->grammar->compileEnableWriteableSchema()); - if (file_exists($dbPath)) { - unlink($dbPath); - } + $this->connection->select($this->grammar->compileDropAllTables()); - touch($dbPath); + $this->connection->select($this->grammar->compileDisableWriteableSchema()); } }
true
Other
laravel
framework
1a2567d1d315cd3176a4a8d7f8de0a630049de1f.json
Add assertion to check if no mailables were sent
src/Illuminate/Support/Testing/Fakes/MailFake.php
@@ -45,6 +45,19 @@ public function assertNotSent($mailable, $callback = null) ); } + /** + * Determine if no mailable was sent. + * + * @return void + */ + public function assertNilSent() + { + PHPUnit::assertEmpty( + $this->mailables, + "Some mailables (".count($this->mailables).") were sent." + ); + } + /** * Get all of the mailables matching a truth-test callback. *
false
Other
laravel
framework
328f505d6cac8bffdb6dc103d60af0b7ce54066b.json
Update doc block
src/Illuminate/Support/Testing/Fakes/MailFake.php
@@ -31,7 +31,7 @@ public function assertSent($mailable, $callback = null) } /** - * Determine if a mailable was sent based on a truth-test callback. + * Determine if a mailable was not sent based on a truth-test callback. * * @param string $mailable * @param callable|null $callback
false
Other
laravel
framework
d493b629771844b08e51370c75a97afdde988c88.json
convert errors to http exception
src/Illuminate/Foundation/Exceptions/Handler.php
@@ -169,11 +169,15 @@ protected function convertValidationExceptionToResponse(ValidationException $e, */ protected function prepareResponse($request, Exception $e) { - if ($this->isHttpException($e)) { - return $this->toIlluminateResponse($this->renderHttpException($e), $e); - } else { + if (! $this->isHttpException($e) && config('app.debug')) { return $this->toIlluminateResponse($this->convertExceptionToResponse($e), $e); } + + if (! $this->isHttpException($e)) { + $e = new HttpException(500, $e->getMessage()); + } + + return $this->toIlluminateResponse($this->renderHttpException($e), $e); } /**
false
Other
laravel
framework
2a5d11b40392748f86c64335b96fba0bd18fbd51.json
Add test for overwriting routes
tests/Routing/RouteCollectionTest.php
@@ -165,4 +165,35 @@ public function testRouteCollectionCanGetAllRoutes() ]; $this->assertEquals($allRoutes, $this->routeCollection->getRoutes()); } + + + public function testRouteCollectionCleansUpOverwrittenRoutes() + { + // Create two routes with the same path and method. + $routeA = new Route('GET', 'product', ['controller' => 'View@view', 'as' => 'routeA']); + $routeB = new Route('GET', 'product', ['controller' => 'OverwrittenView@view', 'as' => 'overwrittenRouteA']); + + $this->routeCollection->add($routeA); + $this->routeCollection->add($routeB); + + // Check if the lookups of $routeA and $routeB are there. + $this->assertEquals($routeA, $this->routeCollection->getByName('routeA')); + $this->assertEquals($routeA, $this->routeCollection->getByAction('View@view')); + $this->assertEquals($routeB, $this->routeCollection->getByName('overwrittenRouteA')); + $this->assertEquals($routeB, $this->routeCollection->getByAction('OverwrittenView@view')); + + // Rebuild the lookup arrays. + $this->routeCollection->refreshNameLookups(); + $this->routeCollection->refreshActionLookups(); + + // The lookups of $routeA should not be there anymore, because they are no longer valid. + $this->assertNull($this->routeCollection->getByName('routeA')); + $this->assertNull($this->routeCollection->getByAction('View@view')); + // The lookups of $routeB are still there. + $this->assertEquals($routeB, $this->routeCollection->getByName('overwrittenRouteA')); + $this->assertEquals($routeB, $this->routeCollection->getByAction('OverwrittenView@view')); + + } + + }
false
Other
laravel
framework
01d6896cb402d7b641c84ed8d541b1bc96af34ce.json
apply style ci
tests/Database/DatabaseEloquentModelTest.php
@@ -67,7 +67,8 @@ public function testDirtyAttributes() $this->assertTrue($model->isDirty(['foo', 'bar'])); } - public function testDirtyOnCastOrDateAttributes(){ + public function testDirtyOnCastOrDateAttributes() + { $model = new EloquentModelCastingStub; $model->setDateFormat('Y-m-d H:i:s'); $model->boolAttribute = 1;
false
Other
laravel
framework
a720279a0b2e7d3a028b63f7c4e5ee501807a1b5.json
add testWhenCallbackWithReturn (#18447)
tests/Database/DatabaseQueryBuilderTest.php
@@ -147,6 +147,23 @@ public function testWhenCallback() $this->assertEquals('select * from "users" where "email" = ?', $builder->toSql()); } + public function testWhenCallbackWithReturn() + { + $callback = function ($query, $condition) { + $this->assertTrue($condition); + + return $query->where('id', '=', 1); + }; + + $builder = $this->getBuilder(); + $builder->select('*')->from('users')->when(true, $callback)->where('email', 'foo'); + $this->assertEquals('select * from "users" where "id" = ? and "email" = ?', $builder->toSql()); + + $builder = $this->getBuilder(); + $builder->select('*')->from('users')->when(false, $callback)->where('email', 'foo'); + $this->assertEquals('select * from "users" where "email" = ?', $builder->toSql()); + } + public function testWhenCallbackWithDefault() { $callback = function ($query, $condition) {
false
Other
laravel
framework
3f693da808f4cc77e15c9932ee1019f00c627ada.json
fix issue with case in authorizeResource (#18435)
src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php
@@ -81,7 +81,7 @@ protected function normalizeGuessedAbilityName($ability) */ public function authorizeResource($model, $parameter = null, array $options = [], $request = null) { - $parameter = $parameter ?: strtolower(class_basename($model)); + $parameter = $parameter ?: lcfirst(class_basename($model)); $middleware = [];
false
Other
laravel
framework
4be74e19a6282a789070b6da81f70e1a886b7176.json
Apply fixes from StyleCI (#18427)
src/Illuminate/View/Compilers/Concerns/CompilesConditionals.php
@@ -77,7 +77,7 @@ protected function compileEndunless() { return '<?php endif; ?>'; } - + /** * Compile the if-isset statements into valid PHP. *
false
Other
laravel
framework
36b255013aeeb841d8fc441401825f9811b0993f.json
Pass the condition value to "when" (#18419)
src/Illuminate/Database/Concerns/BuildsQueries.php
@@ -84,9 +84,9 @@ public function when($value, $callback, $default = null) $builder = $this; if ($value) { - $builder = $callback($builder); + $builder = $callback($builder, $value); } elseif ($default) { - $builder = $default($builder); + $builder = $default($builder, $value); } return $builder;
true
Other
laravel
framework
36b255013aeeb841d8fc441401825f9811b0993f.json
Pass the condition value to "when" (#18419)
tests/Database/DatabaseQueryBuilderTest.php
@@ -132,7 +132,9 @@ public function testBasicTableWrapping() public function testWhenCallback() { - $callback = function ($query) { + $callback = function ($query, $condition) { + $this->assertTrue($condition); + return $query->where('id', '=', 1); }; @@ -147,21 +149,25 @@ public function testWhenCallback() public function testWhenCallbackWithDefault() { - $callback = function ($query) { + $callback = function ($query, $condition) { + $this->assertEquals($condition, 'truthy'); + return $query->where('id', '=', 1); }; - $default = function ($query) { + $default = function ($query, $condition) { + $this->assertEquals($condition, 0); + return $query->where('id', '=', 2); }; $builder = $this->getBuilder(); - $builder->select('*')->from('users')->when(true, $callback, $default)->where('email', 'foo'); + $builder->select('*')->from('users')->when('truthy', $callback, $default)->where('email', 'foo'); $this->assertEquals('select * from "users" where "id" = ? and "email" = ?', $builder->toSql()); $this->assertEquals([0 => 1, 1 => 'foo'], $builder->getBindings()); $builder = $this->getBuilder(); - $builder->select('*')->from('users')->when(false, $callback, $default)->where('email', 'foo'); + $builder->select('*')->from('users')->when(0, $callback, $default)->where('email', 'foo'); $this->assertEquals('select * from "users" where "id" = ? and "email" = ?', $builder->toSql()); $this->assertEquals([0 => 2, 1 => 'foo'], $builder->getBindings()); }
true
Other
laravel
framework
d876eb34ff07ebd54fd48b0264135f795c0bad0c.json
move method lower in class
src/Illuminate/Redis/Connections/PhpRedisConnection.php
@@ -140,17 +140,6 @@ public function transaction(callable $callback = null) : tap($transaction, $callback)->exec(); } - /** - * Execute a raw command. - * - * @param array $parameters - * @return mixed - */ - public function executeRaw(array $parameters) - { - return $this->command('rawCommand', $parameters); - } - /** * Evaluate a LUA script serverside, from the SHA1 hash of the script instead of the script itself. * @@ -222,6 +211,17 @@ public function createSubscription($channels, Closure $callback, $method = 'subs // } + /** + * Execute a raw command. + * + * @param array $parameters + * @return mixed + */ + public function executeRaw(array $parameters) + { + return $this->command('rawCommand', $parameters); + } + /** * Disconnects from the Redis instance. *
false