Commit graph

3 commits

Author SHA1 Message Date
Tim Starling
a7df0148d8 LinksTable: Cast all array keys to string
When fetching a key from an array, PHP converts numeric strings to
integers. This led to an incorrect category update query.

So:

* In LinksTable subclasses, cast all string-like array keys to string.
* Add a unit test which confirms that no integers leak into link IDs.
* Add a fully integrated regression test for T301433.

The integration test and 7 of the link ID cases are confirmed to fail
if Amir's patch is reverted.

Bug: T301433
Change-Id: I8d19443607121b3efcafb82096bcff18c41035df
2022-02-14 15:56:34 +11:00
Tim Starling
c11954c036 Fix page_props DELETE/INSERT on null edit
* In PagePropsTable, compare values after converting to string. In the
  old code this was implicitly done by array_diff_assoc().
* Also convert to string before inserting, since
  ParserOutput::setPageProperty() is documented as allowing null, but
  the field is not nullable, so the query failed.
* Add a regression test which confirms that no write queries are done on
  the second invocation of LinksUpdate.

Bug: T299662
Change-Id: I3f7d5800bf27a47cb57be80bdba13792fe3caae6
2022-01-31 15:59:28 +11:00
Tim Starling
d3b2b80067 LinksUpdate refactor
* In LinksUpdate, put each table in its own class, so that the
  special code for each table has a more elegant place to go.
* Use generators to abstract and flatten out the underlying ParserOutput
  data structures, without requiring the data to be copied. This allows
  the incremental logic which was previously duplicated for each table,
  i.e. computing insertions and deletions from the old and new state,
  to be factored out. The per-table batch classes act as container
  abstractions for the underlying data.

Bug: T263437
Depends-On: I472f4a023969bfde6298eb56112c16d2ae842199
Change-Id: Id40be19a8caa7b4669911927964cfd6755c25238
2022-01-04 15:35:57 +11:00