better support for entries without keys

This commit is contained in:
Martin Monperrus
2016-10-16 21:14:31 +02:00
parent 62d5411155
commit 578fcd97b3
2 changed files with 15 additions and 1 deletions
+14
View File
@@ -597,6 +597,20 @@ class BTBTest extends PHPUnit_Framework_TestCase {
$first_entry->removeField('author'); $first_entry->removeField('author');
$this->assertFalse($first_entry->hasField('author')); $this->assertFalse($first_entry->hasField('author'));
} }
function testdefaultkey() {
bibtexbrowser_configure('BIBTEXBROWSER_BIBTEX_VIEW', 'original');
$bibtex = "@article{title={An article Book},author = {Martin Monperrus and Foo Ac\'e and Monperrus, Martin}}";
$key = md5($bibtex);
$test_data = fopen('php://memory','x+');
fwrite($test_data, $bibtex);
fseek($test_data,0);
$db = new BibDataBase();
$db->update_internal("inline", $test_data);
$entry=$db->getEntryByKey($key);
$this->assertEquals($bibtex, $entry->getText());
}
} // end class } // end class
+1 -1
View File
@@ -911,7 +911,7 @@ class BibDBBuilder extends ParserDelegate {
// we add a key if there is no key // we add a key if there is no key
if (!$this->currentEntry->hasField(Q_KEY) && $this->currentEntry->getType()!='string') { if (!$this->currentEntry->hasField(Q_KEY) && $this->currentEntry->getType()!='string') {
$this->currentEntry->setField(Q_KEY,md5($this->currentEntry->getTitle().implode('',$this->currentEntry->getRawAuthors()))); $this->currentEntry->setField(Q_KEY,md5($entrysource));
} }
// we set the fulltext // we set the fulltext