HomePhabricator

Probably fix Diviner atom collisions
Partially Audited65cdfa292f6d

Description

Probably fix Diviner atom collisions

Ref T8618. I think this was just typoed in D13070.

Immediate issue is that we're looking for symbols with the book name as a "phid".

Auditors: joshuaspence

Details

Auditors
joshuaspence
Group Auditors
Cowboy Commits
Provenance
epriestleyAuthored on
epriestleyPushed on Jun 19 2015, 4:00 PM
Parents
rP40851e5b2529: Adds Remarkup Rendering to Calendar Events' Descriptions.
Branches
Unknown
Tags
Unknown
Tasks
T8618: Symbol collision in Diviner publisher

Event Timeline

Hmm, how does this help prevent atom collisions?

The code roughly does this:

$old_atoms = load_existing_atoms_from_db();
foreach ($atoms_being_published as $atom) {
  if ($atom is not one of $old_atoms) {
    $atom->save();
  }
}

Prior to this patch, we miss the existing atom when loading, so $old_atoms always comes back empty (the query builds like ... WHERE bookPHID = "phabdev" ..., which no rows match, because that isn't a PHID).

Since we fail to load the existing atom, the check to see if the atom we're publishing is being updated or created always decides to create the atom.

Then, when we save it, the atom's hash collides with the existing hash in the database, because there really is an existing atom, we just failed to load it earlier.