Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.1] Remove broken timestamps option #12572

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/Illuminate/Database/Eloquent/Model.php
Expand Up @@ -1442,14 +1442,14 @@ public function save(array $options = [])
// that is already in this database using the current IDs in this "where"
// clause to only update this model. Otherwise, we'll just insert them.
if ($this->exists) {
$saved = $this->performUpdate($query, $options);
$saved = $this->performUpdate($query);
}

// If the model is brand new, we'll insert it into our database and set the
// ID attribute on the model to the value of the newly inserted row's ID
// which is typically an auto-increment value managed by the database.
else {
$saved = $this->performInsert($query, $options);
$saved = $this->performInsert($query);
}

if ($saved) {
Expand Down Expand Up @@ -1495,10 +1495,9 @@ 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, array $options = [])
protected function performUpdate(Builder $query)
{
$dirty = $this->getDirty();

Expand All @@ -1513,7 +1512,7 @@ protected function performUpdate(Builder $query, array $options = [])
// 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 && Arr::get($options, 'timestamps', true)) {
if ($this->timestamps) {
$this->updateTimestamps();
}

Expand All @@ -1536,10 +1535,9 @@ protected function performUpdate(Builder $query, array $options = [])
* Perform a model insert operation.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array $options
* @return bool
*/
protected function performInsert(Builder $query, array $options = [])
protected function performInsert(Builder $query)
{
if ($this->fireModelEvent('creating') === false) {
return false;
Expand All @@ -1548,7 +1546,7 @@ protected function performInsert(Builder $query, array $options = [])
// First we'll need to create a fresh query instance and touch the creation and
// update timestamps on this model, which are maintained by us for developer
// convenience. After, we will just continue saving these model instances.
if ($this->timestamps && Arr::get($options, 'timestamps', true)) {
if ($this->timestamps) {
$this->updateTimestamps();
}

Expand Down
16 changes: 0 additions & 16 deletions tests/Database/DatabaseEloquentModelTest.php
Expand Up @@ -1142,22 +1142,6 @@ public function testRelationshipTouchOwnersIsNotPropagatedIfNoRelationshipResult
$model->touchOwners();
}

public function testTimestampsAreNotUpdatedWithTimestampsFalseSaveOption()
{
$model = m::mock('EloquentModelStub[newQueryWithoutScopes]');
$query = m::mock('Illuminate\Database\Eloquent\Builder');
$query->shouldReceive('where')->once()->with('id', '=', 1);
$query->shouldReceive('update')->once()->with(['name' => 'taylor'])->andReturn(1);
$model->shouldReceive('newQueryWithoutScopes')->once()->andReturn($query);

$model->id = 1;
$model->syncOriginal();
$model->name = 'taylor';
$model->exists = true;
$this->assertTrue($model->save(['timestamps' => false]));
$this->assertNull($model->updated_at);
}

public function testModelAttributesAreCastedWhenPresentInCastsArray()
{
$model = new EloquentModelCastingStub;
Expand Down