# Buggy code
def add_document(self, path, title, text):
    self.database.begin_transaction()
    # sphinx_page_path is used to easily retrieve documents by path.
    sphinx_page_path = '"sphinxpagepath%s"' % path.replace("/", "_")
    # Delete the old document if it exists.
    self.database.delete_document(sphinx_page_path)

    doc = xapian.Document()
    doc.set_data(text)
    doc.add_value(self.DOC_PATH, path)
    doc.add_value(self.DOC_TITLE, title)
    self.indexer.set_document(doc)
    self.indexer.index_text(text)
    doc.add_term(sphinx_page_path)
    for word in text.split():
        doc.add_posting(word, 1)
    self.database.add_document(doc)
    self.database.commit_transaction()


# Traceback (TypeError)
======================================================================
ERROR: test_searchadapters.test_xapian
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/dmitry/upstream/sphinx/sphinx/builders/html.py", line 724, in index_page
self.indexer.feed(pagename, filename, title, doctree)
File "/home/dmitry/upstream/sphinx/sphinx/websupport/search/__init__.py", line 48, in feed
self.add_document(pagename, filename, title, doctree.astext())
TypeError: add_document() takes 4 positional arguments but 5 were given

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/home/dmitry/upstream/sphinx/tests/util.py", line 138, in skipper
return test(*args, **kwds)
File "/home/dmitry/upstream/sphinx/tests/util.py", line 138, in skipper
return test(*args, **kwds)
File "/home/dmitry/upstream/sphinx/tests/test_searchadapters.py", line 63, in test_xapian
search_adapter_helper('xapian')
File "/home/dmitry/upstream/sphinx/tests/test_searchadapters.py", line 31, in search_adapter_helper
support.build()
File "/home/dmitry/upstream/sphinx/sphinx/websupport/__init__.py", line 126, in build
app.build()
File "/home/dmitry/upstream/sphinx/sphinx/application.py", line 333, in build
self.builder.build_update()
File "/home/dmitry/upstream/sphinx/sphinx/builders/__init__.py", line 251, in build_update
'out of date' % len(to_build))
File "/home/dmitry/upstream/sphinx/sphinx/builders/__init__.py", line 322, in build
self.write(docnames, list(updated_docnames), method)
File "/home/dmitry/upstream/sphinx/sphinx/builders/__init__.py", line 360, in write
self._write_serial(sorted(docnames), warnings)
File "/home/dmitry/upstream/sphinx/sphinx/builders/__init__.py", line 367, in _write_serial
self.write_doc_serialized(docname, doctree)
File "/home/dmitry/upstream/sphinx/sphinx/builders/websupport.py", line 79, in write_doc_serialized
self.index_page(docname, doctree, title)
File "/home/dmitry/upstream/sphinx/sphinx/builders/html.py", line 727, in index_page
self.indexer.feed(pagename, title, doctree)
TypeError: feed() missing 1 required positional argument: 'doctree'

# Fixed code
def add_document(self, pagename, filename, title, text):
    self.database.begin_transaction()
    # sphinx_page_path is used to easily retrieve documents by path.
    sphinx_page_path = '"sphinxpagepath%s"' % pagename.replace("/", "_")
    # Delete the old document if it exists.
    self.database.delete_document(sphinx_page_path)

    doc = xapian.Document()
    doc.set_data(text)
    doc.add_value(self.DOC_PATH, pagename)
    doc.add_value(self.DOC_TITLE, title)
    self.indexer.set_document(doc)
    self.indexer.index_text(text)
    doc.add_term(sphinx_page_path)
    for word in text.split():
        doc.add_posting(word, 1)
    self.database.add_document(doc)
    self.database.commit_transaction()