Skip to content
Snippets Groups Projects
Commit fb8d22e5 authored by Demian Katz's avatar Demian Katz
Browse files

Fixed bug: first_indexed value in change_tracker updated inappropriately.

Resolves VUFIND-835; thanks to Luke O'Sullivan for the fix.
parent a2e06f3d
No related merge requests found
...@@ -203,7 +203,7 @@ class ChangeTracker extends Gateway ...@@ -203,7 +203,7 @@ class ChangeTracker extends Gateway
// If first indexed is null, we're restoring a deleted record, so // If first indexed is null, we're restoring a deleted record, so
// we need to treat it as new -- we'll use the current time. // we need to treat it as new -- we'll use the current time.
if (empty($this->first_indexed)) { if (empty($row->first_indexed)) {
$row->first_indexed = $row->last_indexed; $row->first_indexed = $row->last_indexed;
} }
......
...@@ -77,6 +77,10 @@ class ChangeTrackerTest extends \VuFindTest\Unit\DbTestCase ...@@ -77,6 +77,10 @@ class ChangeTrackerTest extends \VuFindTest\Unit\DbTestCase
$this->assertTrue(empty($row->deleted)); $this->assertTrue(empty($row->deleted));
$this->assertEquals($row->first_indexed, $row->last_indexed); $this->assertEquals($row->first_indexed, $row->last_indexed);
$this->assertEquals($row->last_record_change, '2012-01-17 20:46:10'); $this->assertEquals($row->last_record_change, '2012-01-17 20:46:10');
$previousFirstIndexed = $row->first_indexed;
// Sleep two seconds to be sure timestamps change:
sleep(2);
// Index a later record version -- this should lead to changes: // Index a later record version -- this should lead to changes:
$tracker->index($core, 'test1', 1326833176); $tracker->index($core, 'test1', 1326833176);
...@@ -89,6 +93,9 @@ class ChangeTrackerTest extends \VuFindTest\Unit\DbTestCase ...@@ -89,6 +93,9 @@ class ChangeTrackerTest extends \VuFindTest\Unit\DbTestCase
); );
$this->assertEquals($row->last_record_change, '2012-01-17 20:46:16'); $this->assertEquals($row->last_record_change, '2012-01-17 20:46:16');
// Make sure the "first indexed" date hasn't changed!
$this->assertEquals($row->first_indexed, $previousFirstIndexed);
// Delete the record: // Delete the record:
$tracker->markDeleted($core, 'test1'); $tracker->markDeleted($core, 'test1');
$row = $tracker->retrieve($core, 'test1'); $row = $tracker->retrieve($core, 'test1');
...@@ -108,6 +115,7 @@ class ChangeTrackerTest extends \VuFindTest\Unit\DbTestCase ...@@ -108,6 +115,7 @@ class ChangeTrackerTest extends \VuFindTest\Unit\DbTestCase
$this->assertTrue(is_object($row)); $this->assertTrue(is_object($row));
$this->assertTrue(empty($row->deleted)); $this->assertTrue(empty($row->deleted));
$this->assertEquals($row->last_record_change, '2012-01-17 20:46:10'); $this->assertEquals($row->last_record_change, '2012-01-17 20:46:10');
$this->assertEquals($row->first_indexed, $row->last_indexed);
// Clean up after ourselves: // Clean up after ourselves:
$tracker->delete(array('core' => $core)); $tracker->delete(array('core' => $core));
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment