Skip to content

Commit 8f4d2f9

Browse files
authored
Prevent global variables merging origin data (#468)
* Prevent global variables merging origin data * Add test coverage * 🍺
1 parent 24e7f80 commit 8f4d2f9

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/Globals/Variables.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ public static function makeModelFromContract(Contract $source)
3131

3232
$data = $source->data();
3333

34-
if ($source->hasOrigin()) {
35-
$data = $source->origin()->data()->merge($data);
36-
}
37-
3834
return $class::firstOrNew([
3935
'handle' => $source->globalSet()->handle(),
4036
'locale' => $source->locale,
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Globals;
4+
5+
use PHPUnit\Framework\Attributes\Test;
6+
use Statamic\Eloquent\Globals\VariablesModel;
7+
use Statamic\Facades;
8+
use Tests\TestCase;
9+
10+
class GlobalVariablesTest extends TestCase
11+
{
12+
#[Test]
13+
public function does_not_save_synced_origin_data_to_localizations()
14+
{
15+
$global = Facades\Globalset::make('test');
16+
17+
$global->addLocalization($global->makeLocalization('en')->data(['foo' => 'bar', 'baz' => 'qux']));
18+
$global->addLocalization($global->makeLocalization('fr')->origin('en')->data([]));
19+
20+
$global->save();
21+
22+
$this->assertCount(2, VariablesModel::all());
23+
$this->assertSame(VariablesModel::all()->firstWhere('locale', 'fr')->data, []);
24+
}
25+
}

0 commit comments

Comments
 (0)