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 | 9d796c68e4bfcba97c90c782c285fb29592e4042.json | Update Symfony displayer. | src/Illuminate/Exception/SymfonyDisplayer.php | @@ -27,10 +27,11 @@ public function __construct(ExceptionHandler $symfony)
* Display the given exception to the user.
*
* @param \Exception $exception
+ * @return \Symfony\Component\HttpFoundation\Response
*/
public function display(Exception $exception)
{
- $this->symfony->handle($exception);
+ return $this->symfony->createResponse($exception);
}
} | false |
Other | laravel | framework | 2044a767c3ddc6764df5f2e707cf1f67f0e06c37.json | Force the seeding
Otherwise it has to be confirmed twice. | src/Illuminate/Database/Console/Migrations/MigrateCommand.php | @@ -82,7 +82,8 @@ public function fire()
// a migration and a seed at the same time, as it is only this command.
if ($this->input->getOption('seed'))
{
- $this->call('db:seed');
+ $options = array('--force' => true);
+ $this->call('db:seed', $options);
}
}
| false |
Other | laravel | framework | 1f6f00ff8174e9422e45b6dc22fce4bbce715391.json | Use ConfirmableTrait in Seeder
Just like migrations | src/Illuminate/Database/Console/SeedCommand.php | @@ -1,11 +1,14 @@
<?php namespace Illuminate\Database\Console;
use Illuminate\Console\Command;
+use Illuminate\Console\ConfirmableTrait;
use Symfony\Component\Console\Input\InputOption;
use Illuminate\Database\ConnectionResolverInterface as Resolver;
class SeedCommand extends Command {
+ use ConfirmableTrait;
+
/**
* The console command name.
*
@@ -47,6 +50,8 @@ public function __construct(Resolver $resolver)
*/
public function fire()
{
+ if ( ! $this->confirmToProceed()) return;
+
$this->resolver->setDefaultConnection($this->getDatabase());
$this->getSeeder()->run();
@@ -87,6 +92,8 @@ protected function getOptions()
array('class', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder', 'DatabaseSeeder'),
array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to seed'),
+
+ array('force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'),
);
}
| false |
Other | laravel | framework | abc7b9889be3154d400443b8a9ba0a9435157dd6.json | Use input() to get page number
Restricting page numbers to `$request->query->get()` makes it very hard to make api end points which can accept a big amount of filters via an HTTP request because there are several different limitations on how a GET request can function. Allowing current-page to be accessible via `$request->input()` makes it very easy to just send the page number along with a big post-data of all the filters. | src/Illuminate/Pagination/Environment.php | @@ -126,7 +126,7 @@ public function getPaginationView(Paginator $paginator, $view = null)
*/
public function getCurrentPage()
{
- $page = (int) $this->currentPage ?: $this->request->query->get($this->pageName, 1);
+ $page = (int) $this->currentPage ?: $this->request->input($this->pageName, 1);
if ($page < 1 || filter_var($page, FILTER_VALIDATE_INT) === false)
{ | false |
Other | laravel | framework | 62ccd385b89ca125f17d6ce45e3645517c6ce00a.json | Update version on master. | src/Illuminate/Foundation/Application.php | @@ -27,7 +27,7 @@ class Application extends Container implements HttpKernelInterface, TerminableIn
*
* @var string
*/
- const VERSION = '4.2-dev';
+ const VERSION = '4.3-dev';
/**
* Indicates if the application has "booted". | false |
Other | laravel | framework | cd3af2a083bcb1242b9704e6c69239b47b01eafe.json | Upgrade branch alias on master branch. | composer.json | @@ -85,7 +85,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "4.2-dev"
+ "dev-master": "4.3-dev"
}
},
"suggest": {
| false |
Other | laravel | framework | 176105dcb9c222a7ca624d4bc998f1e2b5e88c8c.json | Upgrade stability on 4.2 branch. | composer.json | @@ -91,5 +91,5 @@
"suggest": {
"doctrine/dbal": "Allow renaming columns and dropping SQLite columns."
},
- "minimum-stability": "dev"
+ "minimum-stability": "beta"
}
| false |
Other | laravel | framework | c8a9c9ee9cf9b8d3137b00b02c4961b1b818033f.json | Resolve the right database connection. | src/Illuminate/Database/Migrations/Migrator.php | @@ -323,9 +323,9 @@ public function getNotes()
*
* @return \Illuminate\Database\Connection
*/
- public function resolveConnection()
+ public function resolveConnection($connection)
{
- return $this->resolver->connection($this->connection);
+ return $this->resolver->connection($connection);
}
/**
@@ -376,4 +376,4 @@ public function getFilesystem()
return $this->files;
}
-}
+}
\ No newline at end of file | false |
Other | laravel | framework | 8055c87740e9709b9d733364b8544d8b3753f20d.json | Check daemon option. | src/Illuminate/Queue/Console/WorkCommand.php | @@ -50,7 +50,7 @@ public function __construct(Worker $worker)
*/
public function fire()
{
- if ($this->downForMaintenance()) return;
+ if ($this->downForMaintenance() && ! $this->option('daemon')) return;
$queue = $this->option('queue');
| false |
Other | laravel | framework | d4ef5b200985206b2e09aa409a2901ff44605a61.json | Add force root URLs. | src/Illuminate/Routing/UrlGenerator.php | @@ -19,6 +19,20 @@ class UrlGenerator {
*/
protected $request;
+ /**
+ * The force URL root.
+ *
+ * @var string
+ */
+ protected $forcedRoot;
+
+ /**
+ * The forced schema for URLs.
+ *
+ * @var string
+ */
+ protected $forceSchema;
+
/**
* Characters that should not be URL encoded.
*
@@ -175,14 +189,25 @@ protected function getScheme($secure)
{
if (is_null($secure))
{
- return $this->request->getScheme().'://';
+ return $this->forceSchema ?: $this->request->getScheme().'://';
}
else
{
return $secure ? 'https://' : 'http://';
}
}
+ /**
+ * Force the schema for URLs.
+ *
+ * @param string $schema
+ * @return void
+ */
+ public function forceSchema($schema)
+ {
+ $this->forceSchema = $schema.'://';
+ }
+
/**
* Get the URL to a named route.
*
@@ -439,13 +464,27 @@ public function action($action, $parameters = array(), $absolute = true)
*/
protected function getRootUrl($scheme, $root = null)
{
- $root = $root ?: $this->request->root();
+ if (is_null($root))
+ {
+ $root = $this->forcedRoot ?: $this->request->root();
+ }
$start = starts_with($root, 'http://') ? 'http://' : 'https://';
return preg_replace('~'.$start.'~', $scheme, $root, 1);
}
+ /**
+ * Set the forced root URL.
+ *
+ * @param string $root
+ * @return void
+ */
+ public function forceRootUrl($root)
+ {
+ $this->forcedRoot = $root;
+ }
+
/**
* Determine if the given path is a valid URL.
*
| true |
Other | laravel | framework | d4ef5b200985206b2e09aa409a2901ff44605a61.json | Add force root URLs. | tests/Routing/RoutingUrlGeneratorTest.php | @@ -205,4 +205,34 @@ public function testUrlGenerationForControllers()
$this->assertEquals('http://www.foo.com:8080/foo', $url->route('foo'));
}
+
+ public function testForceRootUrl()
+ {
+ $url = new UrlGenerator(
+ $routes = new Illuminate\Routing\RouteCollection,
+ $request = Illuminate\Http\Request::create('http://www.foo.com/')
+ );
+
+ $url->forceRootUrl('https://www.bar.com');
+ $this->assertEquals('http://www.bar.com/foo/bar', $url->to('foo/bar'));
+
+
+ /**
+ * Route Based...
+ */
+ $url = new UrlGenerator(
+ $routes = new Illuminate\Routing\RouteCollection,
+ $request = Illuminate\Http\Request::create('http://www.foo.com/')
+ );
+
+ $url->forceSchema('https');
+ $route = new Illuminate\Routing\Route(array('GET'), '/foo', array('as' => 'plain'));
+ $routes->add($route);
+
+ $this->assertEquals('https://www.foo.com/foo', $url->route('plain'));
+
+ $url->forceRootUrl('https://www.bar.com');
+ $this->assertEquals('https://www.bar.com/foo', $url->route('plain'));
+ }
+
}
| true |
Other | laravel | framework | 32d39a0d7deb70c0dccd076f23f774b1a16976e1.json | Use new table stuff in routes command. | src/Illuminate/Foundation/Console/RoutesCommand.php | @@ -36,13 +36,6 @@ class RoutesCommand extends Command {
*/
protected $routes;
- /**
- * The table helper set.
- *
- * @var \Symfony\Component\Console\Helper\TableHelper
- */
- protected $table;
-
/**
* The table headers for the command.
*
@@ -73,8 +66,6 @@ public function __construct(Router $router)
*/
public function fire()
{
- $this->table = $this->getHelperSet()->get('table');
-
if (count($this->routes) == 0)
{
return $this->error("Your application doesn't have any routes.");
@@ -129,9 +120,7 @@ protected function getRouteInformation(Route $route)
*/
protected function displayRoutes(array $routes)
{
- $this->table->setHeaders($this->headers)->setRows($routes);
-
- $this->table->render($this->getOutput());
+ $this->table($this->headers, $routes);
}
/** | false |
Other | laravel | framework | 31d720672ef9698af14ed3c06a1716e61e47425b.json | Use data_get in Collection::valueRetriever | src/Illuminate/Support/Collection.php | @@ -561,7 +561,7 @@ protected function valueRetriever($value)
{
return function($item) use ($value)
{
- return is_object($item) ? $item->{$value} : array_get($item, $value);
+ return data_get($item, $value);
};
}
| true |
Other | laravel | framework | 31d720672ef9698af14ed3c06a1716e61e47425b.json | Use data_get in Collection::valueRetriever | tests/Support/SupportCollectionTest.php | @@ -358,17 +358,27 @@ public function testGroupByAttribute()
public function testGettingSumFromCollection()
{
- $c = new Collection(array((object) array('foo' => 50), (object) array('foo' => 50)));
- $this->assertEquals(100, $c->sum('foo'));
+ $c = new Collection(array((object) array('foo' => 50), (object) array('foo' => 50)));
+ $this->assertEquals(100, $c->sum('foo'));
- $c = new Collection(array((object) array('foo' => 50), (object) array('foo' => 50)));
- $this->assertEquals(100, $c->sum(function($i) { return $i->foo; }));
+ $c = new Collection(array((object) array('foo' => 50), (object) array('foo' => 50)));
+ $this->assertEquals(100, $c->sum(function($i) { return $i->foo; }));
}
public function testGettingSumFromEmptyCollection()
{
- $c = new Collection();
- $this->assertEquals(0, $c->sum('foo'));
+ $c = new Collection();
+ $this->assertEquals(0, $c->sum('foo'));
+ }
+
+ public function testValueRetrieverAcceptsDotNotation()
+ {
+ $c = new Collection(array(
+ (object) array('id' => 1, 'foo' => array('bar' => 'B')), (object) array('id' => 2, 'foo' => array('bar' => 'A'))
+ ));
+
+ $c = $c->sortBy('foo.bar');
+ $this->assertEquals(array(2, 1), $c->lists('id'));
}
}
| true |
Other | laravel | framework | 06c897cc683495cab67a81d4bdd180d9f554dd85.json | Fix typo in Manager.php
s/their/there | src/Illuminate/Support/Manager.php | @@ -47,7 +47,7 @@ public function driver($driver = null)
$driver = $driver ?: $this->getDefaultDriver();
// If the given driver has not been created before, we will create the instances
- // here and cache it so we can return it next time very quickly. If their is
+ // here and cache it so we can return it next time very quickly. If there is
// already a driver created by this name, we'll just return that instance.
if ( ! isset($this->drivers[$driver]))
{ | false |
Other | laravel | framework | 933eb1fef3d630c8d9355c72f5ffa8782cb4610c.json | Fix associate on MorphTo | src/Illuminate/Database/Eloquent/Relations/MorphTo.php | @@ -178,4 +178,19 @@ public function getDictionary()
return $this->dictionary;
}
+ /**
+ * Associate the model instance to the given parent.
+ *
+ * @param \Illuminate\Database\Eloquent\Model $model
+ * @return \Illuminate\Database\Eloquent\Model
+ */
+ public function associate(Model $model)
+ {
+ $this->parent->setAttribute($this->foreignKey, $model->getKey());
+
+ $this->parent->setAttribute($this->morphType, get_class($model));
+
+ return $this->parent->setRelation($this->relation, $model);
+ }
+
} | true |
Other | laravel | framework | 933eb1fef3d630c8d9355c72f5ffa8782cb4610c.json | Fix associate on MorphTo | tests/Database/DatabaseEloquentMorphToTest.php | @@ -78,6 +78,36 @@ public function testModelsAreProperlyPulledAndMatched()
}
+ public function testAssociateMethodSetsForeignKeyAndTypeOnModel()
+ {
+ $parent = m::mock('Illuminate\Database\Eloquent\Model');
+ $parent->shouldReceive('getAttribute')->once()->with('foreign_key')->andReturn('foreign.value');
+
+ $relation = $this->getRelationAssociate($parent);
+
+ $associate = m::mock('Illuminate\Database\Eloquent\Model');
+ $associate->shouldReceive('getKey')->once()->andReturn(1);
+
+ $parent->shouldReceive('setAttribute')->once()->with('foreign_key', 1);
+ $parent->shouldReceive('setAttribute')->once()->with('morph_type', get_class($associate));
+ $parent->shouldReceive('setRelation')->once()->with('relation', $associate);
+
+ $relation->associate($associate);
+ }
+
+
+ protected function getRelationAssociate($parent)
+ {
+ $builder = m::mock('Illuminate\Database\Eloquent\Builder');
+ $builder->shouldReceive('where')->with('relation.id', '=', 'foreign.value');
+ $related = m::mock('Illuminate\Database\Eloquent\Model');
+ $related->shouldReceive('getKey')->andReturn(1);
+ $related->shouldReceive('getTable')->andReturn('relation');
+ $builder->shouldReceive('getModel')->andReturn($related);
+ return new MorphTo($builder, $parent, 'foreign_key', 'id', 'morph_type', 'relation');
+ }
+
+
public function getRelation($parent = null)
{
$builder = m::mock('Illuminate\Database\Eloquent\Builder'); | true |
Other | laravel | framework | 1fd14e97805e0eec3ed50c90798074033d1be6e9.json | Ignore Thumbs files | .gitignore | @@ -2,3 +2,4 @@
composer.phar
composer.lock
.DS_Store
+Thumbs.db
| false |
Other | laravel | framework | ff579f49370a568f8b8ad948798bd76309e85753.json | Add space after question. | src/Illuminate/Console/Command.php | @@ -177,7 +177,7 @@ public function confirm($question, $default = true)
{
$dialog = $this->getHelperSet()->get('dialog');
- return $dialog->askConfirmation($this->output, "<question>$question</question>", $default);
+ return $dialog->askConfirmation($this->output, "<question>$question</question> ", $default);
}
/** | false |
Other | laravel | framework | 2a72b471d59cad8701a729fd99cf4b972005e8cf.json | Add subselect to query builder | src/Illuminate/Database/Query/Builder.php | @@ -206,11 +206,58 @@ public function select($columns = array('*'))
* Add a new "raw" select expression to the query.
*
* @param string $expression
+ * @param array $bindings
+ * @return \Illuminate\Database\Query\Builder|static
+ */
+ public function selectRaw($expression, array $bindings = array())
+ {
+ $this->addSelect(new Expression($expression));
+
+ if ($bindings)
+ {
+ $this->addBinding($bindings, 'select');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Add a subselect expression to the query.
+ *
+ * @param \Closure|\Illuminate\Database\Query\Builder|string $query
+ * @param string $as
* @return \Illuminate\Database\Query\Builder|static
*/
- public function selectRaw($expression)
+ public function selectSub($query, $as)
{
- return $this->select(new Expression($expression));
+ if ($query instanceof Closure)
+ {
+ $callback = $query;
+ $query = $this->newQuery();
+ $callback($query);
+ }
+
+ if ($query instanceof Builder)
+ {
+ $bindings = $query->getBindings();
+ $query = $query->toSql();
+ }
+ elseif (is_string($query))
+ {
+ $bindings = [];
+ }
+ else
+ {
+ $type = is_object($query) ? get_class($query) : gettype($query);
+ $message = "Argument #1 passed to selectSub must be an SQL string, query builder or closure, {$type} given";
+ throw new \InvalidArgumentException($message);
+ }
+
+ $as = $this->grammar->wrap($as);
+
+ $query = '(' . $query . ') as ' . $as;
+
+ return $this->selectRaw($query, $bindings);
}
/** | true |
Other | laravel | framework | 2a72b471d59cad8701a729fd99cf4b972005e8cf.json | Add subselect to query builder | tests/Database/DatabaseQueryBuilderTest.php | @@ -1103,6 +1103,27 @@ public function testMergeBuildersBindingOrder()
}
+ public function testSubSelect()
+ {
+ $expectedSql = 'select "foo", "bar", (select "baz" from "two" where "subkey" = ?) as "sub" from "one" where "key" = ?';
+ $expectedBindings = ['subval', 'val'];
+
+ $builder = $this->getPostgresBuilder();
+ $builder->from('one')->select(['foo', 'bar'])->where('key', '=', 'val');
+ $builder->selectSub(function($query) { $query->from('two')->select('baz')->where('subkey', '=', 'subval'); }, 'sub');
+ $this->assertEquals($expectedSql, $builder->toSql());
+ $this->assertEquals($expectedBindings, $builder->getBindings());
+
+ $builder = $this->getPostgresBuilder();
+ $builder->from('one')->select(['foo', 'bar'])->where('key', '=', 'val');
+ $subBuilder = $this->getPostgresBuilder();
+ $subBuilder->from('two')->select('baz')->where('subkey', '=', 'subval');
+ $builder->selectSub($subBuilder, 'sub');
+ $this->assertEquals($expectedSql, $builder->toSql());
+ $this->assertEquals($expectedBindings, $builder->getBindings());
+ }
+
+
protected function getBuilder()
{
$grammar = new Illuminate\Database\Query\Grammars\Grammar; | true |
Other | laravel | framework | 15a540e6038b81b54e218e454eae98b1a2481af9.json | Fix merge conflicts. | src/Illuminate/Console/composer.json | @@ -8,6 +8,7 @@
}
],
"require": {
+ "php": ">=5.4.0",
"symfony/console": "2.5.*"
},
"require-dev": { | true |
Other | laravel | framework | 15a540e6038b81b54e218e454eae98b1a2481af9.json | Fix merge conflicts. | src/Illuminate/Http/composer.json | @@ -8,6 +8,7 @@
}
],
"require": {
+ "php": ">=5.4.0",
"illuminate/session": "4.2.*",
"illuminate/support": "4.2.*",
"symfony/http-foundation": "2.5.*", | true |
Other | laravel | framework | 15a540e6038b81b54e218e454eae98b1a2481af9.json | Fix merge conflicts. | src/Illuminate/Routing/composer.json | @@ -8,6 +8,7 @@
}
],
"require": {
+ "php": ">=5.4.0",
"illuminate/container": "4.2.*",
"illuminate/http": "4.2.*",
"illuminate/session": "4.2.*", | true |
Other | laravel | framework | 15a540e6038b81b54e218e454eae98b1a2481af9.json | Fix merge conflicts. | src/Illuminate/Workbench/composer.json | @@ -8,6 +8,7 @@
}
],
"require": {
+ "php": ">=5.4.0",
"illuminate/filesystem": "4.2.*",
"illuminate/support": "4.2.*",
"symfony/finder": "2.5.*" | true |
Other | laravel | framework | 021a892b59d42a4176cd5c0c90036c975ec547fd.json | Fix code and update change log. | src/Illuminate/Foundation/changes.json | @@ -19,7 +19,8 @@
{"message": "Destructive migration operations now require confirmation or --force when being run in production.", "backport": null},
{"message": "Added Cache::pull method for retrieving a value and then deleting it.", "backport": null},
{"message": "Added Session::pull method for retrieving a value and then deleting it.", "backport": null},
- {"message": "Added rel attribute to basic pagination links.", "backport": null}
+ {"message": "Added rel attribute to basic pagination links.", "backport": null},
+ {"message": "The 'page' query variable is now ignored when calling the paginator 'appends' method.", "backport": null}
],
"4.1.*": [
{"message": "Added new SSH task runner tools.", "backport": null}, | true |
Other | laravel | framework | 021a892b59d42a4176cd5c0c90036c975ec547fd.json | Fix code and update change log. | src/Illuminate/Pagination/Paginator.php | @@ -291,7 +291,10 @@ protected function appendArray(array $keys)
*/
public function addQuery($key, $value)
{
- $this->query[$key] = $value;
+ if ($key !== $this->factory->getPageName())
+ {
+ $this->query[$key] = $value;
+ }
return $this;
} | true |
Other | laravel | framework | 021a892b59d42a4176cd5c0c90036c975ec547fd.json | Fix code and update change log. | tests/Pagination/PaginationPaginatorTest.php | @@ -110,13 +110,15 @@ public function testGetLinksCallsEnvironmentProperly()
public function testGetUrlProperlyFormatsUrl()
{
- $p = new Paginator($factory = m::mock('Illuminate\Pagination\Factory'), array('foo', 'bar', 'baz'), 3, 2);
- $factory->shouldReceive('getCurrentUrl')->twice()->andReturn('http://foo.com');
- $factory->shouldReceive('getPageName')->twice()->andReturn('page');
+ $p = new Paginator($env = m::mock('Illuminate\Pagination\Factory'), array('foo', 'bar', 'baz'), 3, 2);
+ $env->shouldReceive('getCurrentUrl')->times(3)->andReturn('http://foo.com');
+ $env->shouldReceive('getPageName')->andReturn('page');
$this->assertEquals('http://foo.com?page=1', $p->getUrl(1));
$p->addQuery('foo', 'bar');
$this->assertEquals('http://foo.com?page=1&foo=bar', $p->getUrl(1));
+ $p->addQuery('page', 99);
+ $this->assertEquals('http://foo.com?page=1&foo=bar', $p->getUrl(1));
}
@@ -146,9 +148,9 @@ public function testPaginatorIsIterable()
public function testGetUrlAddsFragment()
{
- $p = new Paginator($factory = m::mock('Illuminate\Pagination\Factory'), array('foo', 'bar', 'baz'), 3, 2);
- $factory->shouldReceive('getCurrentUrl')->twice()->andReturn('http://foo.com');
- $factory->shouldReceive('getPageName')->twice()->andReturn('page');
+ $p = new Paginator($env = m::mock('Illuminate\Pagination\Factory'), array('foo', 'bar', 'baz'), 3, 2);
+ $env->shouldReceive('getCurrentUrl')->twice()->andReturn('http://foo.com');
+ $env->shouldReceive('getPageName')->andReturn('page');
$p->fragment("a-fragment");
| true |
Other | laravel | framework | ecbaf21ea4ecacf92ec46bb71a587dcb4d31d5f5.json | Tweak some formatting. | src/Illuminate/Queue/Connectors/IronConnector.php | @@ -48,7 +48,8 @@ public function connect(array $config)
$iron = new IronMQ($ironConfig);
- if (isset($config['ssl_verifypeer'])) {
+ if (isset($config['ssl_verifypeer']))
+ {
$iron->ssl_verifypeer = $config['ssl_verifypeer'];
}
| false |
Other | laravel | framework | cc7bef5b85b8192776bbaab79e955f27045acd5c.json | Fix some comments. | src/Illuminate/Database/Connectors/SQLiteConnector.php | @@ -24,7 +24,7 @@ public function connect(array $config)
$path = realpath($config['database']);
- // Here we'll verify that the SQLite database exists before we going further
+ // Here we'll verify that the SQLite database exists before going any further
// as the developer probably wants to know if the database exists and this
// SQLite driver will not throw any exception if it does not by default.
if ($path === false) | true |
Other | laravel | framework | cc7bef5b85b8192776bbaab79e955f27045acd5c.json | Fix some comments. | src/Illuminate/Database/Eloquent/Model.php | @@ -745,7 +745,7 @@ public function morphTo($name = null, $type = null, $id = null)
);
}
- // If we are not eager loading the relationship, we will essentially treat this
+ // If we are not eager loading the relationship we will essentially treat this
// as a belongs-to style relationship since morph-to extends that class and
// we will pass in the appropriate values so that it behaves as expected.
else
@@ -1337,7 +1337,7 @@ public function push()
// To sync all of the relationships to the database, we will simply spin through
// the relationships and save each model via this "push" method, which allows
- // us to recurs into all of these nested relations for the model instance.
+ // us to recurs into all of these nested relations for this model instance.
foreach ($this->relations as $models)
{
foreach (Collection::make($models) as $model) | true |
Other | laravel | framework | cc7bef5b85b8192776bbaab79e955f27045acd5c.json | Fix some comments. | src/Illuminate/Database/Migrations/Migrator.php | @@ -72,7 +72,7 @@ public function run($path, $pretend = false)
// Once we grab all of the migration files for the path, we will compare them
// against the migrations that have already been run for this package then
- // run all of the outstanding migrations against the database connection.
+ // run each of the outstanding migrations against a database connection.
$ran = $this->repository->getRan();
$migrations = array_diff($files, $ran); | true |
Other | laravel | framework | cc7bef5b85b8192776bbaab79e955f27045acd5c.json | Fix some comments. | src/Illuminate/Routing/UrlGenerator.php | @@ -297,7 +297,7 @@ protected function getRouteQueryString(array $parameters)
// Lastly, if there are still parameters remaining, we will fetch the numeric
// parameters that are in the array and add them to the query string or we
- // will build the initial query string if it wasn't started with strings.
+ // will make the initial query string if it wasn't started with strings.
if (count($keyed) < count($parameters))
{
$query .= '&'.implode(
| true |
Other | laravel | framework | cc7bef5b85b8192776bbaab79e955f27045acd5c.json | Fix some comments. | src/Illuminate/View/View.php | @@ -79,7 +79,7 @@ public function render(Closure $callback = null)
// Once we have the contents of the view, we will flush the sections if we are
// done rendering all views so that there is nothing left hanging over when
- // another view is rendered in the future by the application developers.
+ // another view is rendered in the future via the application developers.
$this->environment->flushSectionsIfDoneRendering();
return $response ?: $contents; | true |
Other | laravel | framework | 3b30883aa8ac37e563cbe77e07d490fa36e3c9cb.json | Add security to encryption's composer file. | src/Illuminate/Encryption/composer.json | @@ -9,7 +9,8 @@
],
"require": {
"php": ">=5.3.0",
- "illuminate/support": "4.1.*"
+ "illuminate/support": "4.1.*",
+ "symfony/security": "2.4.*"
},
"require-dev": {
"phpunit/phpunit": "4.0.*" | false |
Other | laravel | framework | 7cd45b6e76c7dcdbe826693bb4c03a6771026132.json | Fix invalid composer file. | composer.json | @@ -21,7 +21,6 @@
"patchwork/utf8": "1.1.*",
"phpseclib/phpseclib": "0.3.*",
"predis/predis": "0.8.*",
-<<<<<<< HEAD
"stack/builder": "~1.0",
"swiftmailer/swiftmailer": "~5.1",
"symfony/browser-kit": "2.5.*",
| false |
Other | laravel | framework | c3e6e84229f790077b9a2b43976d326f6ef12b24.json | Improve valid MAC detection
Implement constant time string comparison as well as double HMAC
verification for encryption MACs. | composer.json | @@ -33,6 +33,7 @@
"symfony/http-kernel": "2.4.*",
"symfony/process": "2.4.*",
"symfony/routing": "2.4.*",
+ "symfony/security": "2.4.*",
"symfony/translation": "2.4.*"
},
"replace": {
| true |
Other | laravel | framework | c3e6e84229f790077b9a2b43976d326f6ef12b24.json | Improve valid MAC detection
Implement constant time string comparison as well as double HMAC
verification for encryption MACs. | src/Illuminate/Encryption/Encrypter.php | @@ -1,5 +1,8 @@
<?php namespace Illuminate\Encryption;
+use Symfony\Component\Security\Core\Util\StringUtils;
+use Symfony\Component\Security\Core\Util\SecureRandom;
+
class DecryptException extends \RuntimeException {}
class Encrypter {
@@ -145,7 +148,11 @@ protected function getJsonPayload($payload)
*/
protected function validMac(array $payload)
{
- return ($payload['mac'] === $this->hash($payload['iv'], $payload['value']));
+ $bytes = with(new SecureRandom)->nextBytes(16);
+
+ $calcMac = hash_hmac('sha256', $this->hash($payload['iv'], $payload['value']), $bytes, true);
+
+ return StringUtils::equals(hash_hmac('sha256', $payload['mac'], $bytes, true), $calcMac);
}
/** | true |
Other | laravel | framework | c31543cdbdff9d8731b635a271f367b04c172fb4.json | Fix a typo error
The correct word is "Decrement". | src/Illuminate/Cache/DatabaseStore.php | @@ -132,7 +132,7 @@ public function increment($key, $value = 1)
*/
public function decrement($key, $value = 1)
{
- throw new \LogicException("Increment operations not supported by this driver.");
+ throw new \LogicException("Decrement operations not supported by this driver.");
}
/** | false |
Other | laravel | framework | 7435635e501140d9addf2eabd5524a5d027e5b98.json | Replace spaces with tabs | src/Illuminate/Console/Command.php | @@ -268,7 +268,7 @@ public function table(array $headers, array $rows, $style = 'default')
$table = new Table($this->output);
$table->setHeaders($headers);
$table->setRows($rows);
- $table->setStyle($style);
+ $table->setStyle($style);
$table->render();
}
| false |
Other | laravel | framework | b55b0e6ab5d7c9a3c9c369705838e022c1b39874.json | Replace deprecated Table helper | src/Illuminate/Console/Command.php | @@ -1,5 +1,6 @@
<?php namespace Illuminate\Console;
+use Symfony\Component\Helper\Table;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Question\Question;
@@ -254,19 +255,21 @@ public function choice($question, array $choices, $default = null, $attempts = n
return $helper->ask($this->input, $this->output, $question);
}
- /**
- * Format input to textual table
- *
- * @param array $headers
- * @param array $rows
- * @return void
- */
- public function table(array $headers, array $rows)
+ /**
+ * Format input to textual table
+ *
+ * @param array $headers
+ * @param array $rows
+ * @param string $style
+ * @return void
+ */
+ public function table(array $headers, array $rows, $style = 'default')
{
- $table = $this->getHelperSet()->get('table');
+ $table = new Table($this->output);
$table->setHeaders($headers);
$table->setRows($rows);
- $table->render($this->output);
+ $table->setStyle($style);
+ $table->render();
}
/** | false |
Other | laravel | framework | b08866c08e69e0812cb4d863f08e6b17a1fa5edf.json | Replace spaces with tabs | src/Illuminate/Console/Command.php | @@ -178,8 +178,8 @@ public function option($key = null)
*/
public function confirm($question, $default = true)
{
- $helper = $this->getHelperSet()->get('question');
- $question = new ConfirmationQuestion($question, $default);
+ $helper = $this->getHelperSet()->get('question');
+ $question = new ConfirmationQuestion("<question>{$question}</question>", $default);
return $helper->ask($this->input, $this->output, $question);
}
@@ -193,28 +193,28 @@ public function confirm($question, $default = true)
*/
public function ask($question, $default = null)
{
- $helper = $this->getHelperSet()->get('question');
- $question = new Question($question, $default);
+ $helper = $this->getHelperSet()->get('question');
+ $question = new Question("<question>$question</question>", $default);
return $helper->ask($this->input, $this->output, $question);
}
- /**
- * Prompt the user for input with autocomplete
- *
- * @param string $question
- * @param array $list
- * @param string $default
- * @return string
- */
- public function autocomplete($question, array $list, $default = null)
- {
- $helper = $this->getHelperSet()->get('question');
- $question = new Question("<question>$question</question>", $default);
- $question->setAutocompleterValues($list);
+ /**
+ * Prompt the user for input with autocomplete
+ *
+ * @param string $question
+ * @param array $list
+ * @param string $default
+ * @return string
+ */
+ public function autocomplete($question, array $list, $default = null)
+ {
+ $helper = $this->getHelperSet()->get('question');
+ $question = new Question("<question>$question</question>", $default);
+ $question->setAutocompleterValues($list);
- return $helper->ask($this->input, $this->output, $question);
- }
+ return $helper->ask($this->input, $this->output, $question);
+ }
/**
@@ -226,58 +226,47 @@ public function autocomplete($question, array $list, $default = null)
*/
public function secret($question, $fallback = true)
{
- $helper = $this->getHelperSet()->get('question');
- $question = new Question($question);
- $question->setHidden(true);
- $question->setHiddenFallback($fallback);
+ $helper = $this->getHelperSet()->get('question');
+ $question = new Question("<question>$question</question>");
+ $question->setHidden(true);
+ $question->setHiddenFallback($fallback);
return $helper->ask($this->input, $this->output, $question);
}
- /**
- * Give the user a single choice from an array of answers.
- *
- * @param string $question
- * @param array $choices
- * @param string $default
- * @param bool $multiple
- * @param mixed $attempts
- * @return bool
- */
- public function choice($question, array $choices, $default = null, $multiple = false, $attempts = null)
+ /**
+ * Give the user a single choice from an array of answers.
+ *
+ * @param string $question
+ * @param array $choices
+ * @param string $default
+ * @param bool $multiple
+ * @param mixed $attempts
+ * @return bool
+ */
+ public function choice($question, array $choices, $default = null, $attempts = null, $multiple = null)
{
- $helper = $this->getHelperSet()->get('question');
- $question = new ChoiceQuestion($question, $choices, $default);
- $question->setMaxAttempts($attempts);
- $question->setMultiselect($multiple);
+ $helper = $this->getHelperSet()->get('question');
+ $question = new ChoiceQuestion("<question>$question</question>", $choices, $default);
+ $question->setMaxAttempts($attempts);
+ $question->setMultiselect($multiple);
return $helper->ask($this->input, $this->output, $question);
}
- /**
- * Format input to textual table
- *
- * @param array $headers
- * @param array $rows
- * @return void
- */
- public function table(array $headers, array $rows)
- {
- $table = $this->getHelperSet()->get('table');
- $table->setHeaders($headers);
- $table->setRows($rows);
- $table->render($this->output);
- }
-
/**
- * Write a string as standard output.
+ * Format input to textual table
*
- * @param string $string
+ * @param array $headers
+ * @param array $rows
* @return void
*/
- public function line($string)
+ public function table(array $headers, array $rows)
{
- $this->output->writeln($string);
+ $table = $this->getHelperSet()->get('table');
+ $table->setHeaders($headers);
+ $table->setRows($rows);
+ $table->render($this->output);
}
/**
@@ -291,6 +280,17 @@ public function info($string)
$this->output->writeln("<info>$string</info>");
}
+ /**
+ * Write a string as standard output.
+ *
+ * @param string $string
+ * @return void
+ */
+ public function line($string)
+ {
+ $this->output->writeln($string);
+ }
+
/**
* Write a string as comment output.
* | false |
Other | laravel | framework | 8e2e5fea08e26530ee3a8965de78c57329a50d6f.json | Fix loose matching when validating route schemes. | src/Illuminate/Routing/Route.php | @@ -687,7 +687,7 @@ public function methods()
*/
public function httpOnly()
{
- return in_array('http', $this->action);
+ return in_array('http', $this->action, true);
}
/**
@@ -707,7 +707,7 @@ public function httpsOnly()
*/
public function secure()
{
- return in_array('https', $this->action);
+ return in_array('https', $this->action, true);
}
/**
| true |
Other | laravel | framework | 8e2e5fea08e26530ee3a8965de78c57329a50d6f.json | Fix loose matching when validating route schemes. | tests/Routing/RoutingRouteTest.php | @@ -387,6 +387,10 @@ public function testMatchesMethodAgainstRequests()
$route = new Route('GET', 'foo/{bar}', array('https', function() {}));
$this->assertTrue($route->matches($request));
+ $request = Request::create('https://foo.com/foo/bar', 'GET');
+ $route = new Route('GET', 'foo/{bar}', array('https', 'baz' => true, function() {}));
+ $this->assertTrue($route->matches($request));
+
$request = Request::create('http://foo.com/foo/bar', 'GET');
$route = new Route('GET', 'foo/{bar}', array('https', function() {}));
$this->assertFalse($route->matches($request));
@@ -401,6 +405,10 @@ public function testMatchesMethodAgainstRequests()
$request = Request::create('http://foo.com/foo/bar', 'GET');
$route = new Route('GET', 'foo/{bar}', array('http', function() {}));
$this->assertTrue($route->matches($request));
+
+ $request = Request::create('http://foo.com/foo/bar', 'GET');
+ $route = new Route('GET', 'foo/{bar}', array('baz' => true, function() {}));
+ $this->assertTrue($route->matches($request));
}
| true |
Other | laravel | framework | b9586cc46d55451e24ead6adea7eeb7246a57817.json | Use Unix Socket or Host and port
Referring to this (http://us3.php.net/manual/en/ref.pdo-mysql.connection.php) document explaining that unix socket should not be used together with Host and Port. | src/Illuminate/Database/Connectors/MySqlConnector.php | @@ -55,17 +55,18 @@ protected function getDsn(array $config)
// need to establish the PDO connections and return them back for use.
extract($config);
- $dsn = "mysql:host={$host};dbname={$database}";
-
- if (isset($config['port']))
+ $dsn = "mysql:dbname={$database}";
+
+ if (isset($config['unix_socket']))
{
- $dsn .= ";port={$port}";
- }
-
- // Sometimes the developer may specify the specific UNIX socket that should
- // be used. If that is the case we will add that option to the string we
- // have created so that it gets utilized while the connection is made.
- if (isset($config['unix_socket']))
+ $dsn .= ";host={$host}";
+
+ if (isset($config['port']))
+ {
+ $dsn .= ";port={$port}";
+ }
+ }
+ else
{
$dsn .= ";unix_socket={$config['unix_socket']}";
} | false |
Other | laravel | framework | d8c60efe2cd5692e1b667873a85522a5b6f4101c.json | fire an event on cache clear
In some situations, users may store certain cache-style data in a more custom manner than the Cache functions permit. For example, we store most cache data in Redis, but have a few larger cacheable items (rendered, minified CSS) that would incur high levels of unnecessary network traffic from the Redis server if stored there. For these larger items, we manually store to the db and/or the filesystem.
Adding a `cache:clear` event to `php artisan cache:clear` allows these a cache clearing to be hooked into via an event for additional custom processing. | src/Illuminate/Cache/Console/ClearCommand.php | @@ -59,6 +59,8 @@ public function fire()
$this->cache->flush();
$this->files->delete($this->laravel['config']['app.manifest'].'/services.json');
+
+ $this->laravel['events']->fire('cache:clear');
$this->info('Application cache cleared!');
} | false |
Other | laravel | framework | 7d13619e8a6fff8a31ab984e53e87c57358294b9.json | Change method order. | src/Illuminate/Auth/UserInterface.php | @@ -16,13 +16,6 @@ public function getAuthIdentifier();
*/
public function getAuthPassword();
- /**
- * Get the column name for the "remember me" token.
- *
- * @return string
- */
- public function getRememberTokenName();
-
/**
* Get the token value for the "remember me" session.
*
@@ -38,4 +31,11 @@ public function getRememberToken();
*/
public function setRememberToken($value);
+ /**
+ * Get the column name for the "remember me" token.
+ *
+ * @return string
+ */
+ public function getRememberTokenName();
+
} | false |
Other | laravel | framework | a201a02a2c8c81bcacd0fb426ff845ad85f6f361.json | Update replacerRequiredIf for multiple values
:value is being used as though it were :values. To correct this would mean updating the default language lines. | src/Illuminate/Validation/Validator.php | @@ -1709,9 +1709,9 @@ protected function replaceRequiredWithoutAll($message, $attribute, $rule, $param
*/
protected function replaceRequiredIf($message, $attribute, $rule, $parameters)
{
- $parameters[0] = $this->getAttribute($parameters[0]);
+ $other = $this->getAttribute($parameters[0]);
- return str_replace(array(':other', ':value'), $parameters, $message);
+ return str_replace(array(':other', ':value'), array($other, implode(' / ', array_slice($parameters,1))), $message);
}
/** | false |
Other | laravel | framework | 3202b1ab6bdbd32d602261d77d1de131797938b9.json | Fix sometimes validation for nested arrays | src/Illuminate/Validation/Validator.php | @@ -307,7 +307,7 @@ protected function getValue($attribute)
protected function isValidatable($rule, $attribute, $value)
{
return $this->presentOrRuleIsImplicit($rule, $attribute, $value) &&
- $this->passesOptionalCheck($attribute);
+ $this->passesOptionalCheck($attribute);
}
/**
@@ -333,7 +333,8 @@ protected function passesOptionalCheck($attribute)
{
if ($this->hasRule($attribute, array('Sometimes')))
{
- return array_key_exists($attribute, $this->data) || array_key_exists($attribute, $this->files);
+ return array_key_exists($attribute, array_dot($this->data))
+ || array_key_exists($attribute, $this->files);
}
else
{ | true |
Other | laravel | framework | 3202b1ab6bdbd32d602261d77d1de131797938b9.json | Fix sometimes validation for nested arrays | tests/Validation/ValidationValidatorTest.php | @@ -12,6 +12,19 @@ public function tearDown()
}
+ public function testSometimesWorksOnNestedArrays()
+ {
+ $trans = $this->getRealTranslator();
+ $v = new Validator($trans, array('foo' => array('bar' => array('baz' => ''))), array('foo.bar.baz' => 'sometimes|required'));
+ $this->assertFalse($v->passes());
+ $this->assertEquals(array('foo.bar.baz' => array('Required' => array())), $v->failed());
+
+ $trans = $this->getRealTranslator();
+ $v = new Validator($trans, array('foo' => array('bar' => array('baz' => 'nonEmpty'))), array('foo.bar.baz' => 'sometimes|required'));
+ $this->assertTrue($v->passes());
+ }
+
+
public function testHasFailedValidationRules()
{
$trans = $this->getRealTranslator(); | true |
Other | laravel | framework | 9b4271f7b6963da0f57ad087dce5668adafd19d3.json | Remove unnecessary check. | src/Illuminate/Database/Eloquent/Builder.php | @@ -579,7 +579,7 @@ protected function isNested($name, $relation)
{
$dots = str_contains($name, '.');
- return $dots && starts_with($name, $relation.'.') && $name != $relation;
+ return $dots && starts_with($name, $relation.'.');
}
/** | false |
Other | laravel | framework | b6888c026a543d25783cfaf5b502b91bfa95624f.json | Fix nested relations with subset names. | src/Illuminate/Database/Eloquent/Builder.php | @@ -579,7 +579,7 @@ protected function isNested($name, $relation)
{
$dots = str_contains($name, '.');
- return $dots && starts_with($name, $relation) && $name != $relation;
+ return $dots && starts_with($name, $relation.'.') && $name != $relation;
}
/** | true |
Other | laravel | framework | b6888c026a543d25783cfaf5b502b91bfa95624f.json | Fix nested relations with subset names. | tests/Database/DatabaseEloquentBuilderTest.php | @@ -318,6 +318,27 @@ public function testGetRelationProperlySetsNestedRelationships()
}
+ public function testGetRelationProperlySetsNestedRelationshipsWithSimilarNames()
+ {
+ $builder = $this->getBuilder();
+ $builder->setModel($this->getMockModel());
+ $builder->getModel()->shouldReceive('orders')->once()->andReturn($relation = m::mock('stdClass'));
+ $builder->getModel()->shouldReceive('ordersGroups')->once()->andReturn($groupsRelation = m::mock('stdClass'));
+
+ $relationQuery = m::mock('stdClass');
+ $relation->shouldReceive('getQuery')->andReturn($relationQuery);
+
+ $groupRelationQuery = m::mock('stdClass');
+ $groupsRelation->shouldReceive('getQuery')->andReturn($groupRelationQuery);
+ $groupRelationQuery->shouldReceive('with')->once()->with(array('lines' => null, 'lines.details' => null));
+
+ $builder->setEagerLoads(array('orders' => null, 'ordersGroups' => null, 'ordersGroups.lines' => null, 'ordersGroups.lines.details' => null));
+
+ $relation = $builder->getRelation('orders');
+ $relation = $builder->getRelation('ordersGroups');
+ }
+
+
public function testEagerLoadParsingSetsProperRelationships()
{
$builder = $this->getBuilder(); | true |
Other | laravel | framework | 0b9dd1fec3417d778aba2bcaff4436ca1fc7c754.json | move comment to appropriate location | src/Illuminate/Database/Query/Builder.php | @@ -1549,13 +1549,13 @@ protected function ungroupedPaginate($paginator, $perPage, $columns)
*/
public function getPaginationCount()
{
+ // Because some database engines may throw errors if we leave the ordering
+ // statements on the query, we will "back them up" and remove them from
+ // the query. Once we have the count we will put them back onto this.
list($orders, $this->orders) = array($this->orders, null);
$columns = $this->columns;
- // Because some database engines may throw errors if we leave the ordering
- // statements on the query, we will "back them up" and remove them from
- // the query. Once we have the count we will put them back onto this.
$total = $this->count();
$this->orders = $orders; | false |
Other | laravel | framework | 6a1981a9ee5799cb220ac1aa7256fa3a36c0a4bd.json | add distinct pagination test | tests/Database/DatabaseQueryBuilderTest.php | @@ -690,6 +690,27 @@ public function testGetPaginationCountGetsResultCount()
}
+ public function testGetPaginationCountGetsResultCountWithSelectDistinct()
+ {
+ unset($_SERVER['orders']);
+ $builder = $this->getBuilder();
+ $builder->getConnection()->shouldReceive('select')->once()->with('select count(distinct "foo", "bar") as aggregate from "users"', array())->andReturn(array(array('aggregate' => 1)));
+ $builder->getProcessor()->shouldReceive('processSelect')->once()->andReturnUsing(function($query, $results)
+ {
+ $_SERVER['orders'] = $query->orders;
+ return $results;
+ });
+ $results = $builder->distinct()->select('foo', 'bar')->from('users')->orderBy('foo', 'desc')->getPaginationCount();
+
+ $this->assertNull($_SERVER['orders']);
+ unset($_SERVER['orders']);
+
+ $this->assertEquals(array('foo', 'bar'), $builder->columns);
+ $this->assertEquals(array(0 => array('column' => 'foo', 'direction' => 'desc')), $builder->orders);
+ $this->assertEquals(1, $results);
+ }
+
+
public function testPluckMethodReturnsSingleColumn()
{
$builder = $this->getBuilder(); | false |
Other | laravel | framework | c9f84fe994e25c468cd3ef457fd638cf4fe0dd73.json | Add events firing in transaction.
Signed-off-by: Kevin Simard <kesimard@outlook.com> | src/Illuminate/Database/Connection.php | @@ -454,6 +454,11 @@ public function beginTransaction()
{
$this->pdo->beginTransaction();
}
+
+ if (isset($this->events))
+ {
+ $this->events->fire('connection.beganTransaction', $this);
+ }
}
/**
@@ -466,6 +471,11 @@ public function commit()
if ($this->transactions == 1) $this->pdo->commit();
--$this->transactions;
+
+ if (isset($this->events))
+ {
+ $this->events->fire('connection.commited', $this);
+ }
}
/**
@@ -485,6 +495,11 @@ public function rollBack()
{
--$this->transactions;
}
+
+ if (isset($this->events))
+ {
+ $this->events->fire('connection.rollBacked', $this);
+ }
}
/**
@@ -878,6 +893,16 @@ public function setFetchMode($fetchMode)
$this->fetchMode = $fetchMode;
}
+ /**
+ * Get the number of active transactions.
+ *
+ * @return int
+ */
+ public function getTransactions()
+ {
+ return $this->transactions;
+ }
+
/**
* Get the connection query log.
* | true |
Other | laravel | framework | c9f84fe994e25c468cd3ef457fd638cf4fe0dd73.json | Add events firing in transaction.
Signed-off-by: Kevin Simard <kesimard@outlook.com> | tests/Database/DatabaseConnectionTest.php | @@ -121,6 +121,36 @@ public function testAffectingStatementProperlyCallsPDO()
}
+ public function testBeganTransactionFiresEventsIfSet()
+ {
+ $pdo = $this->getMock('DatabaseConnectionTestMockPDO');
+ $connection = $this->getMockConnection(array(), $pdo);
+ $connection->setEventDispatcher($events = m::mock('Illuminate\Events\Dispatcher'));
+ $events->shouldReceive('fire')->once()->with('connection.beganTransaction', $connection);
+ $connection->beginTransaction();
+ }
+
+
+ public function testCommitedFiresEventsIfSet()
+ {
+ $pdo = $this->getMock('DatabaseConnectionTestMockPDO');
+ $connection = $this->getMockConnection(array(), $pdo);
+ $connection->setEventDispatcher($events = m::mock('Illuminate\Events\Dispatcher'));
+ $events->shouldReceive('fire')->once()->with('connection.commited', $connection);
+ $connection->commit();
+ }
+
+
+ public function testRollBackedFiresEventsIfSet()
+ {
+ $pdo = $this->getMock('DatabaseConnectionTestMockPDO');
+ $connection = $this->getMockConnection(array(), $pdo);
+ $connection->setEventDispatcher($events = m::mock('Illuminate\Events\Dispatcher'));
+ $events->shouldReceive('fire')->once()->with('connection.rollBacked', $connection);
+ $connection->rollBack();
+ }
+
+
public function testTransactionMethodRunsSuccessfully()
{
$pdo = $this->getMock('DatabaseConnectionTestMockPDO', array('beginTransaction', 'commit')); | true |
Other | laravel | framework | 2286d156388ac57b7de8824ade3676298626aaf6.json | Support mixed target data in data_get | src/Illuminate/Support/helpers.php | @@ -557,23 +557,38 @@ function csrf_token()
* @param string $key
* @param mixed $default
* @return mixed
- *
- * @throws \InvalidArgumentException
*/
function data_get($target, $key, $default = null)
{
- if (is_array($target))
- {
- return array_get($target, $key, $default);
- }
- elseif (is_object($target))
- {
- return object_get($target, $key, $default);
- }
- else
+ if (is_null($key)) return $target;
+
+ foreach (explode('.', $key) as $segment)
{
- throw new \InvalidArgumentException("Array or object must be passed to data_get.");
+ if (is_array($target))
+ {
+ if ( ! array_key_exists($segment, $target))
+ {
+ return value($default);
+ }
+
+ $target = $target[$segment];
+ }
+ elseif (is_object($target))
+ {
+ if ( ! isset($target->{$segment}))
+ {
+ return value($default);
+ }
+
+ $target = $target->{$segment};
+ }
+ else
+ {
+ return value($default);
+ }
}
+
+ return $target;
}
}
| true |
Other | laravel | framework | 2286d156388ac57b7de8824ade3676298626aaf6.json | Support mixed target data in data_get | tests/Support/SupportHelpersTest.php | @@ -207,6 +207,17 @@ public function testObjectGet()
$this->assertEquals('Taylor', object_get($class, 'name.first'));
}
+ public function testDataGet()
+ {
+ $object = (object) array('users' => array('name' => array('Taylor', 'Otwell')));
+ $array = array((object) array('users' => array((object) array('name' => 'Taylor'))));
+
+ $this->assertEquals('Taylor', data_get($object, 'users.name.0'));
+ $this->assertEquals('Taylor', data_get($array, '0.users.0.name'));
+ $this->assertNull(data_get($array, '0.users.3'));
+ $this->assertEquals('Not found', data_get($array, '0.users.3', 'Not found'));
+ $this->assertEquals('Not found', data_get($array, '0.users.3', function (){ return 'Not found'; }));
+ }
public function testArraySort()
{ | true |
Other | laravel | framework | ff424f62a1d855c5a4b7c9a5ffa0f9a17b25c551.json | Remove unused app variables from the tests | tests/Foundation/ProviderRepositoryTest.php | @@ -93,7 +93,6 @@ public function testLoadManifestReturnsParsedJSON()
$repo = new Illuminate\Foundation\ProviderRepository($files = m::mock('Illuminate\Filesystem\Filesystem'), __DIR__);
$files->shouldReceive('exists')->once()->with(__DIR__.'/services.json')->andReturn(true);
$files->shouldReceive('get')->once()->with(__DIR__.'/services.json')->andReturn(json_encode($array = array('users' => array('dayle' => true))));
- $app = new Illuminate\Foundation\Application;
$array['when'] = array();
$this->assertEquals($array, $repo->loadManifest());
@@ -104,7 +103,6 @@ public function testWriteManifestStoresToProperLocation()
{
$repo = new Illuminate\Foundation\ProviderRepository($files = m::mock('Illuminate\Filesystem\Filesystem'), __DIR__);
$files->shouldReceive('put')->once()->with(__DIR__.'/services.json', json_encode(array('foo')));
- $app = new Illuminate\Foundation\Application;
$result = $repo->writeManifest(array('foo'));
| false |
Other | laravel | framework | 666241ebc6c99cd3af0c3ce7fc63d7107c6edc3b.json | Remove the count. | src/Illuminate/Database/Eloquent/Builder.php | @@ -696,8 +696,6 @@ protected function addHasWhere(Builder $hasQuery, Relation $relation, $operator,
{
$this->mergeWheresToHas($hasQuery, $relation);
- $count = new Expression((int) $count);
-
return $this->where(new Expression('('.$hasQuery->toSql().')'), $operator, $count, $boolean);
}
| false |
Other | laravel | framework | aafa11b45636841c4eb175e070450ae3a68aa544.json | Turn the count into an expression. | src/Illuminate/Database/Eloquent/Builder.php | @@ -696,6 +696,8 @@ protected function addHasWhere(Builder $hasQuery, Relation $relation, $operator,
{
$this->mergeWheresToHas($hasQuery, $relation);
+ $count = new Expression((int) $count);
+
return $this->where(new Expression('('.$hasQuery->toSql().')'), $operator, $count, $boolean);
}
| false |
Other | laravel | framework | 549faad51c4b9ca05cc4e49f354e7b55d0f3afb9.json | Throw exception when no primary key and deleting. | src/Illuminate/Database/Eloquent/Model.php | @@ -960,6 +960,11 @@ public static function destroy($ids)
*/
public function delete()
{
+ if (is_null($this->primaryKey))
+ {
+ throw new \Exception("No primary key defined on model.");
+ }
+
if ($this->exists)
{
if ($this->fireModelEvent('deleting') === false) return false; | false |
Other | laravel | framework | 657338b49c0f6b48a892ddb06eafd13baab1948a.json | Fix bug. Update change log. | src/Illuminate/Foundation/changes.json | @@ -13,7 +13,8 @@
{"message": "Soft deleting models now use SoftDeletingTrait instead of softDelete property.", "backport": null},
{"message": "The queue:listen command will now write the names of the jobs it processes to the console.", "backport": null},
{"message": "Added Mailgun API transport for Mail::send. Depends on new 'services' configuration file.", "backport": null},
- {"message": "Added Mandrill API transport for Mail::send. Depends on new 'services' configuration file.", "backport": null}
+ {"message": "Added Mandrill API transport for Mail::send. Depends on new 'services' configuration file.", "backport": null},
+ {"message": "Added 'log' mail transport for Mail::send. Writes raw MIME string to log files.", "backport": null}
],
"4.1.*": [
{"message": "Added new SSH task runner tools.", "backport": null}, | true |
Other | laravel | framework | 657338b49c0f6b48a892ddb06eafd13baab1948a.json | Fix bug. Update change log. | src/Illuminate/Mail/MailServiceProvider.php | @@ -222,7 +222,7 @@ protected function registerLogTransport($config)
{
$this->app->bindShared('swift.transport', function($app)
{
- return new LogTransport($app['log']);
+ return new LogTransport($app['log']->getMonolog());
});
}
| true |
Other | laravel | framework | 4ae77db16e5fc38eff86cfba86c6f4421ac0f173.json | Log transport for mail. | src/Illuminate/Mail/MailServiceProvider.php | @@ -4,6 +4,7 @@
use Illuminate\Support\ServiceProvider;
use Swift_SmtpTransport as SmtpTransport;
use Swift_MailTransport as MailTransport;
+use Illuminate\Mail\Transport\LogTransport;
use Illuminate\Mail\Transport\MailgunTransport;
use Illuminate\Mail\Transport\MandrillTransport;
use Swift_SendmailTransport as SendmailTransport;
@@ -31,7 +32,9 @@ public function register()
// Once we have create the mailer instance, we will set a container instance
// on the mailer. This allows us to resolve mailer classes via containers
// for maximum testability on said classes instead of passing Closures.
- $mailer = new Mailer($app['view'], $app['swift.mailer'], $app['events']);
+ $mailer = new Mailer(
+ $app['view'], $app['swift.mailer'], $app['events']
+ );
$mailer->setLogger($app['log'])->setQueue($app['queue']);
@@ -105,6 +108,9 @@ protected function registerSwiftTransport($config)
case 'mandrill':
return $this->registerMandrillTransport($config);
+ case 'log':
+ return $this->registerLogTransport($config);
+
default:
throw new \InvalidArgumentException('Invalid mail driver.');
}
@@ -206,6 +212,20 @@ protected function registerMandrillTransport($config)
});
}
+ /**
+ * Register the "Log" Swift Transport instance.
+ *
+ * @param array $config
+ * @return void
+ */
+ protected function registerLogTransport($config)
+ {
+ $this->app->bindShared('swift.transport', function($app)
+ {
+ return new LogTransport($app['log']);
+ });
+ }
+
/**
* Get the services provided by the provider.
*
| true |
Other | laravel | framework | 4ae77db16e5fc38eff86cfba86c6f4421ac0f173.json | Log transport for mail. | src/Illuminate/Mail/Mailer.php | @@ -5,10 +5,10 @@
use Swift_Message;
use Illuminate\Log\Writer;
use Illuminate\View\Factory;
+use Illuminate\Events\Dispatcher;
use Illuminate\Queue\QueueManager;
use Illuminate\Container\Container;
use Illuminate\Support\SerializableClosure;
-use Illuminate\Events\Dispatcher;
class Mailer {
@@ -26,6 +26,13 @@ class Mailer {
*/
protected $swift;
+ /**
+ * The event dispatcher instance.
+ *
+ * @var \Illuminate\Events\Dispatcher
+ */
+ protected $events;
+
/**
* The global from address and name.
*
@@ -60,20 +67,13 @@ class Mailer {
* @var array
*/
protected $failedRecipients = array();
-
+
/**
* Array of parsed views containing html and text view name.
*
* @var array
*/
protected $parsedViews = array();
-
- /**
- * The event dispatcher instance.
- *
- * @var \Illuminate\Events\Dispatcher
- */
- protected $events;
/**
* Create a new Mailer instance.
@@ -127,7 +127,7 @@ public function send($view, array $data, $callback)
// First we need to parse the view, which could either be a string or an array
// containing both an HTML and plain text versions of the view which should
// be used when sending an e-mail. We will extract both of them out here.
- list($view, $plain) = $this->parsedViews = $this->parseView($view);
+ list($view, $plain) = $this->parseView($view);
$data['message'] = $message = $this->createMessage();
@@ -315,6 +315,7 @@ protected function sendSwiftMessage($message)
{
$this->events->fire('mailer.sending', array($message));
}
+
if ( ! $this->pretending)
{
return $this->swift->send($message, $this->failedRecipients);
@@ -336,9 +337,8 @@ protected function sendSwiftMessage($message)
protected function logMessage($message)
{
$emails = implode(', ', array_keys((array) $message->getTo()));
- $views = implode(', ', $this->parsedViews);
- $this->logger->info("Pretending to mail message to: {$emails} [Subject: {$message->getSubject()}] [Use view: {$views}]");
+ $this->logger->info("Pretending to mail message to: {$emails}");
}
/** | true |
Other | laravel | framework | 4ae77db16e5fc38eff86cfba86c6f4421ac0f173.json | Log transport for mail. | src/Illuminate/Mail/Transport/LogTransport.php | @@ -0,0 +1,68 @@
+<?php namespace Illuminate\Mail\Transport;
+
+use Swift_Transport;
+use Swift_Mime_Message;
+use Psr\Log\LoggerInterface;
+use Swift_Events_EventListener;
+
+class LogTransport implements Swift_Transport {
+
+ /**
+ * The Logger instance.
+ *
+ * @var \Psr\Log\LoggerInterface
+ */
+ protected $logger;
+
+ /**
+ * Create a new Mandrill transport instance.
+ *
+ * @param string $key
+ * @return void
+ */
+ public function __construct(LoggerInterface $logger)
+ {
+ $this->logger = $logger;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isStarted()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function start()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function stop()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function send(Swift_Mime_Message $message, &$failedRecipients = null)
+ {
+ $this->logger->debug((string) $message);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function registerPlugin(Swift_Events_EventListener $plugin)
+ {
+ //
+ }
+
+} | true |
Other | laravel | framework | 4ae77db16e5fc38eff86cfba86c6f4421ac0f173.json | Log transport for mail. | tests/Mail/MailMailerTest.php | @@ -139,11 +139,10 @@ public function testMessagesCanBeLoggedInsteadOfSent()
$message->shouldReceive('setFrom')->never();
$mailer->setSwiftMailer(m::mock('StdClass'));
$message->shouldReceive('getTo')->once()->andReturn(array('taylor@userscape.com' => 'Taylor'));
- $message->shouldReceive('getSubject')->once()->andReturn('Lorem Ipsum');
$message->shouldReceive('getSwiftMessage')->once()->andReturn($message);
$mailer->getSwiftMailer()->shouldReceive('send')->never();
$logger = m::mock('Illuminate\Log\Writer');
- $logger->shouldReceive('info')->once()->with('Pretending to mail message to: taylor@userscape.com [Subject: Lorem Ipsum] [Use view: foo, ]');
+ $logger->shouldReceive('info')->once()->with('Pretending to mail message to: taylor@userscape.com');
$mailer->setLogger($logger);
$mailer->pretend();
| true |
Other | laravel | framework | 377df4f1a76530cfe6ca2c39e3fb406a87db212a.json | Add a space. | src/Illuminate/Mail/MailServiceProvider.php | @@ -24,7 +24,7 @@ public function register()
{
$me = $this;
- $this->app->bindShared('mailer', function($app) use($me)
+ $this->app->bindShared('mailer', function($app) use ($me)
{
$me->registerSwiftMailer();
| false |
Other | laravel | framework | 4af2e0be3b92f3e1f08d5cc3d2c49e9e7c64be81.json | move swiftMailer registration into closure
Signed-off-by: Suhayb El Wardany <me@suw.me> | src/Illuminate/Mail/MailServiceProvider.php | @@ -22,10 +22,12 @@ class MailServiceProvider extends ServiceProvider {
*/
public function register()
{
- $this->registerSwiftMailer();
+ $me = $this;
- $this->app->bindShared('mailer', function($app)
+ $this->app->bindShared('mailer', function($app) use($me)
{
+ $me->registerSwiftMailer();
+
// Once we have create the mailer instance, we will set a container instance
// on the mailer. This allows us to resolve mailer classes via containers
// for maximum testability on said classes instead of passing Closures.
| false |
Other | laravel | framework | 66cf7f89405e583efab34ffeb3e07e5095c8e579.json | Add Validator::each for validation of arrays | src/Illuminate/Validation/Validator.php | @@ -201,6 +201,34 @@ public function sometimes($attribute, $rules, $callback)
}
}
+ /**
+ * Define a set of rules that apply to each element in an array attribute.
+ *
+ * @param string $attribute
+ * @param string|array $rules
+ * @return void
+ */
+ public function each($attribute, $rules)
+ {
+ $data = array_get($this->data, $attribute);
+
+ if ( ! is_array($data))
+ {
+ if ($this->hasRule($attribute, 'Array')) return;
+
+ throw new \InvalidArgumentException('Attribute for each() must be an array.');
+ }
+
+ foreach ($data as $dataKey => $dataValue)
+ {
+ foreach ($rules as $ruleKey => $ruleValue)
+ {
+ $key = "$attribute.$dataKey.$ruleKey";
+ $this->mergeRules($key, $ruleValue);
+ }
+ }
+ }
+
/**
* Merge additional rules into a given attribute.
*
@@ -1787,6 +1815,11 @@ protected function getRule($attribute, $rules)
{
$rules = (array) $rules;
+ if ( ! array_key_exists($attribute, $this->rules))
+ {
+ return;
+ }
+
foreach ($this->rules[$attribute] as $rule)
{
list($rule, $parameters) = $this->parseRule($rule); | true |
Other | laravel | framework | 66cf7f89405e583efab34ffeb3e07e5095c8e579.json | Add Validator::each for validation of arrays | tests/Validation/ValidationValidatorTest.php | @@ -1056,6 +1056,42 @@ public function testExceptionThrownOnIncorrectParameterCount()
}
+ public function testValidateEach()
+ {
+ $trans = $this->getRealTranslator();
+ $data = ['foo' => [['field' => 5], ['field' => 10], ['field' => 15]]];
+
+ $v = new Validator($trans, $data, ['foo' => 'array']);
+ $v->each('foo', ['field' => 'numeric|min:6|max:14']);
+ $this->assertFalse($v->passes());
+
+ $v = new Validator($trans, $data, ['foo' => 'array']);
+ $v->each('foo', ['field' => 'numeric|min:4|max:16']);
+ $this->assertTrue($v->passes());
+ }
+
+
+ public function testValidateEachWithNonArrayWithArrayRule()
+ {
+ $trans = $this->getRealTranslator();
+ $v = new Validator($trans, ['foo' => 'string'], ['foo' => 'array']);
+ $v->each('foo', ['field' => 'min:7|max:13']);
+ $this->assertFalse($v->passes());
+ }
+
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testValidateEachWithNonArrayWithoutArrayRule()
+ {
+ $trans = $this->getRealTranslator();
+ $v = new Validator($trans, ['foo' => 'string'], ['foo' => 'numeric']);
+ $v->each('foo', ['field' => 'min:7|max:13']);
+ $this->assertFalse($v->passes());
+ }
+
+
protected function getTranslator()
{
return m::mock('Symfony\Component\Translation\TranslatorInterface'); | true |
Other | laravel | framework | 6c643e0cd2c988344aff8038d153ee5ea16a48f8.json | Fix posting of messages. | src/Illuminate/Mail/Transport/MailgunTransport.php | @@ -73,12 +73,12 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null)
{
$client = $this->getHttpClient();
- $response = $client->send($client->post($this->url, ['auth' => ['api', $this->key],
+ $client->post($this->url, ['auth' => ['api', $this->key],
'body' => [
'to' => $this->getTo($message),
'message' => new PostFile('message', (string) $message),
],
- ]));
+ ]);
}
/** | true |
Other | laravel | framework | 6c643e0cd2c988344aff8038d153ee5ea16a48f8.json | Fix posting of messages. | src/Illuminate/Mail/Transport/MandrillTransport.php | @@ -55,13 +55,13 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null)
{
$client = $this->getHttpClient();
- $client->send($client->post('https://mandrillapp.com/api/1.0/messages/send-raw.json', [
+ $client->post('https://mandrillapp.com/api/1.0/messages/send-raw.json', [
'body' => [
'key' => $this->key,
'raw_message' => (string) $message,
'async' => true,
],
- ]));
+ ]);
}
/** | true |
Other | laravel | framework | e452a41351602363420257813798b03e63f6367e.json | Remove unneeded accessor. | src/Illuminate/Mail/Transport/MailgunTransport.php | @@ -163,25 +163,4 @@ public function setDomain($domain)
return $this->domain = $domain;
}
- /**
- * Get the path to the storage directory.
- *
- * @return string
- */
- public function getStoragePath()
- {
- return $this->storagePath ?: storage_path().'/meta';
- }
-
- /**
- * Set the storage path.
- *
- * @param string $storagePath
- * @return void
- */
- public function setStoragePath($storagePath)
- {
- $this->storagePath = $storagePath;
- }
-
} | false |
Other | laravel | framework | 674765a6b7a256316410950dc36b8fb8c188a090.json | Convert Mailgun and Mandrill drivers to Guzzle 4. | src/Illuminate/Mail/Transport/MailgunTransport.php | @@ -2,8 +2,8 @@
use Swift_Transport;
use Swift_Mime_Message;
+use GuzzleHttp\Post\PostFile;
use Swift_Events_EventListener;
-use Guzzle\Http\Client as HttpClient;
class MailgunTransport implements Swift_Transport {
@@ -22,25 +22,24 @@ class MailgunTransport implements Swift_Transport {
protected $domain;
/**
- * The path where temporary files are written.
+ * THe Mailgun API end-point.
*
* @var string
*/
- protected $storagePath;
+ protected $url;
/**
* Create a new Mailgun transport instance.
*
* @param string $key
* @param string $domain
- * @param string $storagePath
* @return void
*/
- public function __construct($key, $domain, $storagePath = null)
+ public function __construct($key, $domain)
{
$this->key = $key;
$this->domain = $domain;
- $this->storagePath = $storagePath;
+ $this->url = 'https://api.mailgun.net/v2/'.$this->domain.'/messages.mime';
}
/**
@@ -72,20 +71,14 @@ public function stop()
*/
public function send(Swift_Mime_Message $message, &$failedRecipients = null)
{
- $request = $this->getHttpClient()
- ->post()
- ->addPostFields(['to' => $this->getTo($message)])
- ->setAuth('api', $this->key);
-
- $message = (string) $message;
-
- file_put_contents(
- $path = $this->getStoragePath().'/'.md5($message), $message
- );
-
- $request->addPostFile('message', $path)->send();
-
- @unlink($path);
+ $client = $this->getHttpClient();
+
+ $response = $client->send($client->post($this->url, ['auth' => ['api', $this->key],
+ 'body' => [
+ 'to' => $this->getTo($message),
+ 'message' => new PostFile('message', (string) $message),
+ ],
+ ]));
}
/**
@@ -121,11 +114,11 @@ protected function getTo(Swift_Mime_Message $message)
/**
* Get a new HTTP client instance.
*
- * @return \Guzzle\Http\Client
+ * @return \GuzzleHttp\Client
*/
protected function getHttpClient()
{
- return new HttpClient('https://api.mailgun.net/v2/'.$this->domain.'/messages.mime');
+ return new \GuzzleHttp\Client;
}
/** | true |
Other | laravel | framework | 674765a6b7a256316410950dc36b8fb8c188a090.json | Convert Mailgun and Mandrill drivers to Guzzle 4. | src/Illuminate/Mail/Transport/MandrillTransport.php | @@ -3,7 +3,6 @@
use Swift_Transport;
use Swift_Mime_Message;
use Swift_Events_EventListener;
-use Guzzle\Http\Client as HttpClient;
class MandrillTransport implements Swift_Transport {
@@ -54,11 +53,15 @@ public function stop()
*/
public function send(Swift_Mime_Message $message, &$failedRecipients = null)
{
- $this->getHttpClient()
- ->post(null, [], json_encode([
- 'key' => $this->key, 'raw_message' => (string) $message, 'async' => true,
- ]))
- ->send();
+ $client = $this->getHttpClient();
+
+ $client->send($client->post('https://mandrillapp.com/api/1.0/messages/send-raw.json', [
+ 'body' => [
+ 'key' => $this->key,
+ 'raw_message' => (string) $message,
+ 'async' => true,
+ ],
+ ]));
}
/**
@@ -76,7 +79,7 @@ public function registerPlugin(Swift_Events_EventListener $plugin)
*/
protected function getHttpClient()
{
- return new HttpClient('https://mandrillapp.com/api/1.0/messages/send-raw.json');
+ return new \GuzzleHttp\Client;
}
/** | true |
Other | laravel | framework | 4a38f403c75208cecab46ae2f05410cf351e741a.json | Add space between lines of code. | src/Illuminate/Validation/Validator.php | @@ -563,6 +563,7 @@ protected function validateRequiredIf($attribute, $value, $parameters)
$this->requireParameterCount(2, $parameters, 'required_if');
$data = array_get($this->data, $parameters[0]);
+
$values = array_slice($parameters, 1);
if (in_array($data, $values)) | false |
Other | laravel | framework | 4bc806c6fc5759d5f7227c3aa632af82282a6fa5.json | Allow multiple parameters for required_if | src/Illuminate/Validation/Validator.php | @@ -562,7 +562,10 @@ protected function validateRequiredIf($attribute, $value, $parameters)
{
$this->requireParameterCount(2, $parameters, 'required_if');
- if ($parameters[1] == array_get($this->data, $parameters[0]))
+ $data = array_get($this->data, $parameters[0]);
+ $values = array_slice($parameters, 1);
+
+ if (in_array($data, $values))
{
return $this->validateRequired($attribute, $value);
} | true |
Other | laravel | framework | 4bc806c6fc5759d5f7227c3aa632af82282a6fa5.json | Allow multiple parameters for required_if | tests/Validation/ValidationValidatorTest.php | @@ -345,6 +345,14 @@ public function testRequiredIf()
$trans = $this->getRealTranslator();
$v = new Validator($trans, array('first' => 'taylor', 'last' => 'otwell'), array('last' => 'required_if:first,taylor'));
$this->assertTrue($v->passes());
+
+ $trans = $this->getRealTranslator();
+ $v = new Validator($trans, array('first' => 'taylor', 'last' => 'otwell'), array('last' => 'required_if:first,taylor,dayle'));
+ $this->assertTrue($v->passes());
+
+ $trans = $this->getRealTranslator();
+ $v = new Validator($trans, array('first' => 'dayle', 'last' => 'rees'), array('last' => 'required_if:first,taylor,dayle'));
+ $this->assertTrue($v->passes());
}
| true |
Other | laravel | framework | fbb24e5eadbb47152645e25d5b63bbdffe023058.json | Return the index instead of the choice.
Signed-off-by: Jason Lewis <jason.lewis1991@gmail.com> | src/Illuminate/Console/Command.php | @@ -222,9 +222,7 @@ public function choice($question, array $choices, $default = null, $attempts = f
{
$dialog = $this->getHelperSet()->get('dialog');
- $choice = $dialog->select($this->output, "<question>$question</question>", $choices, $default, $attempts);
-
- return $choices[$choice];
+ return $dialog->select($this->output, "<question>$question</question>", $choices, $default, $attempts);
}
/** | false |
Other | laravel | framework | 0719bad766e625f25502b695a4dcaf3b976ddcab.json | Shorten variable name. | src/Illuminate/Support/Facades/Response.php | @@ -83,16 +83,16 @@ public static function stream($callback, $status = 200, array $headers = array()
* @param \SplFileInfo|string $file
* @param string $name
* @param array $headers
- * @param null|string $contentDisposition
+ * @param null|string $disposition
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*/
- public static function download($file, $name = null, array $headers = array(), $contentDisposition = 'attachment')
+ public static function download($file, $name = null, array $headers = array(), $disposition = 'attachment')
{
- $response = new BinaryFileResponse($file, 200, $headers, true, $contentDisposition);
+ $response = new BinaryFileResponse($file, 200, $headers, true, $disposition);
if ( ! is_null($name))
{
- return $response->setContentDisposition($contentDisposition, $name, Str::ascii($name));
+ return $response->setContentDisposition($disposition, $name, Str::ascii($name));
}
return $response; | false |
Other | laravel | framework | f1eb309438f7d19e8a71dcecc0eced5f8b33a7c3.json | Fix typo in core alias for event dispatcher | src/Illuminate/Foundation/Application.php | @@ -1073,7 +1073,7 @@ public function registerCoreContainerAliases()
'cookie' => 'Illuminate\Cookie\CookieJar',
'encrypter' => 'Illuminate\Encryption\Encrypter',
'db' => 'Illuminate\Database\DatabaseManager',
- 'events' => 'Illuminate\Events\Dispatacher',
+ 'events' => 'Illuminate\Events\Dispatcher',
'files' => 'Illuminate\Filesystem\Filesystem',
'form' => 'Illuminate\Html\FormBuilder',
'hash' => 'Illuminate\Hashing\HasherInterface', | false |
Other | laravel | framework | f5d9bc0a6662b40cdbecea7a7f8ff6a9819954c7.json | add test for Session\Store::regenerateToken | tests/Session/SessionStoreTest.php | @@ -246,6 +246,15 @@ public function testToken()
}
+ public function testRegenerateToken()
+ {
+ $session = $this->getSession();
+ $token = $session->getToken();
+ $session->regenerateToken();
+ $this->assertNotEquals($token, $session->getToken());
+ }
+
+
public function testName()
{
$session = $this->getSession(); | false |
Other | laravel | framework | 0e4cfdc69bf8df348187f42e7c2c36a23a6cc03f.json | add findOrNew eloquent method | src/Illuminate/Database/Eloquent/Model.php | @@ -520,6 +520,20 @@ public static function find($id, $columns = array('*'))
return $instance->newQuery()->find($id, $columns);
}
+ /**
+ * Find a model by its primary key or return new static.
+ *
+ * @param mixed $id
+ * @param array $columns
+ * @return \Illuminate\Database\Eloquent\Model|Collection|static
+ */
+ public static function findOrNew($id, $columns = array('*'))
+ {
+ if ( ! is_null($model = static::find($id, $columns))) return $model;
+
+ return new static($columns);
+ }
+
/**
* Find a model by its primary key or throw an exception.
* | false |
Other | laravel | framework | 6cd389a68d7fffa94fd3439ee49065562fe74ef9.json | Add a chunk method to Collection | src/Illuminate/Support/Collection.php | @@ -386,6 +386,25 @@ public function slice($offset, $length = null, $preserveKeys = false)
return new static(array_slice($this->items, $offset, $length, $preserveKeys));
}
+ /**
+ * Chunk the underlying collection array.
+ *
+ * @param int $size
+ * @param bool $preserveKeys
+ * @return \Illuminate\Support\Collection
+ */
+ public function chunk($size, $preserveKeys = false)
+ {
+ $chunks = new static;
+
+ foreach (array_chunk($this->items, $size, $preserveKeys) as $chunk)
+ {
+ $chunks->push(new static($chunk));
+ }
+
+ return $chunks;
+ }
+
/**
* Sort through each item with a callback.
*
| true |
Other | laravel | framework | 6cd389a68d7fffa94fd3439ee49065562fe74ef9.json | Add a chunk method to Collection | tests/Support/SupportCollectionTest.php | @@ -230,6 +230,19 @@ public function testReverse()
}
+ public function testChunk ()
+ {
+ $data = new Collection(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
+ $data = $data->chunk(3);
+
+ $this->assertInstanceOf('Illuminate\Support\Collection', $data);
+ $this->assertInstanceOf('Illuminate\Support\Collection', $data[0]);
+ $this->assertEquals(4, $data->count());
+ $this->assertEquals(array(1, 2, 3), $data[0]->toArray());
+ $this->assertEquals(array(10), $data[3]->toArray());
+ }
+
+
public function testListsWithArrayAndObjectValues()
{
$data = new Collection(array((object) array('name' => 'taylor', 'email' => 'foo'), array('name' => 'dayle', 'email' => 'bar')));
| true |
Other | laravel | framework | 2704bace3a7187205db03d55f6e8304743eb8396.json | Fix bug and add regression test | src/Illuminate/Http/JsonResponse.php | @@ -5,13 +5,6 @@
class JsonResponse extends \Symfony\Component\HttpFoundation\JsonResponse {
- /**
- * The json encoding options.
- *
- * @var int
- */
- protected $jsonOptions;
-
/**
* Constructor.
*
@@ -32,14 +25,11 @@ public function __construct($data = null, $status = 200, $headers = array(), $op
*
* @param bool $assoc
* @param int $depth
- * @param int $options
* @return mixed
*/
- public function getData($assoc = false, $depth = 512, $options = null)
+ public function getData($assoc = false, $depth = 512)
{
- $options = $options ?: $this->jsonOptions;
-
- return json_decode($this->data, $assoc, $depth, $options);
+ return json_decode($this->data, $assoc, $depth);
}
/** | true |
Other | laravel | framework | 2704bace3a7187205db03d55f6e8304743eb8396.json | Fix bug and add regression test | tests/Http/HttpJsonResponseTest.php | @@ -0,0 +1,13 @@
+<?php
+
+class HttpJsonResponseTest extends PHPUnit_Framework_TestCase {
+
+ public function testSetAndRetrieveData()
+ {
+ $response = new Illuminate\Http\JsonResponse(array('foo' => 'bar'));
+ $data = $response->getData();
+ $this->assertInstanceOf('StdClass', $data);
+ $this->assertEquals('bar', $data->foo);
+ }
+
+} | true |
Other | laravel | framework | 9997b7ffb5a9b09914db2eca12118f84a70da24f.json | Create a composite index for morphing columns | src/Illuminate/Database/Schema/Blueprint.php | @@ -668,6 +668,8 @@ public function morphs($name)
$this->unsignedInteger("{$name}_id");
$this->string("{$name}_type");
+
+ $this->index(array("{$name}_id", "{$name}_type"));
}
/** | false |
Other | laravel | framework | 077a9ef83057e8df5993ef16f1d607640cbb1dc8.json | Check path in method hasFile.
This pull-request solves a problem encountered when uploading a "corrupt" file like one of the files you can found at http://www.thinkbroadband.com/download.html.
Any of these files is considered empty in the validation (I am checking that a image is uploaded), therefore these pass validation. However, in the controller, when I try to save the image I check if Input has the file and this returned true.
This commit solves this problem. Previously a corrupt file passed the validation because is considered empty and is not required, but was not considered empty by the method Input::hasFile(). | src/Illuminate/Http/Request.php | @@ -293,7 +293,7 @@ public function hasFile($key)
{
if (is_array($file = $this->file($key))) $file = head($file);
- return $file instanceof \SplFileInfo;
+ return $file instanceof \SplFileInfo && $file->getPath() != '';
}
/** | false |
Other | laravel | framework | 7e5514db12e390bc8acf12f8ddee9da8f480c931.json | Add default to array_pull to match array_get. | src/Illuminate/Support/helpers.php | @@ -376,11 +376,12 @@ function array_pluck($array, $value, $key = null)
*
* @param array $array
* @param string $key
+ * @param mixed $default
* @return mixed
*/
- function array_pull(&$array, $key)
+ function array_pull(&$array, $key, $default = null)
{
- $value = array_get($array, $key);
+ $value = array_get($array, $key, $default);
array_forget($array, $key);
| false |
Other | laravel | framework | 58d103c921151fd9e3af626dd243beb0d5d8d460.json | add new blade statements: stack and push | src/Illuminate/View/Compilers/BladeCompiler.php | @@ -473,6 +473,39 @@ protected function compileInclude($expression)
return "<?php echo \$__env->make($expression, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>";
}
+ /**
+ * Compile the stack statements into the content
+ *
+ * @param string $expression
+ * @return string
+ */
+ protected function compileStack($expression)
+ {
+ return "<?php echo \$__env->stackContent{$expression}; ?>";
+ }
+
+ /**
+ * Compile the push statements into valid PHP
+ *
+ * @param $expression
+ * @return string
+ */
+ protected function compilePush($expression)
+ {
+ return "<?php echo \$__env->startPush{$expression}; ?>";
+ }
+
+ /**
+ * Compile the endpush statements into valid PHP
+ *
+ * @param $expression
+ * @return string
+ */
+ protected function compileEndpush($expression)
+ {
+ return "<?php echo \$__env->endPush{$expression}; ?>";
+ }
+
/**
* Register a custom Blade compiler.
* | true |
Other | laravel | framework | 58d103c921151fd9e3af626dd243beb0d5d8d460.json | add new blade statements: stack and push | src/Illuminate/View/Factory.php | @@ -78,13 +78,27 @@ class Factory {
*/
protected $sectionStack = array();
+ /**
+ * The stack of in-progress stacks.
+ *
+ * @var array
+ */
+ protected $stackStack = array();
+
/**
* The number of active rendering operations.
*
* @var int
*/
protected $renderCount = 0;
+ /**
+ * All of the finished, fully pushed stacks
+ *
+ * @var array
+ */
+ protected $stacks = array();
+
/**
* Create a new view factory instance.
*
@@ -471,6 +485,17 @@ public function startSection($section, $content = '')
}
}
+ /**
+ * @param string $stackName
+ * @return void
+ */
+ public function startPush($stackName)
+ {
+ $this->stackStack[] = $stackName;
+
+ ob_start();
+ }
+
/**
* Inject inline content into a section.
*
@@ -515,6 +540,27 @@ public function stopSection($overwrite = false)
return $last;
}
+ /**
+ * Stop pushing content into a stack
+ *
+ * @return string
+ */
+ public function endPush()
+ {
+ $last = array_pop($this->stackStack);
+
+ if (isset($this->stacks[$last]))
+ {
+ $this->stacks[$last] .= ob_get_clean();
+ }
+ else
+ {
+ $this->stacks[$last] = ob_get_clean();
+ }
+
+ return $last;
+ }
+
/**
* Stop injecting content into a section and append it.
*
@@ -557,6 +603,11 @@ protected function extendSection($section, $content)
}
}
+ public function stackContent($stackName)
+ {
+ return isset($this->stacks[$stackName]) ? $this->stacks[$stackName] : '';
+ }
+
/**
* Get the string contents of a section.
* | true |
Other | laravel | framework | 58d103c921151fd9e3af626dd243beb0d5d8d460.json | add new blade statements: stack and push | tests/View/ViewBladeCompilerTest.php | @@ -152,6 +152,25 @@ public function testExtendsAreCompiled()
$this->assertEquals($expected, $compiler->compileString($string));
}
+ public function testPushIsCompiled()
+ {
+ $compiler = new BladeCompiler($this->getFiles(), __DIR__);
+ $string = '@push(\'foo\')
+test
+@endpush';
+ $expected = '<?php echo $__env->startPush(\'foo\'); ?>
+test
+<?php echo $__env->endPush; ?>';
+ $this->assertEquals($expected, $compiler->compileString($string));
+ }
+
+ public function testStackIsCompiled()
+ {
+ $compiler = new BladeCompiler($this->getFiles(), __DIR__);
+ $string = '@stack(\'foo\')';;
+ $expected = '<?php echo $__env->stackContent(\'foo\'); ?>';
+ $this->assertEquals($expected, $compiler->compileString($string));
+ }
public function testCommentsAreCompiled()
{ | true |
Other | laravel | framework | 58d103c921151fd9e3af626dd243beb0d5d8d460.json | add new blade statements: stack and push | tests/View/ViewFactoryTest.php | @@ -256,6 +256,26 @@ public function testSectionExtending()
$this->assertEquals('hi there', $factory->yieldContent('foo'));
}
+ public function testSingleStackPush()
+ {
+ $factory = $this->getFactory();
+ $factory->startPush('foo');
+ echo 'hi';
+ $factory->endPush();
+ $this->assertEquals('hi', $factory->stackContent('foo'));
+ }
+
+ public function testMultipleStackPush()
+ {
+ $factory = $this->getFactory();
+ $factory->startPush('foo');
+ echo 'hi';
+ $factory->endPush();
+ $factory->startPush('foo');
+ echo ', Hello!';
+ $factory->endPush();
+ $this->assertEquals('hi, Hello!', $factory->stackContent('foo'));
+ }
public function testSessionAppending()
{ | true |
Other | laravel | framework | 9a2d5c67468be927b0e7530b1a5768a03b32c757.json | Handle non-string messages in Log::method() calls
Passing a more complex variable like an object or array to one of the Log calls spits out an error exception. This patch converts these messages into a `print_r` representation. | src/Illuminate/Log/Writer.php | @@ -234,6 +234,10 @@ public function write()
*/
public function __call($method, $parameters)
{
+ if (isset($parameters[0]) && in_array(gettype($parameters[0]), ['object', 'array', 'resource'])) {
+ $parameters[0] = print_r($parameters[0], true);
+ }
+
if (in_array($method, $this->levels))
{
call_user_func_array(array($this, 'fireLogEvent'), array_merge(array($method), $parameters)); | false |
Other | laravel | framework | e4401ea20b687675178db34738a93bffd628919e.json | add getPath() method to BladeCompiler | src/Illuminate/View/Compilers/BladeCompiler.php | @@ -11,6 +11,13 @@ class BladeCompiler extends Compiler implements CompilerInterface {
*/
protected $extensions = array();
+ /**
+ * The file being compiled.
+ *
+ * @var string
+ */
+ protected $path;
+
/**
* All of the available compiler functions.
*
@@ -57,16 +64,42 @@ class BladeCompiler extends Compiler implements CompilerInterface {
* @param string $path
* @return void
*/
- public function compile($path)
+ public function compile($path = null)
{
- $contents = $this->compileString($this->files->get($path));
+ if ($path)
+ {
+ $this->setPath($path);
+ }
+
+ $contents = $this->compileString($this->files->get($this->getPath()));
if ( ! is_null($this->cachePath))
{
- $this->files->put($this->getCompiledPath($path), $contents);
+ $this->files->put($this->getCompiledPath($this->getPath()), $contents);
}
}
+ /**
+ * Set the current view path
+ *
+ * @param string $path
+ * @return void
+ */
+ public function setPath($path)
+ {
+ $this->path = $path;
+ }
+
+ /**
+ * Get the current view path
+ *
+ * @return string
+ */
+ public function getPath()
+ {
+ return $this->path;
+ }
+
/**
* Compile the given Blade template contents.
* | true |
Other | laravel | framework | e4401ea20b687675178db34738a93bffd628919e.json | add getPath() method to BladeCompiler | tests/View/ViewBladeCompilerTest.php | @@ -53,6 +53,24 @@ public function testCompileCompilesFileAndReturnsContents()
}
+ public function testCompileCompilesAndGetThePath()
+ {
+ $compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
+ $files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
+ $files->shouldReceive('put')->once()->with(__DIR__.'/'.md5('foo'), 'Hello World');
+ $compiler->compile('foo');
+ $this->assertEquals('foo', $compiler->getPath());
+ }
+
+
+ public function testCompileSetAndGetThePath()
+ {
+ $compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
+ $compiler->setPath('foo');
+ $this->assertEquals('foo', $compiler->getPath());
+ }
+
+
public function testCompileDoesntStoreFilesWhenCachePathIsNull()
{
$compiler = new BladeCompiler($files = $this->getFiles(), null); | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.