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
1a0930650601cbcbbaf4b4ede904bd147e0f461f.json
Use bootstrappers instead of events
src/Illuminate/Foundation/Console/Kernel.php
@@ -8,7 +8,6 @@ use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Console\Application as Artisan; -use Illuminate\Console\Events\ArtisanStarting; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Console\Kernel as KernelContract; use Symfony\Component\Debug\Exception\FatalThrowableError; @@ -181,8 +180,8 @@ public function command($signature, Closure $callback) { $command = new ClosureCommand($signature, $callback); - $this->app['events']->listen(ArtisanStarting::class, function ($event) use ($command) { - $event->artisan->add($command); + Artisan::starting(function ($artisan) use ($command) { + $artisan->add($command); }); return $command;
true
Other
laravel
framework
1a0930650601cbcbbaf4b4ede904bd147e0f461f.json
Use bootstrappers instead of events
src/Illuminate/Support/ServiceProvider.php
@@ -2,7 +2,7 @@ namespace Illuminate\Support; -use Illuminate\Console\Events\ArtisanStarting; +use Illuminate\Console\Application as Artisan; abstract class ServiceProvider { @@ -176,13 +176,8 @@ public function commands($commands) { $commands = is_array($commands) ? $commands : func_get_args(); - // To register the commands with Artisan, we will grab each of the arguments - // passed into the method and listen for Artisan "start" event which will - // give us the Artisan console instance which we will give commands to. - $events = $this->app['events']; - - $events->listen(ArtisanStarting::class, function ($event) use ($commands) { - $event->artisan->resolveCommands($commands); + Artisan::starting(function ($artisan) use ($commands) { + $artisan->resolveCommands($commands); }); }
true
Other
laravel
framework
baa8a094fe61294e12913d8973fd06b09dd0b404.json
remove blank line
src/Illuminate/Routing/Console/stubs/controller.plain.stub
@@ -3,7 +3,6 @@ namespace DummyNamespace; use Illuminate\Http\Request; - use DummyRootNamespaceHttp\Controllers\Controller; class DummyClass extends Controller
true
Other
laravel
framework
baa8a094fe61294e12913d8973fd06b09dd0b404.json
remove blank line
src/Illuminate/Routing/Console/stubs/controller.stub
@@ -3,7 +3,6 @@ namespace DummyNamespace; use Illuminate\Http\Request; - use DummyRootNamespaceHttp\Controllers\Controller; class DummyClass extends Controller
true
Other
laravel
framework
fca954dd807e93d8e734c36357b9ee46617f77b0.json
Fix invalid @return types in dockblocks (#16006)
src/Illuminate/Foundation/Auth/AuthenticatesUsers.php
@@ -109,7 +109,7 @@ protected function authenticated(Request $request, $user) * Get the failed login response instance. * * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse */ protected function sendFailedLoginResponse(Request $request) {
true
Other
laravel
framework
fca954dd807e93d8e734c36357b9ee46617f77b0.json
Fix invalid @return types in dockblocks (#16006)
src/Illuminate/Foundation/Auth/ResetsPasswords.php
@@ -18,7 +18,7 @@ trait ResetsPasswords * * @param \Illuminate\Http\Request $request * @param string|null $token - * @return \Illuminate\Http\Response + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function showResetForm(Request $request, $token = null) { @@ -104,7 +104,7 @@ protected function sendResetResponse($response) * * @param \Illuminate\Http\Request * @param string $response - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse */ protected function sendResetFailedResponse(Request $request, $response) {
true
Other
laravel
framework
07ab16fdfe4db427b4518ceda5693dbd3911b663.json
Simplify conditional (#16007)
src/Illuminate/Foundation/Console/ModelMakeCommand.php
@@ -36,24 +36,26 @@ class ModelMakeCommand extends GeneratorCommand */ public function fire() { - if (parent::fire() !== false) { - if ($this->option('migration')) { - $table = Str::plural(Str::snake(class_basename($this->argument('name')))); + if (parent::fire() === false) { + return; + } + + if ($this->option('migration')) { + $table = Str::plural(Str::snake(class_basename($this->argument('name')))); - $this->call('make:migration', [ - 'name' => "create_{$table}_table", - '--create' => $table, - ]); - } + $this->call('make:migration', [ + 'name' => "create_{$table}_table", + '--create' => $table, + ]); + } - if ($this->option('controller')) { - $controller = Str::studly(class_basename($this->argument('name'))); + if ($this->option('controller')) { + $controller = Str::studly(class_basename($this->argument('name'))); - $this->call('make:controller', [ - 'name' => "{$controller}Controller", - '--resource' => $this->option('resource'), - ]); - } + $this->call('make:controller', [ + 'name' => "{$controller}Controller", + '--resource' => $this->option('resource'), + ]); } }
false
Other
laravel
framework
6440dac54b9786f3b273e6c60f3040ae4d2749a1.json
Keep the Composer Cache (#15997)
.travis.yml
@@ -21,6 +21,10 @@ matrix: sudo: false +cache: + directories: + - $HOME/.composer/cache + services: - memcached - redis-server
false
Other
laravel
framework
7971ecc1dd607f4b1ca16c2a4eb08ba05e64c0c6.json
Add flag for select type of create controller Add flag for select type of create controller (resource controller or no).
src/Illuminate/Foundation/Console/ModelMakeCommand.php
@@ -45,8 +45,14 @@ public function fire() if ($this->option('controller')) { $controller = Str::studly(class_basename($this->argument('name'))); - - $this->call('make:controller', ['name' => "{$controller}Controller", '--resource' => true]); + + if ($this->option('controller_resource') { + $resource = true; + } else { + $resource = false; + } + + $this->call('make:controller', ['name' => "{$controller}Controller", '--resource' => $resource]); } } } @@ -82,7 +88,10 @@ protected function getOptions() return [ ['migration', 'm', InputOption::VALUE_NONE, 'Create a new migration file for the model.'], - ['controller', 'c', InputOption::VALUE_NONE, 'Create a new resource controller for the model.'], + ['controller', 'c', InputOption::VALUE_NONE, 'Create a new controller for the model.'], + + ['controller_resource', 'c_r', InputOption::VALUE_NONE, + 'Set is resource controller or no. If create a new controller for the model'] ]; } }
false
Other
laravel
framework
8fb3cfe5a44ea2fbc9d5961f5afe33c23e108c7c.json
Use studly case for controller names (#15988)
src/Illuminate/Foundation/Console/ModelMakeCommand.php
@@ -44,7 +44,7 @@ public function fire() } if ($this->option('controller')) { - $controller = Str::camel(class_basename($this->argument('name'))); + $controller = Str::studly(class_basename($this->argument('name'))); $this->call('make:controller', ['name' => "{$controller}Controller", '--resource' => true]); }
false
Other
laravel
framework
778350e5d6a59c4670251ca6b6e0419f801368ba.json
Fix a method naming error
src/Illuminate/Database/Migrations/Migrator.php
@@ -159,7 +159,7 @@ protected function runUp($file, $batch, $pretend) return $this->pretendToRun($migration, 'up'); } - $this->migrate($migration, 'up'); + $this->runMigration($migration, 'up'); // Once we have run a migrations class, we will log that it was run in this // repository so that we don't try to run it next time we do a migration
false
Other
laravel
framework
5aa9a6d5151ca983e3a2c6b638e46e240c14be1f.json
Remove an unused import
src/Illuminate/Database/Migrations/Migrator.php
@@ -2,7 +2,6 @@ namespace Illuminate\Database\Migrations; -use Closure; use Illuminate\Support\Arr; use Illuminate\Support\Str; use Illuminate\Support\Collection;
false
Other
laravel
framework
4e9c9fd98b4dff71f449764e87c52577e2634587.json
break constructor line
src/Illuminate/Validation/Validator.php
@@ -197,7 +197,8 @@ class Validator implements ValidatorContract * @param array $customAttributes * @return void */ - public function __construct(TranslatorInterface $translator, array $data, array $rules, array $messages = [], array $customAttributes = []) + public function __construct(TranslatorInterface $translator, array $data, array $rules, + array $messages = [], array $customAttributes = []) { $this->initialRules = $rules; $this->translator = $translator;
false
Other
laravel
framework
7322343923b5d6f963ee5ea03cc64a3d33361b6d.json
fix doc block
src/Illuminate/Foundation/Console/stubs/policy.stub
@@ -13,8 +13,8 @@ class DummyClass /** * Determine whether the user can view the dummyModelName. * - * @param DummyRootNamespaceUser $user - * @param DummyRootNamespaceDummyModel $dummyModelName + * @param \DummyRootNamespaceUser $user + * @param \DummyRootNamespaceDummyModel $dummyModelName * @return mixed */ public function view(User $user, DummyModel $dummyModelName) @@ -25,7 +25,7 @@ class DummyClass /** * Determine whether the user can create dummyPluralModelName. * - * @param DummyRootNamespaceUser $user + * @param \DummyRootNamespaceUser $user * @return mixed */ public function create(User $user) @@ -36,8 +36,8 @@ class DummyClass /** * Determine whether the user can update the dummyModelName. * - * @param DummyRootNamespaceUser $user - * @param DummyRootNamespaceDummyModel $dummyModelName + * @param \DummyRootNamespaceUser $user + * @param \DummyRootNamespaceDummyModel $dummyModelName * @return mixed */ public function update(User $user, DummyModel $dummyModelName) @@ -48,8 +48,8 @@ class DummyClass /** * Determine whether the user can delete the dummyModelName. * - * @param DummyRootNamespaceUser $user - * @param DummyRootNamespaceDummyModel $dummyModelName + * @param \DummyRootNamespaceUser $user + * @param \DummyRootNamespaceDummyModel $dummyModelName * @return mixed */ public function delete(User $user, DummyModel $dummyModelName)
false
Other
laravel
framework
a8a55657a588291693b1faa93d1e6ebdb556b113.json
Fix some typos
CHANGELOG-5.2.md
@@ -259,7 +259,7 @@ - Simplified calling `Model::replicate()` with `$except` argument ([#13676](https://github.com/laravel/framework/pull/13676)) - Allow auth events to be serialized ([#13704](https://github.com/laravel/framework/pull/13704)) - Added `for` and `id` attributes to auth scaffold ([#13689](https://github.com/laravel/framework/pull/13689)) -- Aquire lock before deleting reserved job ([4b502dc](https://github.com/laravel/framework/commit/4b502dc6eecd80efad01e845469b9a2bac26dae0#diff-b05083dc38b4e45d38d28c676abbad83)) +- Acquire lock before deleting reserved job ([4b502dc](https://github.com/laravel/framework/commit/4b502dc6eecd80efad01e845469b9a2bac26dae0#diff-b05083dc38b4e45d38d28c676abbad83)) ### Fixed - Prefix timestamps when updating many-to-many relationships ([#13519](https://github.com/laravel/framework/pull/13519))
true
Other
laravel
framework
a8a55657a588291693b1faa93d1e6ebdb556b113.json
Fix some typos
src/Illuminate/Database/Events/QueryExecuted.php
@@ -26,7 +26,7 @@ class QueryExecuted public $time; /** - * The databse connection instance. + * The database connection instance. * * @var \Illuminate\Database\Connection */
true
Other
laravel
framework
a8a55657a588291693b1faa93d1e6ebdb556b113.json
Fix some typos
src/Illuminate/Queue/SyncQueue.php
@@ -52,7 +52,7 @@ public function push($job, $data = '', $queue = null) } /** - * Handle an exception that occured while processing a job. + * Handle an exception that occurred while processing a job. * * @param \Illuminate\Queue\Jobs\Job $queueJob * @param \Exception $e
true
Other
laravel
framework
e3bd359d52cee0ba8db9673e45a8221c1c1d95d6.json
add retry helper
src/Illuminate/Support/helpers.php
@@ -606,6 +606,33 @@ function preg_replace_array($pattern, array $replacements, $subject) } } +if (! function_exists('retry')) { + /** + * Retry an operation a given number of times. + * + * @param int $times + * @param callable $callback + * @return mixed + */ + function retry($times, callable $callback) + { + $times--; + + beginning: + try { + return $callback(); + } catch (Exception $e) { + if (! $times) { + throw $e; + } + + $times--; + + goto beginning; + } + } +} + if (! function_exists('snake_case')) { /** * Convert a string to snake case.
false
Other
laravel
framework
7a0832bb44057f1060c96c2e01652aae7c583323.json
add tests and update transaction logic
src/Illuminate/Database/Connection.php
@@ -601,22 +601,25 @@ public function transaction(Closure $callback, $attempts = 1) */ public function beginTransaction() { - ++$this->transactions; - - if ($this->transactions == 1) { + if ($this->transactions == 0) { try { - $this->getPdo()->beginTransaction(); + $this->pdo->beginTransaction(); } catch (Exception $e) { - --$this->transactions; - - throw $e; + if ($this->causedByLostConnection($e)) { + $this->reconnect(); + $this->pdo->beginTransaction(); + } else { + throw $e; + } } - } elseif ($this->transactions > 1 && $this->queryGrammar->supportsSavepoints()) { - $this->getPdo()->exec( - $this->queryGrammar->compileSavepoint('trans'.$this->transactions) + } elseif ($this->transactions >= 1 && $this->queryGrammar->supportsSavepoints()) { + $this->pdo->exec( + $this->queryGrammar->compileSavepoint('trans'.($this->transactions + 1)) ); } + ++$this->transactions; + $this->fireConnectionEvent('beganTransaction'); }
true
Other
laravel
framework
7a0832bb44057f1060c96c2e01652aae7c583323.json
add tests and update transaction logic
tests/Database/DatabaseConnectionTest.php
@@ -114,15 +114,46 @@ public function testAffectingStatementProperlyCallsPDO() $this->assertTrue(is_numeric($log[0]['time'])); } - public function testTransactionsDecrementedOnTransactionException() + public function testTransactionLevelNotIncrementedOnTransactionException() { $pdo = $this->createMock('DatabaseConnectionTestMockPDO'); - $pdo->expects($this->once())->method('beginTransaction')->will($this->throwException(new ErrorException('MySQL server has gone away'))); + $pdo->expects($this->once())->method('beginTransaction')->will($this->throwException(new Exception)); $connection = $this->getMockConnection([], $pdo); - $this->setExpectedException('ErrorException', 'MySQL server has gone away'); + try { + $connection->beginTransaction(); + } catch (Exception $e) { + $this->assertEquals(0, $connection->transactionLevel()); + } + } + + public function testBeginTransactionMethodRetriesOnFailure() + { + $pdo = $this->createMock('DatabaseConnectionTestMockPDO'); + $pdo->expects($this->exactly(2))->method('beginTransaction'); + $pdo->expects($this->at(0))->method('beginTransaction')->will($this->throwException(new ErrorException('server has gone away'))); + $connection = $this->getMockConnection(['reconnect'], $pdo); + $connection->expects($this->once())->method('reconnect'); $connection->beginTransaction(); - $connection->disconnect(); - $this->assertNull($connection->getPdo()); + $this->assertEquals(1, $connection->transactionLevel()); + } + + public function testBeginTransactionMethodNeverRetriesIfWithinTransaction() + { + $pdo = $this->createMock('DatabaseConnectionTestMockPDO'); + $pdo->expects($this->once())->method('beginTransaction'); + $pdo->expects($this->once())->method('exec')->will($this->throwException(new Exception)); + $connection = $this->getMockConnection(['reconnect'], $pdo); + $queryGrammar = $this->createMock('Illuminate\Database\Query\Grammars\Grammar'); + $queryGrammar->expects($this->once())->method('supportsSavepoints')->will($this->returnValue(true)); + $connection->setQueryGrammar($queryGrammar); + $connection->expects($this->never())->method('reconnect'); + $connection->beginTransaction(); + $this->assertEquals(1, $connection->transactionLevel()); + try { + $connection->beginTransaction(); + } catch (Exception $e) { + $this->assertEquals(1, $connection->transactionLevel()); + } } public function testCantSwapPDOWithOpenTransaction()
true
Other
laravel
framework
d0d1596464794a37a81b894869b3c23047a61ee5.json
Setup additional configuration for Slack Client.
src/Illuminate/Notifications/Channels/SlackWebhookChannel.php
@@ -59,12 +59,19 @@ protected function buildJsonPayload(SlackMessage $message) 'channel' => data_get($message, 'channel'), ]); - return [ + $payload = [ 'json' => array_merge([ 'text' => $message->content, 'attachments' => $this->attachments($message), ], $optionalFields), ]; + + // Add other configuration settings if available. + if (! empty($message->options)) { + $payload = array_merge($payload, $message->options); + } + + return $payload; } /**
true
Other
laravel
framework
d0d1596464794a37a81b894869b3c23047a61ee5.json
Setup additional configuration for Slack Client.
src/Illuminate/Notifications/Messages/SlackMessage.php
@@ -48,6 +48,13 @@ class SlackMessage */ public $attachments = []; + /** + * Additional settings for Slack HTTP Client. + * + * @var array + */ + public $options = []; + /** * Indicate that the notification gives information about a successful operation. * @@ -145,4 +152,17 @@ public function color() return '#F35A00'; } } + + /** + * Setup additional configuration for Slack HTTP Client. + * + * @param array $options + * @return $this + */ + public function options($options) + { + $this->options = $options; + + return $this; + } }
true
Other
laravel
framework
394ec059c3968a534434028b5040176b830d943b.json
fix notification fake for arrays
src/Illuminate/Support/Testing/Fakes/NotificationFake.php
@@ -26,6 +26,14 @@ class NotificationFake implements NotificationFactory */ public function assertSentTo($notifiable, $notification, $callback = null) { + if (is_array($notifiable) || $notifiable instanceof Collection) { + foreach ($notifiable as $singleNotifiable) { + $this->assertSentTo($singleNotifiable, $notification, $callback); + } + + return; + } + PHPUnit::assertTrue( $this->sent($notifiable, $notification, $callback)->count() > 0, "The expected [{$notification}] notification was not sent." @@ -42,6 +50,14 @@ public function assertSentTo($notifiable, $notification, $callback = null) */ public function assertNotSentTo($notifiable, $notification, $callback = null) { + if (is_array($notifiable) || $notifiable instanceof Collection) { + foreach ($notifiable as $singleNotifiable) { + $this->assertNotSentTo($singleNotifiable, $notification, $callback); + } + + return; + } + PHPUnit::assertTrue( $this->sent($notifiable, $notification, $callback)->count() === 0, "The unexpected [{$notification}] notification was sent."
false
Other
laravel
framework
057492d31c569e96a3ba2f99722112a9762c6071.json
fix various things
src/Illuminate/Cache/ArrayStore.php
@@ -100,6 +100,7 @@ public function forget($key) public function flush() { $this->storage = []; + return true; }
true
Other
laravel
framework
057492d31c569e96a3ba2f99722112a9762c6071.json
fix various things
src/Illuminate/Cache/FileStore.php
@@ -188,12 +188,14 @@ public function flush() { if ($this->files->isDirectory($this->directory)) { foreach ($this->files->directories($this->directory) as $directory) { - if(!$this->files->deleteDirectory($directory)){ + if (! $this->files->deleteDirectory($directory)) { return false; } } + return true; } + return false; }
true
Other
laravel
framework
057492d31c569e96a3ba2f99722112a9762c6071.json
fix various things
src/Illuminate/Cache/NullStore.php
@@ -93,7 +93,7 @@ public function forget($key) */ public function flush() { - // + return true; } /**
true
Other
laravel
framework
057492d31c569e96a3ba2f99722112a9762c6071.json
fix various things
src/Illuminate/Cache/RedisStore.php
@@ -170,7 +170,9 @@ public function forget($key) */ public function flush() { - return (bool) $this->connection()->flushdb(); + $this->connection()->flushdb(); + + return true; } /**
true
Other
laravel
framework
67128a4cdbb2d40c34b878cb28f58d59d63c9877.json
Add success message to clear-compiled command
src/Illuminate/Foundation/Console/ClearCompiledCommand.php
@@ -37,5 +37,7 @@ public function fire() if (file_exists($servicesPath)) { @unlink($servicesPath); } + + $this->info('Compiled class file removed!'); } }
false
Other
laravel
framework
1526178f4e1ad7f02d751a822b8fac5bfb301500.json
Add fluent interface for the dimensions rule
src/Illuminate/Validation/Rule.php
@@ -27,4 +27,15 @@ public static function unique($table, $column = 'NULL') { return new Rules\Unique($table, $column); } + + /** + * Get a dimensions constraint builder instance. + * + * @param array $constraints + * @return \Illuminate\Validation\Rules\Dimensions + */ + public static function dimensions(array $constraints = []) + { + return new Rules\Dimensions($constraints); + } }
true
Other
laravel
framework
1526178f4e1ad7f02d751a822b8fac5bfb301500.json
Add fluent interface for the dimensions rule
src/Illuminate/Validation/Rules/Dimensions.php
@@ -0,0 +1,131 @@ +<?php + +namespace Illuminate\Validation\Rules; + +class Dimensions +{ + /** + * The constraints for the dimensions rule. + * + * @var array + */ + protected $constraints = []; + + /** + * Create a new dimensions rule instance. + * + * @param array $constraints; + * @return void + */ + public function __construct(array $constraints = []) + { + $this->constraints = $constraints; + } + + /** + * Set the "width" constraint. + * + * @param int $value + * @return $this + */ + public function width($value) + { + $this->constraints['width'] = $value; + + return $this; + } + + /** + * Set the "height" constraint. + * + * @param int $value + * @return $this + */ + public function height($value) + { + $this->constraints['height'] = $value; + + return $this; + } + + /** + * Set the "min width" constraint. + * + * @param int $value + * @return $this + */ + public function minWidth($value) + { + $this->constraints['min_width'] = $value; + + return $this; + } + + /** + * Set the "min height" constraint. + * + * @param int $value + * @return $this + */ + public function minHeight($value) + { + $this->constraints['min_height'] = $value; + + return $this; + } + + /** + * Set the "max width" constraint. + * + * @param int $value + * @return $this + */ + public function maxWidth($value) + { + $this->constraints['max_width'] = $value; + + return $this; + } + + /** + * Set the "max height" constraint. + * + * @param int $value + * @return $this + */ + public function maxHeight($value) + { + $this->constraints['max_height'] = $value; + + return $this; + } + + /** + * Set the "ratio" constraint. + * + * @param float $value + * @return $this + */ + public function ratio($value) + { + $this->constraints['ratio'] = $value; + + return $this; + } + + /** + * Convert the rule to a validation string. + * + * @return string + */ + public function __toString() + { + $result = ''; + + foreach ($this->constraints as $key => $value) { + $result .= "$key=$value,"; + } + + return 'dimensions:'.substr($result, 0, -1); + } +}
true
Other
laravel
framework
1526178f4e1ad7f02d751a822b8fac5bfb301500.json
Add fluent interface for the dimensions rule
tests/Validation/ValidationDimensionsRuleTest.php
@@ -0,0 +1,22 @@ +<?php + +use Illuminate\Validation\Rule; +use Illuminate\Validation\Rules\Dimensions; + +class ValidationDimensionsRuleTest extends PHPUnit_Framework_TestCase +{ + public function testItCorrectlyFormatsAStringVersionOfTheRule() + { + $rule = new Dimensions(['min_width' => 100, 'min_height' => 100]); + + $this->assertEquals('dimensions:min_width=100,min_height=100', (string) $rule); + + $rule = Rule::dimensions()->width(200)->height(100); + + $this->assertEquals('dimensions:width=200,height=100', (string) $rule); + + $rule = Rule::dimensions()->maxWidth(1000)->maxHeight(500)->ratio(3 / 2); + + $this->assertEquals('dimensions:max_width=1000,max_height=500,ratio=1.5', (string) $rule); + } +}
true
Other
laravel
framework
4543caa9a45adbc2e127e8c92a70158bd191d83b.json
Change cache flush return type Change flush return type If a flush operation fails, then you now have chance of knowing about it. Change flush method, return false on failure Change flush test Ensuring that flush method does return false, should the delete directories return false. Change wrapper flush return type Both apcu_clear_cache() and apc_clear_cache() return bool values, which can indicate if flush operation fails. Change flush method, return bool Add Apc flush test Change flush method return type Change flush test, check return of flush method Change flush method return type The table delete() returns the number of affected rows. If the number is higher that zero, then the operation has succeeded. If not, it means that there was nothing to delete... Not too sure about this one, however, it should be the most correct response, if you do expect something to be deleted and zero is returned. Change flush test, check flush return Change flush method return type Memcached's flush method also returns true. Add flush test Change flush method return type Change flush method return type Not sure about flushdb() return. However, from what I understand, it never fails and thus should return something like "ok" back. Add flush test Add release note about cache flush change Revert "Ignore PHPStorm IDE file" This reverts commit 8176c328d5316e8508ad1c382b20841c2699b95e.
CHANGELOG-5.4.md
@@ -6,6 +6,7 @@ - Support wildcards in `MessageBag::first()` ([#15217](https://github.com/laravel/framework/pull/15217)) ### Changed +- Cache flush method returns bool ([#15578](https://github.com/laravel/framework/issues/15578)) ### Fixed
true
Other
laravel
framework
4543caa9a45adbc2e127e8c92a70158bd191d83b.json
Change cache flush return type Change flush return type If a flush operation fails, then you now have chance of knowing about it. Change flush method, return false on failure Change flush test Ensuring that flush method does return false, should the delete directories return false. Change wrapper flush return type Both apcu_clear_cache() and apc_clear_cache() return bool values, which can indicate if flush operation fails. Change flush method, return bool Add Apc flush test Change flush method return type Change flush test, check return of flush method Change flush method return type The table delete() returns the number of affected rows. If the number is higher that zero, then the operation has succeeded. If not, it means that there was nothing to delete... Not too sure about this one, however, it should be the most correct response, if you do expect something to be deleted and zero is returned. Change flush test, check flush return Change flush method return type Memcached's flush method also returns true. Add flush test Change flush method return type Change flush method return type Not sure about flushdb() return. However, from what I understand, it never fails and thus should return something like "ok" back. Add flush test Add release note about cache flush change Revert "Ignore PHPStorm IDE file" This reverts commit 8176c328d5316e8508ad1c382b20841c2699b95e.
src/Illuminate/Cache/ApcStore.php
@@ -113,11 +113,11 @@ public function forget($key) /** * Remove all items from the cache. * - * @return void + * @return bool */ public function flush() { - $this->apc->flush(); + return $this->apc->flush(); } /**
true
Other
laravel
framework
4543caa9a45adbc2e127e8c92a70158bd191d83b.json
Change cache flush return type Change flush return type If a flush operation fails, then you now have chance of knowing about it. Change flush method, return false on failure Change flush test Ensuring that flush method does return false, should the delete directories return false. Change wrapper flush return type Both apcu_clear_cache() and apc_clear_cache() return bool values, which can indicate if flush operation fails. Change flush method, return bool Add Apc flush test Change flush method return type Change flush test, check return of flush method Change flush method return type The table delete() returns the number of affected rows. If the number is higher that zero, then the operation has succeeded. If not, it means that there was nothing to delete... Not too sure about this one, however, it should be the most correct response, if you do expect something to be deleted and zero is returned. Change flush test, check flush return Change flush method return type Memcached's flush method also returns true. Add flush test Change flush method return type Change flush method return type Not sure about flushdb() return. However, from what I understand, it never fails and thus should return something like "ok" back. Add flush test Add release note about cache flush change Revert "Ignore PHPStorm IDE file" This reverts commit 8176c328d5316e8508ad1c382b20841c2699b95e.
src/Illuminate/Cache/ApcWrapper.php
@@ -83,10 +83,10 @@ public function delete($key) /** * Remove all items from the cache. * - * @return void + * @return bool */ public function flush() { - $this->apcu ? apcu_clear_cache() : apc_clear_cache('user'); + return $this->apcu ? apcu_clear_cache() : apc_clear_cache('user'); } }
true
Other
laravel
framework
4543caa9a45adbc2e127e8c92a70158bd191d83b.json
Change cache flush return type Change flush return type If a flush operation fails, then you now have chance of knowing about it. Change flush method, return false on failure Change flush test Ensuring that flush method does return false, should the delete directories return false. Change wrapper flush return type Both apcu_clear_cache() and apc_clear_cache() return bool values, which can indicate if flush operation fails. Change flush method, return bool Add Apc flush test Change flush method return type Change flush test, check return of flush method Change flush method return type The table delete() returns the number of affected rows. If the number is higher that zero, then the operation has succeeded. If not, it means that there was nothing to delete... Not too sure about this one, however, it should be the most correct response, if you do expect something to be deleted and zero is returned. Change flush test, check flush return Change flush method return type Memcached's flush method also returns true. Add flush test Change flush method return type Change flush method return type Not sure about flushdb() return. However, from what I understand, it never fails and thus should return something like "ok" back. Add flush test Add release note about cache flush change Revert "Ignore PHPStorm IDE file" This reverts commit 8176c328d5316e8508ad1c382b20841c2699b95e.
src/Illuminate/Cache/ArrayStore.php
@@ -95,11 +95,12 @@ public function forget($key) /** * Remove all items from the cache. * - * @return void + * @return bool */ public function flush() { $this->storage = []; + return true; } /**
true
Other
laravel
framework
4543caa9a45adbc2e127e8c92a70158bd191d83b.json
Change cache flush return type Change flush return type If a flush operation fails, then you now have chance of knowing about it. Change flush method, return false on failure Change flush test Ensuring that flush method does return false, should the delete directories return false. Change wrapper flush return type Both apcu_clear_cache() and apc_clear_cache() return bool values, which can indicate if flush operation fails. Change flush method, return bool Add Apc flush test Change flush method return type Change flush test, check return of flush method Change flush method return type The table delete() returns the number of affected rows. If the number is higher that zero, then the operation has succeeded. If not, it means that there was nothing to delete... Not too sure about this one, however, it should be the most correct response, if you do expect something to be deleted and zero is returned. Change flush test, check flush return Change flush method return type Memcached's flush method also returns true. Add flush test Change flush method return type Change flush method return type Not sure about flushdb() return. However, from what I understand, it never fails and thus should return something like "ok" back. Add flush test Add release note about cache flush change Revert "Ignore PHPStorm IDE file" This reverts commit 8176c328d5316e8508ad1c382b20841c2699b95e.
src/Illuminate/Cache/DatabaseStore.php
@@ -218,11 +218,11 @@ public function forget($key) /** * Remove all items from the cache. * - * @return void + * @return bool */ public function flush() { - $this->table()->delete(); + return (bool) $this->table()->delete(); } /**
true
Other
laravel
framework
4543caa9a45adbc2e127e8c92a70158bd191d83b.json
Change cache flush return type Change flush return type If a flush operation fails, then you now have chance of knowing about it. Change flush method, return false on failure Change flush test Ensuring that flush method does return false, should the delete directories return false. Change wrapper flush return type Both apcu_clear_cache() and apc_clear_cache() return bool values, which can indicate if flush operation fails. Change flush method, return bool Add Apc flush test Change flush method return type Change flush test, check return of flush method Change flush method return type The table delete() returns the number of affected rows. If the number is higher that zero, then the operation has succeeded. If not, it means that there was nothing to delete... Not too sure about this one, however, it should be the most correct response, if you do expect something to be deleted and zero is returned. Change flush test, check flush return Change flush method return type Memcached's flush method also returns true. Add flush test Change flush method return type Change flush method return type Not sure about flushdb() return. However, from what I understand, it never fails and thus should return something like "ok" back. Add flush test Add release note about cache flush change Revert "Ignore PHPStorm IDE file" This reverts commit 8176c328d5316e8508ad1c382b20841c2699b95e.
src/Illuminate/Cache/FileStore.php
@@ -182,15 +182,19 @@ public function forget($key) /** * Remove all items from the cache. * - * @return void + * @return bool */ public function flush() { if ($this->files->isDirectory($this->directory)) { foreach ($this->files->directories($this->directory) as $directory) { - $this->files->deleteDirectory($directory); + if(!$this->files->deleteDirectory($directory)){ + return false; + } } + return true; } + return false; } /**
true
Other
laravel
framework
4543caa9a45adbc2e127e8c92a70158bd191d83b.json
Change cache flush return type Change flush return type If a flush operation fails, then you now have chance of knowing about it. Change flush method, return false on failure Change flush test Ensuring that flush method does return false, should the delete directories return false. Change wrapper flush return type Both apcu_clear_cache() and apc_clear_cache() return bool values, which can indicate if flush operation fails. Change flush method, return bool Add Apc flush test Change flush method return type Change flush test, check return of flush method Change flush method return type The table delete() returns the number of affected rows. If the number is higher that zero, then the operation has succeeded. If not, it means that there was nothing to delete... Not too sure about this one, however, it should be the most correct response, if you do expect something to be deleted and zero is returned. Change flush test, check flush return Change flush method return type Memcached's flush method also returns true. Add flush test Change flush method return type Change flush method return type Not sure about flushdb() return. However, from what I understand, it never fails and thus should return something like "ok" back. Add flush test Add release note about cache flush change Revert "Ignore PHPStorm IDE file" This reverts commit 8176c328d5316e8508ad1c382b20841c2699b95e.
src/Illuminate/Cache/MemcachedStore.php
@@ -184,11 +184,11 @@ public function forget($key) /** * Remove all items from the cache. * - * @return void + * @return bool */ public function flush() { - $this->memcached->flush(); + return $this->memcached->flush(); } /**
true
Other
laravel
framework
4543caa9a45adbc2e127e8c92a70158bd191d83b.json
Change cache flush return type Change flush return type If a flush operation fails, then you now have chance of knowing about it. Change flush method, return false on failure Change flush test Ensuring that flush method does return false, should the delete directories return false. Change wrapper flush return type Both apcu_clear_cache() and apc_clear_cache() return bool values, which can indicate if flush operation fails. Change flush method, return bool Add Apc flush test Change flush method return type Change flush test, check return of flush method Change flush method return type The table delete() returns the number of affected rows. If the number is higher that zero, then the operation has succeeded. If not, it means that there was nothing to delete... Not too sure about this one, however, it should be the most correct response, if you do expect something to be deleted and zero is returned. Change flush test, check flush return Change flush method return type Memcached's flush method also returns true. Add flush test Change flush method return type Change flush method return type Not sure about flushdb() return. However, from what I understand, it never fails and thus should return something like "ok" back. Add flush test Add release note about cache flush change Revert "Ignore PHPStorm IDE file" This reverts commit 8176c328d5316e8508ad1c382b20841c2699b95e.
src/Illuminate/Cache/NullStore.php
@@ -89,7 +89,7 @@ public function forget($key) /** * Remove all items from the cache. * - * @return void + * @return bool */ public function flush() {
true
Other
laravel
framework
4543caa9a45adbc2e127e8c92a70158bd191d83b.json
Change cache flush return type Change flush return type If a flush operation fails, then you now have chance of knowing about it. Change flush method, return false on failure Change flush test Ensuring that flush method does return false, should the delete directories return false. Change wrapper flush return type Both apcu_clear_cache() and apc_clear_cache() return bool values, which can indicate if flush operation fails. Change flush method, return bool Add Apc flush test Change flush method return type Change flush test, check return of flush method Change flush method return type The table delete() returns the number of affected rows. If the number is higher that zero, then the operation has succeeded. If not, it means that there was nothing to delete... Not too sure about this one, however, it should be the most correct response, if you do expect something to be deleted and zero is returned. Change flush test, check flush return Change flush method return type Memcached's flush method also returns true. Add flush test Change flush method return type Change flush method return type Not sure about flushdb() return. However, from what I understand, it never fails and thus should return something like "ok" back. Add flush test Add release note about cache flush change Revert "Ignore PHPStorm IDE file" This reverts commit 8176c328d5316e8508ad1c382b20841c2699b95e.
src/Illuminate/Cache/RedisStore.php
@@ -166,11 +166,11 @@ public function forget($key) /** * Remove all items from the cache. * - * @return void + * @return bool */ public function flush() { - $this->connection()->flushdb(); + return (bool) $this->connection()->flushdb(); } /**
true
Other
laravel
framework
4543caa9a45adbc2e127e8c92a70158bd191d83b.json
Change cache flush return type Change flush return type If a flush operation fails, then you now have chance of knowing about it. Change flush method, return false on failure Change flush test Ensuring that flush method does return false, should the delete directories return false. Change wrapper flush return type Both apcu_clear_cache() and apc_clear_cache() return bool values, which can indicate if flush operation fails. Change flush method, return bool Add Apc flush test Change flush method return type Change flush test, check return of flush method Change flush method return type The table delete() returns the number of affected rows. If the number is higher that zero, then the operation has succeeded. If not, it means that there was nothing to delete... Not too sure about this one, however, it should be the most correct response, if you do expect something to be deleted and zero is returned. Change flush test, check flush return Change flush method return type Memcached's flush method also returns true. Add flush test Change flush method return type Change flush method return type Not sure about flushdb() return. However, from what I understand, it never fails and thus should return something like "ok" back. Add flush test Add release note about cache flush change Revert "Ignore PHPStorm IDE file" This reverts commit 8176c328d5316e8508ad1c382b20841c2699b95e.
src/Illuminate/Contracts/Cache/Store.php
@@ -79,7 +79,7 @@ public function forget($key); /** * Remove all items from the cache. * - * @return void + * @return bool */ public function flush();
true
Other
laravel
framework
4543caa9a45adbc2e127e8c92a70158bd191d83b.json
Change cache flush return type Change flush return type If a flush operation fails, then you now have chance of knowing about it. Change flush method, return false on failure Change flush test Ensuring that flush method does return false, should the delete directories return false. Change wrapper flush return type Both apcu_clear_cache() and apc_clear_cache() return bool values, which can indicate if flush operation fails. Change flush method, return bool Add Apc flush test Change flush method return type Change flush test, check return of flush method Change flush method return type The table delete() returns the number of affected rows. If the number is higher that zero, then the operation has succeeded. If not, it means that there was nothing to delete... Not too sure about this one, however, it should be the most correct response, if you do expect something to be deleted and zero is returned. Change flush test, check flush return Change flush method return type Memcached's flush method also returns true. Add flush test Change flush method return type Change flush method return type Not sure about flushdb() return. However, from what I understand, it never fails and thus should return something like "ok" back. Add flush test Add release note about cache flush change Revert "Ignore PHPStorm IDE file" This reverts commit 8176c328d5316e8508ad1c382b20841c2699b95e.
tests/Cache/CacheApcStoreTest.php
@@ -91,4 +91,13 @@ public function testForgetMethodProperlyCallsAPC() $store = new Illuminate\Cache\ApcStore($apc); $store->forget('foo'); } + + public function testFlushesCached() + { + $apc = $this->getMockBuilder('Illuminate\Cache\ApcWrapper')->setMethods(['flush'])->getMock(); + $apc->expects($this->once())->method('flush')->willReturn(true); + $store = new Illuminate\Cache\ApcStore($apc); + $result = $store->flush(); + $this->assertTrue($result); + } }
true
Other
laravel
framework
4543caa9a45adbc2e127e8c92a70158bd191d83b.json
Change cache flush return type Change flush return type If a flush operation fails, then you now have chance of knowing about it. Change flush method, return false on failure Change flush test Ensuring that flush method does return false, should the delete directories return false. Change wrapper flush return type Both apcu_clear_cache() and apc_clear_cache() return bool values, which can indicate if flush operation fails. Change flush method, return bool Add Apc flush test Change flush method return type Change flush test, check return of flush method Change flush method return type The table delete() returns the number of affected rows. If the number is higher that zero, then the operation has succeeded. If not, it means that there was nothing to delete... Not too sure about this one, however, it should be the most correct response, if you do expect something to be deleted and zero is returned. Change flush test, check flush return Change flush method return type Memcached's flush method also returns true. Add flush test Change flush method return type Change flush method return type Not sure about flushdb() return. However, from what I understand, it never fails and thus should return something like "ok" back. Add flush test Add release note about cache flush change Revert "Ignore PHPStorm IDE file" This reverts commit 8176c328d5316e8508ad1c382b20841c2699b95e.
tests/Cache/CacheArrayStoreTest.php
@@ -63,7 +63,8 @@ public function testItemsCanBeFlushed() $store = new ArrayStore; $store->put('foo', 'bar', 10); $store->put('baz', 'boom', 10); - $store->flush(); + $result = $store->flush(); + $this->assertTrue($result); $this->assertNull($store->get('foo')); $this->assertNull($store->get('baz')); }
true
Other
laravel
framework
4543caa9a45adbc2e127e8c92a70158bd191d83b.json
Change cache flush return type Change flush return type If a flush operation fails, then you now have chance of knowing about it. Change flush method, return false on failure Change flush test Ensuring that flush method does return false, should the delete directories return false. Change wrapper flush return type Both apcu_clear_cache() and apc_clear_cache() return bool values, which can indicate if flush operation fails. Change flush method, return bool Add Apc flush test Change flush method return type Change flush test, check return of flush method Change flush method return type The table delete() returns the number of affected rows. If the number is higher that zero, then the operation has succeeded. If not, it means that there was nothing to delete... Not too sure about this one, however, it should be the most correct response, if you do expect something to be deleted and zero is returned. Change flush test, check flush return Change flush method return type Memcached's flush method also returns true. Add flush test Change flush method return type Change flush method return type Not sure about flushdb() return. However, from what I understand, it never fails and thus should return something like "ok" back. Add flush test Add release note about cache flush change Revert "Ignore PHPStorm IDE file" This reverts commit 8176c328d5316e8508ad1c382b20841c2699b95e.
tests/Cache/CacheDatabaseStoreTest.php
@@ -96,9 +96,10 @@ public function testItemsMayBeFlushedFromCache() $store = $this->getStore(); $table = m::mock('StdClass'); $store->getConnection()->shouldReceive('table')->once()->with('table')->andReturn($table); - $table->shouldReceive('delete')->once(); + $table->shouldReceive('delete')->once()->andReturn(2); - $store->flush(); + $result = $store->flush(); + $this->assertTrue($result); } public function testIncrementReturnsCorrectValues()
true
Other
laravel
framework
4543caa9a45adbc2e127e8c92a70158bd191d83b.json
Change cache flush return type Change flush return type If a flush operation fails, then you now have chance of knowing about it. Change flush method, return false on failure Change flush test Ensuring that flush method does return false, should the delete directories return false. Change wrapper flush return type Both apcu_clear_cache() and apc_clear_cache() return bool values, which can indicate if flush operation fails. Change flush method, return bool Add Apc flush test Change flush method return type Change flush test, check return of flush method Change flush method return type The table delete() returns the number of affected rows. If the number is higher that zero, then the operation has succeeded. If not, it means that there was nothing to delete... Not too sure about this one, however, it should be the most correct response, if you do expect something to be deleted and zero is returned. Change flush test, check flush return Change flush method return type Memcached's flush method also returns true. Add flush test Change flush method return type Change flush method return type Not sure about flushdb() return. However, from what I understand, it never fails and thus should return something like "ok" back. Add flush test Add release note about cache flush change Revert "Ignore PHPStorm IDE file" This reverts commit 8176c328d5316e8508ad1c382b20841c2699b95e.
tests/Cache/CacheFileStoreTest.php
@@ -120,10 +120,23 @@ public function testFlushCleansDirectory() $files = $this->mockFilesystem(); $files->expects($this->once())->method('isDirectory')->with($this->equalTo(__DIR__))->will($this->returnValue(true)); $files->expects($this->once())->method('directories')->with($this->equalTo(__DIR__))->will($this->returnValue(['foo'])); - $files->expects($this->once())->method('deleteDirectory')->with($this->equalTo('foo')); + $files->expects($this->once())->method('deleteDirectory')->with($this->equalTo('foo'))->will($this->returnValue(true)); $store = new FileStore($files, __DIR__); - $store->flush(); + $result = $store->flush(); + $this->assertTrue($result, 'Flush failed'); + } + + public function testFlushFailsDirectoryClean() + { + $files = $this->mockFilesystem(); + $files->expects($this->once())->method('isDirectory')->with($this->equalTo(__DIR__))->will($this->returnValue(true)); + $files->expects($this->once())->method('directories')->with($this->equalTo(__DIR__))->will($this->returnValue(['foo'])); + $files->expects($this->once())->method('deleteDirectory')->with($this->equalTo('foo'))->will($this->returnValue(false)); + + $store = new FileStore($files, __DIR__); + $result = $store->flush(); + $this->assertFalse($result, 'Flush should not have cleared directories'); } public function testFlushIgnoreNonExistingDirectory() @@ -132,7 +145,8 @@ public function testFlushIgnoreNonExistingDirectory() $files->expects($this->once())->method('isDirectory')->with($this->equalTo(__DIR__.'--wrong'))->will($this->returnValue(false)); $store = new FileStore($files, __DIR__.'--wrong'); - $store->flush(); + $result = $store->flush(); + $this->assertFalse($result, 'Flush should not clean directory'); } protected function mockFilesystem()
true
Other
laravel
framework
4543caa9a45adbc2e127e8c92a70158bd191d83b.json
Change cache flush return type Change flush return type If a flush operation fails, then you now have chance of knowing about it. Change flush method, return false on failure Change flush test Ensuring that flush method does return false, should the delete directories return false. Change wrapper flush return type Both apcu_clear_cache() and apc_clear_cache() return bool values, which can indicate if flush operation fails. Change flush method, return bool Add Apc flush test Change flush method return type Change flush test, check return of flush method Change flush method return type The table delete() returns the number of affected rows. If the number is higher that zero, then the operation has succeeded. If not, it means that there was nothing to delete... Not too sure about this one, however, it should be the most correct response, if you do expect something to be deleted and zero is returned. Change flush test, check flush return Change flush method return type Memcached's flush method also returns true. Add flush test Change flush method return type Change flush method return type Not sure about flushdb() return. However, from what I understand, it never fails and thus should return something like "ok" back. Add flush test Add release note about cache flush change Revert "Ignore PHPStorm IDE file" This reverts commit 8176c328d5316e8508ad1c382b20841c2699b95e.
tests/Cache/CacheMemcachedStoreTest.php
@@ -105,6 +105,19 @@ public function testForgetMethodProperlyCallsMemcache() $store->forget('foo'); } + public function testFlushesCached() + { + if (! class_exists('Memcached')) { + $this->markTestSkipped('Memcached module not installed'); + } + + $memcache = $this->getMockBuilder('Memcached')->setMethods(['flush'])->getMock(); + $memcache->expects($this->once())->method('flush')->willReturn(true); + $store = new Illuminate\Cache\MemcachedStore($memcache); + $result = $store->flush(); + $this->assertTrue($result); + } + public function testGetAndSetPrefix() { if (! class_exists('Memcached')) {
true
Other
laravel
framework
4543caa9a45adbc2e127e8c92a70158bd191d83b.json
Change cache flush return type Change flush return type If a flush operation fails, then you now have chance of knowing about it. Change flush method, return false on failure Change flush test Ensuring that flush method does return false, should the delete directories return false. Change wrapper flush return type Both apcu_clear_cache() and apc_clear_cache() return bool values, which can indicate if flush operation fails. Change flush method, return bool Add Apc flush test Change flush method return type Change flush test, check return of flush method Change flush method return type The table delete() returns the number of affected rows. If the number is higher that zero, then the operation has succeeded. If not, it means that there was nothing to delete... Not too sure about this one, however, it should be the most correct response, if you do expect something to be deleted and zero is returned. Change flush test, check flush return Change flush method return type Memcached's flush method also returns true. Add flush test Change flush method return type Change flush method return type Not sure about flushdb() return. However, from what I understand, it never fails and thus should return something like "ok" back. Add flush test Add release note about cache flush change Revert "Ignore PHPStorm IDE file" This reverts commit 8176c328d5316e8508ad1c382b20841c2699b95e.
tests/Cache/CacheRedisStoreTest.php
@@ -119,6 +119,15 @@ public function testForgetMethodProperlyCallsRedis() $redis->forget('foo'); } + public function testFlushesCached() + { + $redis = $this->getRedis(); + $redis->getRedis()->shouldReceive('connection')->once()->with('default')->andReturn($redis->getRedis()); + $redis->getRedis()->shouldReceive('flushdb')->once()->andReturn('ok'); + $result = $redis->flush(); + $this->assertTrue($result); + } + public function testGetAndSetPrefix() { $redis = $this->getRedis();
true
Other
laravel
framework
cb2eb7963b29aafe63c87e1d2b1e633ecd0c25b0.json
use a collection
src/Illuminate/Foundation/Console/RouteListCommand.php
@@ -138,15 +138,9 @@ protected function displayRoutes(array $routes) */ protected function getMiddleware($route) { - $middlewares = $route->gatherMiddleware(); - - foreach ($middlewares as $i => $middleware) { - if ($middleware instanceof Closure) { - $middlewares[$i] = 'Closure'; - } - } - - return implode(',', $middlewares); + return collect($route->gatherMiddleware())->map(function ($middleware) { + return $middleware instanceof Closure ? 'Closure' : $middleware; + })->implode(','); } /**
false
Other
laravel
framework
3562235233d159e8adbc6c22507339dc1dc2af51.json
create a resource controller along with the model it's incredibly common for me to make a resource controller for most of my models, so it'd be nice do it in one line. while this would be a nicety, I can also see someone arguing that this adds unnecessary complexity, when it's already easy enough to just run the commands one after the other. curious where you stand on this, because we could just as easily add an option to create a seeder at the same time.
src/Illuminate/Foundation/Console/ModelMakeCommand.php
@@ -42,6 +42,11 @@ public function fire() $this->call('make:migration', ['name' => "create_{$table}_table", '--create' => $table]); } + if ($this->option('controller')) { + $controller = Str::camel(class_basename($this->argument('name'))); + + $this->call('make:controller', ['name' => "{$controller}Controller", '--resource' => true]); + } } } @@ -75,6 +80,7 @@ protected function getOptions() { return [ ['migration', 'm', InputOption::VALUE_NONE, 'Create a new migration file for the model.'], + ['controller', 'c', InputOption::VALUE_NONE, 'Create a new resource controller for the model.'], ]; } }
false
Other
laravel
framework
1c78e00ef3815e7b0bf710037b52faefb464e97d.json
send eloquent collection for proper serializationg
src/Illuminate/Notifications/ChannelManager.php
@@ -114,7 +114,7 @@ protected function queueNotification($notifiables, $notification) foreach ($notifiables as $notifiable) { foreach ($notification->via($notifiable) as $channel) { $bus->dispatch( - (new SendQueuedNotifications([$notifiable], $notification, [$channel])) + (new SendQueuedNotifications($this->formatNotifiables($notifiable), $notification, [$channel])) ->onConnection($notification->connection) ->onQueue($notification->queue) ->delay($notification->delay)
false
Other
laravel
framework
34ad9726ad9de2069f3761bf3c75d00f9771f563.json
Hide developer hints in html (#15786) Turn html comments into blade comments so that the resulting html is cleaner.
src/Illuminate/Pagination/resources/views/bootstrap-4.blade.php
@@ -1,20 +1,20 @@ @if ($paginator->hasPages()) <ul class="pagination"> - <!-- Previous Page Link --> + {{-- Previous Page Link --}} @if ($paginator->onFirstPage()) <li class="page-item disabled"><span class="page-link">&laquo;</span></li> @else <li class="page-item"><a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev">&laquo;</a></li> @endif - <!-- Pagination Elements --> + {{-- Pagination Elements --}} @foreach ($elements as $element) - <!-- "Three Dots" Separator --> + {{-- "Three Dots" Separator --}} @if (is_string($element)) <li class="page-item disabled"><span class="page-link">{{ $element }}</span></li> @endif - <!-- Array Of Links --> + {{-- Array Of Links --}} @if (is_array($element)) @foreach ($element as $page => $url) @if ($page == $paginator->currentPage()) @@ -26,7 +26,7 @@ @endif @endforeach - <!-- Next Page Link --> + {{-- Next Page Link --}} @if ($paginator->hasMorePages()) <li class="page-item"><a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">&raquo;</a></li> @else
true
Other
laravel
framework
34ad9726ad9de2069f3761bf3c75d00f9771f563.json
Hide developer hints in html (#15786) Turn html comments into blade comments so that the resulting html is cleaner.
src/Illuminate/Pagination/resources/views/default.blade.php
@@ -1,20 +1,20 @@ @if ($paginator->hasPages()) <ul class="pagination"> - <!-- Previous Page Link --> + {{-- Previous Page Link --}} @if ($paginator->onFirstPage()) <li class="disabled"><span>&laquo;</span></li> @else <li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">&laquo;</a></li> @endif - <!-- Pagination Elements --> + {{-- Pagination Elements --}} @foreach ($elements as $element) - <!-- "Three Dots" Separator --> + {{-- "Three Dots" Separator --}} @if (is_string($element)) <li class="disabled"><span>{{ $element }}</span></li> @endif - <!-- Array Of Links --> + {{-- Array Of Links --}} @if (is_array($element)) @foreach ($element as $page => $url) @if ($page == $paginator->currentPage()) @@ -26,7 +26,7 @@ @endif @endforeach - <!-- Next Page Link --> + {{-- Next Page Link --}} @if ($paginator->hasMorePages()) <li><a href="{{ $paginator->nextPageUrl() }}" rel="next">&raquo;</a></li> @else
true
Other
laravel
framework
34ad9726ad9de2069f3761bf3c75d00f9771f563.json
Hide developer hints in html (#15786) Turn html comments into blade comments so that the resulting html is cleaner.
src/Illuminate/Pagination/resources/views/simple-bootstrap-4.blade.php
@@ -1,13 +1,13 @@ @if ($paginator->hasPages()) <ul class="pagination"> - <!-- Previous Page Link --> + {{-- Previous Page Link --}} @if ($paginator->onFirstPage()) <li class="page-item disabled"><span class="page-link">&laquo;</span></li> @else <li class="page-item"><a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev">&laquo;</a></li> @endif - <!-- Next Page Link --> + {{-- Next Page Link --}} @if ($paginator->hasMorePages()) <li class="page-item"><a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">&raquo;</a></li> @else
true
Other
laravel
framework
34ad9726ad9de2069f3761bf3c75d00f9771f563.json
Hide developer hints in html (#15786) Turn html comments into blade comments so that the resulting html is cleaner.
src/Illuminate/Pagination/resources/views/simple-default.blade.php
@@ -1,13 +1,13 @@ @if ($paginator->hasPages()) <ul class="pagination"> - <!-- Previous Page Link --> + {{-- Previous Page Link --}} @if ($paginator->onFirstPage()) <li class="disabled"><span>&laquo;</span></li> @else <li><a href="{{ $paginator->previousPageUrl() }}" rel="prev">&laquo;</a></li> @endif - <!-- Next Page Link --> + {{-- Next Page Link --}} @if ($paginator->hasMorePages()) <li><a href="{{ $paginator->nextPageUrl() }}" rel="next">&raquo;</a></li> @else
true
Other
laravel
framework
242f52f83567ae0d3351744cc98e5a2fbab68592.json
fix a few bugs
src/Illuminate/Database/Eloquent/Factory.php
@@ -90,7 +90,7 @@ public function define($class, callable $attributes, $name = 'default') */ public function state($class, $state, callable $attributes) { - $this->modifiers[$class][$state] = $attributes; + $this->states[$class][$state] = $attributes; } /** @@ -199,7 +199,7 @@ public function raw($class, array $attributes = [], $name = 'default') */ public function of($class, $name = 'default') { - return new FactoryBuilder($class, $name, $this->definitions, $this->faker, $this->states); + return new FactoryBuilder($class, $name, $this->definitions, $this->states, $this->faker); } /**
false
Other
laravel
framework
4ef6fd76d5bcf3590f930ec262f1f0756eeaed3b.json
Fix a typo
src/Illuminate/Database/Migrations/Migrator.php
@@ -365,7 +365,7 @@ protected function getQueries($migration, $method) * Run a migration, inside a transaction if the database supports it. * * @param \Closure $callback - * @retrun void + * @return void */ protected function runMigration(Closure $callback) {
false
Other
laravel
framework
f67e081cb48ef1bdbe7821a03f850442b501461f.json
fix various formatting issues
src/Illuminate/Validation/Validator.php
@@ -247,18 +247,19 @@ protected function hydrateFiles(array $data, $arrayKey = null) } foreach ($data as $key => $value) { - $new_key = ($arrayKey) ? "$arrayKey.$key" : $key; + $newKey = ($arrayKey) ? "$arrayKey.$key" : $key; // If this value is an instance of the HttpFoundation File class we will // remove it from the data array and add it to the files array, which // we use to conveniently separate out these files from other data. if ($value instanceof File) { - $this->files[$new_key] = $value; + $this->files[$newKey] = $value; unset($data[$key]); } elseif (is_array($value)) { if (! empty($value)) { - $value = $this->hydrateFiles($value, $new_key); + $value = $this->hydrateFiles($value, $newKey); + if (empty($value)) { unset($data[$key]); } @@ -340,8 +341,7 @@ public function sometimes($attribute, $rules, callable $callback) public function each($attribute, $rules) { $data = array_merge( - Arr::dot($this->initializeAttributeOnData($attribute)), - $this->files + Arr::dot($this->initializeAttributeOnData($attribute)), $this->files ); $pattern = str_replace('\*', '[^\.]+', preg_quote($attribute));
false
Other
laravel
framework
061f54e319c72e320e9759860ef5a44fc37bda2b.json
fix import order
src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php
@@ -9,8 +9,8 @@ use Illuminate\Contracts\View\View; use PHPUnit_Framework_Assert as PHPUnit; use PHPUnit_Framework_ExpectationFailedException; -use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile; use Symfony\Component\HttpFoundation\Request as SymfonyRequest; +use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile; trait MakesHttpRequests {
false
Other
laravel
framework
08bcbdbe70b69330943cc45625b160877b37341a.json
Add a top level #app id.
src/Illuminate/Auth/Console/stubs/make/views/layouts/app.stub
@@ -21,63 +21,65 @@ </script> </head> <body> - <nav class="navbar navbar-default navbar-static-top"> - <div class="container"> - <div class="navbar-header"> + <div id="app"> + <nav class="navbar navbar-default navbar-static-top"> + <div class="container"> + <div class="navbar-header"> - <!-- Collapsed Hamburger --> - <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse"> - <span class="sr-only">Toggle Navigation</span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - </button> + <!-- Collapsed Hamburger --> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse"> + <span class="sr-only">Toggle Navigation</span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> - <!-- Branding Image --> - <a class="navbar-brand" href="{{ url('/') }}"> - {{ config('app.name', 'Laravel') }} - </a> - </div> + <!-- Branding Image --> + <a class="navbar-brand" href="{{ url('/') }}"> + {{ config('app.name', 'Laravel') }} + </a> + </div> - <div class="collapse navbar-collapse" id="app-navbar-collapse"> - <!-- Left Side Of Navbar --> - <ul class="nav navbar-nav"> - &nbsp; - </ul> + <div class="collapse navbar-collapse" id="app-navbar-collapse"> + <!-- Left Side Of Navbar --> + <ul class="nav navbar-nav"> + &nbsp; + </ul> - <!-- Right Side Of Navbar --> - <ul class="nav navbar-nav navbar-right"> - <!-- Authentication Links --> - @if (Auth::guest()) - <li><a href="{{ url('/login') }}">Login</a></li> - <li><a href="{{ url('/register') }}">Register</a></li> - @else - <li class="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> - {{ Auth::user()->name }} <span class="caret"></span> - </a> + <!-- Right Side Of Navbar --> + <ul class="nav navbar-nav navbar-right"> + <!-- Authentication Links --> + @if (Auth::guest()) + <li><a href="{{ url('/login') }}">Login</a></li> + <li><a href="{{ url('/register') }}">Register</a></li> + @else + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> + {{ Auth::user()->name }} <span class="caret"></span> + </a> - <ul class="dropdown-menu" role="menu"> - <li> - <a href="{{ url('/logout') }}" - onclick="event.preventDefault(); - document.getElementById('logout-form').submit();"> - Logout - </a> + <ul class="dropdown-menu" role="menu"> + <li> + <a href="{{ url('/logout') }}" + onclick="event.preventDefault(); + document.getElementById('logout-form').submit();"> + Logout + </a> - <form id="logout-form" action="{{ url('/logout') }}" method="POST" style="display: none;"> - {{ csrf_field() }} - </form> - </li> - </ul> - </li> - @endif - </ul> + <form id="logout-form" action="{{ url('/logout') }}" method="POST" style="display: none;"> + {{ csrf_field() }} + </form> + </li> + </ul> + </li> + @endif + </ul> + </div> </div> - </div> - </nav> + </nav> - @yield('content') + @yield('content') + </div> <!-- Scripts --> <script src="/js/app.js"></script>
false
Other
laravel
framework
6b1075e479eacda7d131ccb0da525be2dfe33eb3.json
Add Seneca quote to Inspire command (#15747)
src/Illuminate/Foundation/Inspiring.php
@@ -26,6 +26,7 @@ public static function quote() 'Well begun is half done. - Aristotle', 'He who is contented is rich. - Laozi', 'Very little is needed to make a happy life. - Marcus Antoninus', + 'It is quality rather than quantity that matters. - Lucius Annaeus Seneca', ])->random(); }
false
Other
laravel
framework
cc9e1f09683fd23cf8e973e84bf310f7ce1304a2.json
register timeout handlers on php 7.1
src/Illuminate/Queue/Worker.php
@@ -70,6 +70,8 @@ public function daemon($connectionName, $queue, WorkerOptions $options) $lastRestart = $this->getTimestampOfLastQueueRestart(); while (true) { + $this->registerTimeoutHandler($options); + if ($this->daemonShouldRun()) { $this->runNextJob($connectionName, $queue, $options); } else { @@ -83,6 +85,29 @@ public function daemon($connectionName, $queue, WorkerOptions $options) } } + /** + * Register the worker timeout handler (PHP 7.1+). + * + * @param WorkerOptions $options + * @return void + */ + protected function registerTimeoutHandler(WorkerOptions $options) + { + if (version_compare(PHP_VERSION, '7.1.0') < 0 || ! extension_loaded('pcntl')) { + return; + } + + pcntl_async_signals(true); + + pcntl_signal(SIGALRM, function () { + $this->exceptions->report(new TimeoutException("A queue worker timed out while processing a job.")); + + exit(1); + }); + + pcntl_alarm($options->timeout + $options->sleep); + } + /** * Determine if the daemon should process on this iteration. *
false
Other
laravel
framework
45455d798ab3099815004ab0cc136d027dbb735f.json
fix minor document mistakes. (#15711)
src/Illuminate/Mail/Message.php
@@ -86,7 +86,7 @@ public function to($address, $name = null, $override = false) /** * Add a carbon copy to the message. * - * @param string $address + * @param string|array $address * @param string|null $name * @return $this */ @@ -98,7 +98,7 @@ public function cc($address, $name = null) /** * Add a blind carbon copy to the message. * - * @param string $address + * @param string|array $address * @param string|null $name * @return $this */
false
Other
laravel
framework
769ccaebc520a84f59ba62d8639b75f5081c03cf.json
Update Pluralizer.php (#15703) Added some more words that I come across.
src/Illuminate/Support/Pluralizer.php
@@ -23,6 +23,7 @@ class Pluralizer 'emoji', 'equipment', 'fish', + 'furniture', 'gold', 'information', 'knowledge', @@ -41,6 +42,7 @@ class Pluralizer 'species', 'swine', 'traffic', + 'wheat', ]; /**
false
Other
laravel
framework
e6a81b6d3617b6de3baa87afbc1bd68ae91ea1ba.json
Add missing property. (#15664)
src/Illuminate/Session/CookieSessionHandler.php
@@ -23,6 +23,13 @@ class CookieSessionHandler implements SessionHandlerInterface */ protected $request; + /* + * The number of minutes the session should be valid. + * + * @var int + */ + protected $minutes; + /** * Create a new cookie driven handler instance. *
false
Other
laravel
framework
38684f94871e66a599644b605b02c4bcac3ea088.json
Allow array of strings/arrays, optional name attr This works in 5.3: Mail::to('name1@example.com')->send(new OrderShipped($order)); And this works too: $user1 = User::find(1); $user2 = User::find(2); Mail::to([$user1, $user2])->send(new OrderShipped($order)); However this does not work in 5.3: Mail::to(['name1@example.com','name2@example.com'])->send(new OrderShipped($order)); And this does not work in 5.3 too: $user1 = User::find(1)->toArray(); $user2 = User::find(2)->toArray(); Mail::to([$user1, $user2])->send(new OrderShipped($order)); This commmit implements all cases plus it allows to not to have 'name' attribute in User model (User models often have first_name and last_name).
src/Illuminate/Mail/Mailable.php
@@ -374,7 +374,12 @@ protected function setAddress($address, $name = null, $property = 'to') if ($address instanceof Collection || is_array($address)) { foreach ($address as $user) { - $this->{$property}($user->email, $user->name); + if (is_array($user)){ + $user = (object) $user; + }elseif (is_string($user)) { + $user = (object) ['email' => $user]; + } + $this->{$property}($user->email, isset($user->name) ? $user->name : null); } } else { $this->{$property}[] = compact('address', 'name');
false
Other
laravel
framework
ab0801cf08df7d448b1047892eabec07407739f6.json
change method order
src/Illuminate/Contracts/Translation/Translator.php
@@ -26,17 +26,17 @@ public function trans($key, array $replace = [], $locale = null); public function transChoice($key, $number, array $replace = [], $locale = null); /** - * Set the default locale. + * Get the default locale being used. * - * @param string $locale - * @return void + * @return string */ - public function setLocale($locale); + public function getLocale(); /** - * Get the default locale being used. + * Set the default locale. * - * @return string + * @param string $locale + * @return void */ - public function getLocale(); + public function setLocale($locale); }
false
Other
laravel
framework
33c6f9a19e0e19d8d1610e26c00d8acad58a5d71.json
Add tests for beginTransaction() retrying
src/Illuminate/Database/Connection.php
@@ -505,11 +505,11 @@ public function beginTransaction() { if ($this->transactions == 0) { try { - $this->getPdo()->beginTransaction(); + $this->pdo->beginTransaction(); } catch (Exception $e) { if ($this->causedByLostConnection($e)) { $this->reconnect(); - $this->getPdo()->beginTransaction(); + $this->pdo->beginTransaction(); } else { throw $e; }
true
Other
laravel
framework
33c6f9a19e0e19d8d1610e26c00d8acad58a5d71.json
Add tests for beginTransaction() retrying
tests/Database/DatabaseConnectionTest.php
@@ -123,6 +123,36 @@ public function testTransactionLevelNotIncrementedOnTransactionException() } } + public function testBeginTransactionMethodRetriesOnFailure() + { + $pdo = $this->getMock('DatabaseConnectionTestMockPDO'); + $pdo->expects($this->exactly(2))->method('beginTransaction'); + $pdo->expects($this->at(0))->method('beginTransaction')->will($this->throwException(new ErrorException('server has gone away'))); + $connection = $this->getMockConnection(['reconnect'], $pdo); + $connection->expects($this->once())->method('reconnect'); + $connection->beginTransaction(); + $this->assertEquals(1, $connection->transactionLevel()); + } + + public function testBeginTransactionMethodNeverRetriesIfWithinTransaction() + { + $pdo = $this->getMock('DatabaseConnectionTestMockPDO'); + $pdo->expects($this->once())->method('beginTransaction'); + $pdo->expects($this->once())->method('exec')->will($this->throwException(new Exception)); + $connection = $this->getMockConnection([], $pdo); + $queryGrammar = $this->getMock('Illuminate\Database\Query\Grammars\Grammar'); + $queryGrammar->expects($this->once())->method('supportsSavepoints')->will($this->returnValue(true)); + $connection->setQueryGrammar($queryGrammar); + $connection->expects($this->never())->method('reconnect'); + $connection->beginTransaction(); + $this->assertEquals(1, $connection->transactionLevel()); + try { + $connection->beginTransaction(); + } catch (Exception $e) { + $this->assertEquals(1, $connection->transactionLevel()); + } + } + /** * @expectedException RuntimeException */
true
Other
laravel
framework
7c9d04e27ff699ae9ff537d4dacac4f96ab7181e.json
use carbon addMinutes() function (#15545)
src/Illuminate/Cache/MemcachedStore.php
@@ -182,7 +182,7 @@ public function flush() */ protected function toTimestamp($minutes) { - return $minutes > 0 ? Carbon::now()->timestamp + ((int) $minutes * 60) : 0; + return $minutes > 0 ? Carbon::now()->addMinutes($minutes)->timestamp : 0; } /**
false
Other
laravel
framework
c5984af3757e492c6e79cef161169ea09b5b9c7a.json
send unix timestamp to memcached
src/Illuminate/Cache/MemcachedStore.php
@@ -3,6 +3,7 @@ namespace Illuminate\Cache; use Memcached; +use Carbon\Carbon; use Illuminate\Contracts\Cache\Store; class MemcachedStore extends TaggableStore implements Store @@ -82,7 +83,7 @@ public function many(array $keys) */ public function put($key, $value, $minutes) { - $this->memcached->set($this->prefix.$key, $value, (int) ($minutes * 60)); + $this->memcached->set($this->prefix.$key, $value, $this->toTimestamp($minutes)); } /** @@ -100,7 +101,7 @@ public function putMany(array $values, $minutes) $prefixedValues[$this->prefix.$key] = $value; } - $this->memcached->setMulti($prefixedValues, (int) ($minutes * 60)); + $this->memcached->setMulti($prefixedValues, $this->toTimestamp($minutes)); } /** @@ -113,7 +114,7 @@ public function putMany(array $values, $minutes) */ public function add($key, $value, $minutes) { - return $this->memcached->add($this->prefix.$key, $value, (int) ($minutes * 60)); + return $this->memcached->add($this->prefix.$key, $value, $this->toTimestamp($minutes)); } /** @@ -173,6 +174,17 @@ public function flush() $this->memcached->flush(); } + /** + * Get the UNIX timestamp for the given number of minutes. + * + * @parma int $minutes + * @return int + */ + protected function toTimestamp($minutes) + { + return $minutes > 0 ? Carbon::now()->timestamp + ((int) $minutes * 60) : 0; + } + /** * Get the underlying Memcached connection. *
true
Other
laravel
framework
c5984af3757e492c6e79cef161169ea09b5b9c7a.json
send unix timestamp to memcached
tests/Cache/CacheMemcachedStoreTest.php
@@ -49,10 +49,12 @@ public function testSetMethodProperlyCallsMemcache() $this->markTestSkipped('Memcached module not installed'); } + Carbon\Carbon::setTestNow($now = Carbon\Carbon::now()); $memcache = $this->getMockBuilder('Memcached')->setMethods(['set'])->getMock(); - $memcache->expects($this->once())->method('set')->with($this->equalTo('foo'), $this->equalTo('bar'), $this->equalTo(60)); + $memcache->expects($this->once())->method('set')->with($this->equalTo('foo'), $this->equalTo('bar'), $this->equalTo($now->timestamp + 60)); $store = new Illuminate\Cache\MemcachedStore($memcache); $store->put('foo', 'bar', 1); + Carbon\Carbon::setTestNow(); } public function testIncrementMethodProperlyCallsMemcache()
true
Other
laravel
framework
2fb90f4c66ecc5bee876e701bbef1879dbb8b2be.json
fix Collection import on NotificationFake (#15506)
src/Illuminate/Support/Testing/Fakes/NotificationFake.php
@@ -3,6 +3,7 @@ namespace Illuminate\Support\Testing\Fakes; use Ramsey\Uuid\Uuid; +use Illuminate\Support\Collection; use PHPUnit_Framework_Assert as PHPUnit; use Illuminate\Contracts\Notifications\Factory as NotificationFactory;
false
Other
laravel
framework
2ef1a22e911b2df978960fcff17873e7420c7c15.json
Add connection method to QueueFake
src/Illuminate/Support/Testing/Fakes/QueueFake.php
@@ -191,4 +191,15 @@ public function pop($queue = null) { // } + + /** + * Return fake queue. + * + * @param string $value + * @return \Illuminate\Contracts\Queue\Queue + */ + public function connection($value = null) + { + return $this; + } }
false
Other
laravel
framework
92b34069c1c36aef1e298174b2c3fbbe8511f28d.json
Remove uninstantiable seeder class (#15450)
src/Illuminate/Database/SeedServiceProvider.php
@@ -21,10 +21,6 @@ class SeedServiceProvider extends ServiceProvider */ public function register() { - $this->app->singleton('seeder', function () { - return new Seeder; - }); - $this->registerSeedCommand(); $this->commands('command.seed');
false
Other
laravel
framework
9ae949ffdc3cde39f91dcc0b7db7452586bd6c79.json
Remove unused method (#15446)
src/Illuminate/Foundation/Auth/SendsPasswordResetEmails.php
@@ -31,7 +31,7 @@ public function sendResetLinkEmail(Request $request) // to send the link, we will examine the response then see the message we // need to show to the user. Finally, we'll send out a proper response. $response = $this->broker()->sendResetLink( - $request->only('email'), $this->resetNotifier() + $request->only('email') ); if ($response === Password::RESET_LINK_SENT) { @@ -46,16 +46,6 @@ public function sendResetLinkEmail(Request $request) ); } - /** - * Get the Closure which is used to build the password reset notification. - * - * @return \Closure - */ - protected function resetNotifier() - { - // - } - /** * Get the broker to be used during password reset. *
false
Other
laravel
framework
4df539c76353ff1931b0441f0d8f3f07bbf7b342.json
Add missing parameter to toMail (#15448)
src/Illuminate/Auth/Notifications/ResetPassword.php
@@ -39,9 +39,10 @@ public function via($notifiable) /** * Build the mail representation of the notification. * + * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail() + public function toMail($notifiable) { return (new MailMessage) ->line('You are receiving this email because we received a password reset request for your account.')
false
Other
laravel
framework
40438b3b88d7164f3c18f463ee1587bde9ad8ef4.json
Fix pcntl extension error for queue (#15393)
src/Illuminate/Queue/Console/ListenCommand.php
@@ -2,6 +2,7 @@ namespace Illuminate\Queue\Console; +use RuntimeException; use Illuminate\Queue\Listener; use Illuminate\Console\Command; use Symfony\Component\Console\Input\InputOption; @@ -47,6 +48,8 @@ public function __construct(Listener $listener) * Execute the console command. * * @return void + * + * @throws \RuntimeException */ public function fire() { @@ -63,6 +66,10 @@ public function fire() $timeout = $this->input->getOption('timeout'); + if ($timeout && ! function_exists('pcntl_fork')) { + throw new RuntimeException('Timeouts not supported without the pcntl_fork extension.'); + } + // We need to get the right queue for the connection which is set in the queue // configuration file for the application. We will pull it based on the set // connection being run for the queue operation currently being executed.
false
Other
laravel
framework
3130be90548f1c4e986138ce2bb224f29ab73f92.json
Add SSL options for Postgres DSN (#15371) * Add SSL options for Postgres DSN There is already the SSLMODE option available, but if you set it to verify-full, you would need to also set the sslrootcert with the full path of the server certificate. This way, the client will be able to check the certificate of the server and be sure it's connecting to the right one. This patch is only adding the different SSL option available for a postgres connection has stated here: https://www.postgresql.org/docs/9.5/static/libpq-connect.html * Fix Style-Ci
src/Illuminate/Database/Connectors/PostgresConnector.php
@@ -97,6 +97,18 @@ protected function getDsn(array $config) $dsn .= ";sslmode={$sslmode}"; } + if (isset($config['sslcert'])) { + $dsn .= ";sslcert={$sslcert}"; + } + + if (isset($config['sslkey'])) { + $dsn .= ";sslkey={$sslkey}"; + } + + if (isset($config['sslrootcert'])) { + $dsn .= ";sslrootcert={$sslrootcert}"; + } + return $dsn; }
false
Other
laravel
framework
eb6e0fd3d77193f392181a12bef51a1c721652e7.json
Fix fatal error on file uploads (#15350) PR #15250 broke file uploads in Laravel 5.3.7.
src/Illuminate/Http/Request.php
@@ -880,7 +880,7 @@ protected function filterFiles($files) $files[$key] = $this->filterFiles($files[$key]); } - if (! $files[$key]) { + if (empty($files[$key])) { unset($files[$key]); } }
false
Other
laravel
framework
91d25ee41d354925c1b2c60b15b9bbc69b360bf1.json
fix #10501 by fixing morph to naming (#15334)
src/Illuminate/Database/Eloquent/Model.php
@@ -805,10 +805,10 @@ public function morphTo($name = null, $type = null, $id = null) if (is_null($name)) { list($current, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); - $name = Str::snake($caller['function']); + $name = $caller['function']; } - list($type, $id) = $this->getMorphs($name, $type, $id); + list($type, $id) = $this->getMorphs(Str::snake($name), $type, $id); // If the type value is null it is probably safe to assume we're eager loading // the relationship. In this case we'll just pass in a dummy query where we
true
Other
laravel
framework
91d25ee41d354925c1b2c60b15b9bbc69b360bf1.json
fix #10501 by fixing morph to naming (#15334)
src/Illuminate/Database/Eloquent/Relations/BelongsTo.php
@@ -305,6 +305,16 @@ public function getOtherKey() return $this->otherKey; } + /** + * Get the name of the relationship. + * + * @return string + */ + public function getRelation() + { + return $this->relation; + } + /** * Get the fully qualified associated key of the relationship. *
true
Other
laravel
framework
91d25ee41d354925c1b2c60b15b9bbc69b360bf1.json
fix #10501 by fixing morph to naming (#15334)
tests/Database/DatabaseEloquentModelTest.php
@@ -956,10 +956,32 @@ public function testMorphToCreatesProperRelation() { $model = new EloquentModelStub; $this->addMockConnection($model); + + // $this->morphTo(); $relation = $model->morphToStub(); $this->assertEquals('morph_to_stub_id', $relation->getForeignKey()); + $this->assertEquals('morph_to_stub_type', $relation->getMorphType()); + $this->assertEquals('morphToStub', $relation->getRelation()); $this->assertSame($model, $relation->getParent()); $this->assertInstanceOf('EloquentModelSaveStub', $relation->getQuery()->getModel()); + + // $this->morphTo(null, 'type', 'id'); + $relation2 = $model->morphToStubWithKeys(); + $this->assertEquals('id', $relation2->getForeignKey()); + $this->assertEquals('type', $relation2->getMorphType()); + $this->assertEquals('morphToStubWithKeys', $relation2->getRelation()); + + // $this->morphTo('someName'); + $relation3 = $model->morphToStubWithName(); + $this->assertEquals('some_name_id', $relation3->getForeignKey()); + $this->assertEquals('some_name_type', $relation3->getMorphType()); + $this->assertEquals('someName', $relation3->getRelation()); + + // $this->morphTo('someName', 'type', 'id'); + $relation4 = $model->morphToStubWithNameAndKeys(); + $this->assertEquals('id', $relation4->getForeignKey()); + $this->assertEquals('type', $relation4->getMorphType()); + $this->assertEquals('someName', $relation4->getRelation()); } public function testBelongsToManyCreatesProperRelation() @@ -1489,6 +1511,21 @@ public function morphToStub() return $this->morphTo(); } + public function morphToStubWithKeys() + { + return $this->morphTo(null, 'type', 'id'); + } + + public function morphToStubWithName() + { + return $this->morphTo('someName'); + } + + public function morphToStubWithNameAndKeys() + { + return $this->morphTo('someName', 'type', 'id'); + } + public function belongsToExplicitKeyStub() { return $this->belongsTo('EloquentModelSaveStub', 'foo');
true
Other
laravel
framework
b4e6777ce18b2372d19569ca1314ef3d14a76cdf.json
remove unnecessary code
src/Illuminate/Support/Testing/Fakes/BusFake.php
@@ -61,10 +61,6 @@ public function dispatched($command, $callback = null) return true; }; - if (is_null($callback)) { - return collect($this->commands[$command]); - } - return collect($this->commands[$command])->filter(function ($command) use ($callback) { return $callback($command); });
true
Other
laravel
framework
b4e6777ce18b2372d19569ca1314ef3d14a76cdf.json
remove unnecessary code
src/Illuminate/Support/Testing/Fakes/EventFake.php
@@ -61,10 +61,6 @@ public function fired($event, $callback = null) return true; }; - if (is_null($callback)) { - return collect($this->events[$event]); - } - return collect($this->events[$event])->filter(function ($arguments) use ($callback) { return $callback(...$arguments); })->flatMap(function ($arguments) {
true
Other
laravel
framework
b4e6777ce18b2372d19569ca1314ef3d14a76cdf.json
remove unnecessary code
src/Illuminate/Support/Testing/Fakes/MailFake.php
@@ -120,10 +120,6 @@ public function sent($mailable, $callback = null) return true; }; - if (is_null($callback)) { - return collect($this->mailables[$mailable]); - } - return $this->mailablesOf($mailable)->filter(function ($mailable) use ($callback) { return $callback($mailable->mailable, ...array_values($mailable->getRecipients())); });
true
Other
laravel
framework
b4e6777ce18b2372d19569ca1314ef3d14a76cdf.json
remove unnecessary code
src/Illuminate/Support/Testing/Fakes/NotificationFake.php
@@ -68,10 +68,6 @@ public function sent($notifiable, $notification, $callback = null) $notifications = collect($this->notificationsFor($notifiable, $notification)); - if (is_null($callback)) { - return $notifications; - } - return $notifications->filter(function ($arguments) use ($callback) { return $callback(...array_values($arguments)); })->pluck('notification');
true
Other
laravel
framework
b4e6777ce18b2372d19569ca1314ef3d14a76cdf.json
remove unnecessary code
src/Illuminate/Support/Testing/Fakes/QueueFake.php
@@ -84,10 +84,6 @@ public function pushed($job, $callback = null) return true; }; - if (is_null($callback)) { - return collect($this->jobs[$job]); - } - return collect($this->jobs[$job])->filter(function ($data) use ($callback) { return $callback($data['job'], $data['queue']); })->pluck('job');
true
Other
laravel
framework
7e7013222f98ff31db89fb732d047ce910c8753a.json
fix code styling
src/Illuminate/View/Compilers/BladeCompiler.php
@@ -513,7 +513,7 @@ protected function compileOverwrite($expression) */ protected function compileUnless($expression) { - return "<?php if ( ! $expression): ?>"; + return "<?php if (! $expression): ?>"; } /**
true
Other
laravel
framework
7e7013222f98ff31db89fb732d047ce910c8753a.json
fix code styling
tests/View/ViewBladeCompilerTest.php
@@ -309,7 +309,7 @@ public function testUnlessStatementsAreCompiled() $string = '@unless (name(foo(bar))) breeze @endunless'; - $expected = '<?php if ( ! (name(foo(bar)))): ?> + $expected = '<?php if (! (name(foo(bar)))): ?> breeze <?php endif; ?>'; $this->assertEquals($expected, $compiler->compileString($string));
true
Other
laravel
framework
54d2c6b8e38e90da7466fb5f306e1dbbe08a28e9.json
Remove extra line
tests/Queue/QueueWorkerTest.php
@@ -91,7 +91,6 @@ public function test_job_is_not_released_if_it_has_exceeded_max_attempts() $e = new RuntimeException; $job = new WorkerFakeJob(function ($job) use ($e) { - // In normal use this would be incremented by being popped off the queue $job->attempts++;
false
Other
laravel
framework
6cac4df0f66a8624eb553169291c2f09842120e1.json
remove leading slash and extra brackets
tests/Notifications/NotificationMailChannelTest.php
@@ -294,7 +294,7 @@ public function toMail($notifiable) $mock = Mockery::mock(Illuminate\Contracts\Mail\Mailable::class); $mock->shouldReceive('send')->once()->with(Mockery::on(function ($mailer) { - if (! ($mailer instanceof \Illuminate\Contracts\Mail\Mailer)) { + if (! $mailer instanceof Illuminate\Contracts\Mail\Mailer) { return false; }
false
Other
laravel
framework
7b1916e1708b5a7fb31f5b42a4d6cd2f290998fc.json
add unit test for Mailable Notification
tests/Notifications/NotificationMailChannelTest.php
@@ -210,6 +210,20 @@ public function testMessageWithToAddress() $channel->send($notifiable, $notification); } + + public function testMessageWithMailableContract() + { + $notification = new NotificationMailChannelTestNotificationWithMailableContract; + $notifiable = new NotificationMailChannelTestNotifiable; + + $channel = new Illuminate\Notifications\Channels\MailChannel( + $mailer = Mockery::mock(Illuminate\Contracts\Mail\Mailer::class) + ); + + $mailer->shouldReceive('send')->once(); + + $channel->send($notifiable, $notification); + } } class NotificationMailChannelTestNotifiable @@ -272,3 +286,23 @@ public function toMail($notifiable) ->to('jeffrey@laracasts.com'); } } + +class NotificationMailChannelTestNotificationWithMailableContract extends Notification +{ + public function toMail($notifiable) + { + $mock = Mockery::mock(Illuminate\Contracts\Mail\Mailable::class); + + $mock->shouldReceive('send')->once()->with(Mockery::on(function($mailer) { + if (! ($mailer instanceof \Illuminate\Contracts\Mail\Mailer)) { + return false; + } + + $mailer->send('notifications::email-plain'); + + return true; + })); + + return $mock; + } +}
false
Other
laravel
framework
dd29bbcb9cdeba47286d22666692d00dd9a3a35d.json
support aliases on withcount
src/Illuminate/Database/Eloquent/Builder.php
@@ -1056,20 +1056,20 @@ public function withCount($relations) $relations = is_array($relations) ? $relations : func_get_args(); foreach ($this->parseWithRelations($relations) as $name => $constraints) { - // If relation string matches "relation as newname" extract first part as the relation - // name and remember the last part as output name. - $nameParts = explode(' ', $name); - $resultName = ''; - if (count($nameParts) == 3 && Str::lower($nameParts[1]) == 'as') { - $name = $nameParts[0]; - $resultName = $nameParts[2]; + // First we will determine if the name has been aliased using an "as" clause on the name + // and if it has we will extract the actual relationship name and the desired name of + // the resulting column. This allows multiple counts on the same relationship name. + $segments = explode(' ', $name); + + if (count($segments) == 3 && Str::lower($segments[1]) == 'as') { + list($name, $alias) = [$segments[0], $segments[2]]; } + $relation = $this->getHasRelationQuery($name); + // Here we will get the relationship count query and prepare to add it to the main query // as a sub-select. First, we'll get the "has" query and use that to get the relation // count query. We will normalize the relation name then append _count as the name. - $relation = $this->getHasRelationQuery($name); - $query = $relation->getRelationCountQuery( $relation->getRelated()->newQuery(), $this ); @@ -1078,7 +1078,12 @@ public function withCount($relations) $query->mergeModelDefinedRelationConstraints($relation->getQuery()); - $this->selectSub($query->toBase(), snake_case(! empty($resultName) ? $resultName : $name).'_count'); + // Finally we will add the proper result column alias to the query and run the subselect + // statement against the query builder. Then we will return the builder instance back + // to the developer for further constraint chaining that needs to take place on it. + $column = snake_case(isset($alias) ? $alias : $name).'_count'; + + $this->selectSub($query->toBase(), $column); } return $this;
false
Other
laravel
framework
0730ec587dc7a4071966a1c65f3c978ccc4ad467.json
fix method order
src/Illuminate/Filesystem/Filesystem.php
@@ -306,25 +306,25 @@ public function isDirectory($directory) } /** - * Determine if the given path is writable. + * Determine if the given path is readable. * * @param string $path * @return bool */ - public function isWritable($path) + public function isReadable($path) { - return is_writable($path); + return is_readable($path); } /** - * Determine if the given path is readable. + * Determine if the given path is writable. * * @param string $path * @return bool */ - public function isReadable($path) + public function isWritable($path) { - return is_readable($path); + return is_writable($path); } /**
false
Other
laravel
framework
b05f46a0500349dadda6886178c043d3b72fc392.json
Fix some phpdoc inconsistencies
src/Illuminate/Database/Query/Builder.php
@@ -582,7 +582,7 @@ protected function invalidOperatorAndValue($operator, $value) /** * Add an "or where" clause to the query. * - * @param string|\Closure $column + * @param \Closure|string $column * @param string $operator * @param mixed $value * @return \Illuminate\Database\Query\Builder|static
true
Other
laravel
framework
b05f46a0500349dadda6886178c043d3b72fc392.json
Fix some phpdoc inconsistencies
src/Illuminate/View/Factory.php
@@ -792,7 +792,7 @@ public function doneRendering() /** * Add new loop to the stack. * - * @param array|\Countable $data + * @param \Countable|array $data * @return void */ public function addLoop($data)
true
Other
laravel
framework
e509b3958dde4fbe8454edc79c6870f60a1082e9.json
fix a bunch of things
src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php
@@ -56,17 +56,28 @@ public function auth($request) public function validAuthenticationResponse($request, $result) { if (Str::startsWith($request->channel_name, 'private')) { - return $this->decodedPusherResponse( + return $this->decodePusherResponse( $this->pusher->socket_auth($request->channel_name, $request->socket_id) ); } else { - return $this->decodedPusherResponse( + return $this->decodePusherResponse( $this->pusher->presence_auth( $request->channel_name, $request->socket_id, $request->user()->id, $result) ); } } + /** + * Decode the given Pusher response. + * + * @param mixed $response + * @return array + */ + protected function decodePusherResponse($response) + { + return json_decode($response, true); + } + /** * Broadcast the given event. * @@ -91,15 +102,4 @@ public function getPusher() { return $this->pusher; } - - /** - * Decoded PusherResponse. - * - * @param mixed $response - * @return array - */ - public function decodedPusherResponse($response) - { - return json_decode($response, true); - } }
false
Other
laravel
framework
6c3ecdc5cf02c19ae28218201152ef34cd1ff9b5.json
Fix regression in save(touch) option (#15264)
src/Illuminate/Database/Eloquent/Model.php
@@ -1462,7 +1462,7 @@ public function save(array $options = []) // clause to only update this model. Otherwise, we'll just insert them. if ($this->exists) { $saved = $this->isDirty() ? - $this->performUpdate($query) : true; + $this->performUpdate($query, $options) : true; } // If the model is brand new, we'll insert it into our database and set the @@ -1515,9 +1515,10 @@ protected function finishSave(array $options) * Perform a model update operation. * * @param \Illuminate\Database\Eloquent\Builder $query + * @param array $options * @return bool */ - protected function performUpdate(Builder $query) + protected function performUpdate(Builder $query, array $options = []) { // If the updating event returns false, we will cancel the update operation so // developers can hook Validation systems into their models and cancel this @@ -1529,7 +1530,7 @@ protected function performUpdate(Builder $query) // First we need to create a fresh query instance and touch the creation and // update timestamp on the model which are maintained by us for developer // convenience. Then we will just continue saving the model instances. - if ($this->timestamps) { + if ($this->timestamps && Arr::get($options, 'touch', true)) { $this->updateTimestamps(); }
true
Other
laravel
framework
6c3ecdc5cf02c19ae28218201152ef34cd1ff9b5.json
Fix regression in save(touch) option (#15264)
tests/Database/DatabaseEloquentModelTest.php
@@ -195,6 +195,23 @@ public function testUpdateProcessDoesntOverrideTimestamps() $this->assertTrue($model->save()); } + public function testSaveDoesntUpateTimestampsIfTouchOptionDisabled() + { + $model = $this->getMockBuilder('EloquentModelStub')->setMethods(['newQueryWithoutScopes', 'updateTimestamps', 'fireModelEvent'])->getMock(); + $query = m::mock('Illuminate\Database\Eloquent\Builder'); + $query->shouldReceive('where')->once()->with('id', '=', 1); + $query->shouldReceive('update')->once()->with(['name' => 'taylor'])->andReturn(1); + $model->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); + $model->expects($this->never())->method('updateTimestamps'); + $model->expects($this->any())->method('fireModelEvent')->will($this->returnValue(true)); + + $model->id = 1; + $model->syncOriginal(); + $model->name = 'taylor'; + $model->exists = true; + $this->assertTrue($model->save(['touch' => false])); + } + public function testSaveIsCancelledIfSavingEventReturnsFalse() { $model = $this->getMockBuilder('EloquentModelStub')->setMethods(['newQueryWithoutScopes'])->getMock();
true
Other
laravel
framework
5d062ad0b93350b757f151bc9dbe5fe7239c19cc.json
Add line below document block summary.
src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php
@@ -94,6 +94,7 @@ public function getPusher() /** * Decoded PusherResponse. + * * @param mixed $response * @return array */
false