Skip to content

Commit a92ab1c

Browse files
committed
Fixing bugs.
1 parent 98ea9ac commit a92ab1c

File tree

5 files changed

+42
-24
lines changed

5 files changed

+42
-24
lines changed

laravel/cache/drivers/driver.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,27 @@ abstract public function put($key, $value, $minutes);
6969
* @param int $minutes
7070
* @return mixed
7171
*/
72-
public function remember($key, $default, $minutes)
72+
public function remember($key, $default, $minutes, $function = 'put')
7373
{
7474
if ( ! is_null($item = $this->get($key, null))) return $item;
7575

76-
$this->put($key, $default = value($default), $minutes);
76+
$this->$function($key, $default = value($default), $minutes);
7777

7878
return $default;
7979
}
8080

81+
/**
82+
* Get an item from the cache, or cache the default value forever.
83+
*
84+
* @param string $key
85+
* @param mixed $default
86+
* @return mixed
87+
*/
88+
public function sear($key, $default)
89+
{
90+
return $this->remember($key, $default, null, 'forever');
91+
}
92+
8193
/**
8294
* Delete an item from the cache.
8395
*

laravel/cli/artisan.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,12 @@
1616
* for the "database" CLI option. This allows migrations to be run
1717
* conveniently for a test or staging database.
1818
*/
19-
if (isset($_SERVER['CLI']['DB']))
19+
20+
if ( ! is_null($database = get_cli_option('db')))
2021
{
21-
Config::set('database.default', $_SERVER['CLI']['DB']);
22+
Config::set('database.default', $database);
2223
}
2324

24-
/**
25-
* Overwrite the HttpFoundation request since we have set some of
26-
* the server variables since it was created. This allows us to
27-
* set the default database for the CLI task.
28-
*/
29-
30-
use Symfony\Component\HttpFoundation\LaravelRequest as RequestFoundation;
31-
32-
Request::$foundation = RequestFoundation::createFromGlobals();
33-
3425
/**
3526
* We will register all of the Laravel provided tasks inside the IoC
3627
* container so they can be resolved by the task class. This allows

laravel/core.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,7 @@
156156

157157
if (Request::cli())
158158
{
159-
foreach (Request::foundation()->server->get('argv') as $argument)
160-
{
161-
if (starts_with($argument, '--env='))
162-
{
163-
$environment = substr($argument, 6);
164-
165-
break;
166-
}
167-
}
159+
$environment = get_cli_option('env');
168160
}
169161
else
170162
{

laravel/database/schema.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@ public static function create($table, $callback)
4444
* Drop a database table from the schema.
4545
*
4646
* @param string $table
47+
* @param string $connection
4748
* @return void
4849
*/
49-
public static function drop($table)
50+
public static function drop($table, $connection = null)
5051
{
5152
$table = new Schema\Table($table);
5253

54+
$table->on($connection);
55+
5356
// To indicate that the table needs to be dropped, we will run the
5457
// "drop" command on the table instance and pass the instance to
5558
// the execute method as calling a Closure isn't needed.

laravel/helpers.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,4 +504,24 @@ function render_each($partial, array $data, $iterator, $empty = 'raw|')
504504
function yield($section)
505505
{
506506
return Laravel\Section::yield($section);
507+
}
508+
509+
/**
510+
* Get a CLI option from the argv $_SERVER variable.
511+
*
512+
* @param string $option
513+
* @param mixed $default
514+
* @return string
515+
*/
516+
function get_cli_option($option, $default = null)
517+
{
518+
foreach (Laravel\Request::foundation()->server->get('argv') as $argument)
519+
{
520+
if (starts_with($argument, "--{$option}="))
521+
{
522+
return substr($argument, strlen($option) + 3);
523+
}
524+
}
525+
526+
return value($default);
507527
}

0 commit comments

Comments
 (0)