In July 2007 (9382bc7a858cf5c6a41794aba51f437efbf093c7), I modified Database::query() and related functions to return a ResultWrapper instead of a raw resource from the database driver. Some odd architectural decisions remain, as a result of backwards compatibility with the previous situation.
Proposals:
- IDatabase::fetchObject() etc. should be deprecated. Callers should use the methods in IResultWrapper instead.
- Some callers call IDatabase::numRows() on a boolean (the result of a write query). They can just stop doing that.
- Fix vague or incorrect parameter typing, e.g. IDatabase::fetchObject() cannot actually take a stdClass.
- ResultWrapper should have DBMS-dependent subclasses and the subclass should simply implement the relevant operation rather than delegating to IDatabase. ResultWrapper would become abstract.
- ResultWrapper::unwrap() should be removed.
- If the ResultWrapper subclass needs public helpers in the IDatabase subclass, the helpers should be marked internal.
Motivation: for T285917 I am trying to figure out the current position in a ResultWrapper so that I can concurrently iterate through an array. But it is surprisingly awkward. Some pagers call IDatabase::fetchObject() directly, so IResultWrapper doesn't have a simple way to keep track of its position. Some pagers reimplement the outer loop over the result array, so IndexPager/TablePager can't easily know the position either. It would simplify things if there was a single place where DB results were modified.
Todo:
- Hard-deprecate {DatabasePostgres,DatabaseMysqlBase}::fieldType() in 1.37.
- Hard-deprecate ResultWrapper::unwrap() in 1.37.
- Hard-deprecate IDatabase::numRows(), IDatabase::numFields(), IDatabase::fieldName(), IDatabase::freeResult(), and IDatabase::dataSeek() (deprecated in 1.37, hard-deprecated or removed in 1.38)
- Hard-deprecate IDatabase::fetchObject() and IDatabase::fetchRow() (deprecated in 1.37, hard-deprecated in in 1.38).
- Remove {DatabasePostgres,DatabaseMysqlBase}::fieldType() in 1.38.
- Remove ResultWrapper::unwrap() in 1.38
- Remove IDatabase::numFields(), IDatabase::fieldName(), IDatabase::dataSeek() in 1.38 (unused)
- Remove IDatabase::numRows(), IDatabase::freeResult(), IDatabase::fetchObject() and IDatabase::fetchRow() in 1.39.
Removals:
- IDatabase::numRows()
- IDatabase::numFields()
- IDatabase::fieldName()
- IDatabase::freeResult()
- IDatabase::dataSeek()
- IDatabase::fetchObject()
- IDatabase::fetchRow()