Bug 478035 - Remove the now unnecessary code that attempts to fix a missing places root. r?mak
MozReview-Commit-ID: LP3O1JX9V0d
--- a/toolkit/components/places/PlacesDBUtils.jsm
+++ b/toolkit/components/places/PlacesDBUtils.jsm
@@ -704,51 +704,16 @@ var PlacesDBUtils = {
SELECT MAX(visit_date) FROM moz_historyvisits
WHERE place_id = fk
), STRFTIME('%s', 'now', 'localtime', 'utc') * 1000000)
WHERE dateAdded IS NULL OR
lastModified IS NULL`,
},
];
- // Check bookmarks roots
- // Bug 477739 shows a case where the root could be wrongly removed
- // due to an endianness issue. We try to fix broken roots here.
- let db = await PlacesUtils.promiseDBConnection();
- let rows = await db.execute(
- `SELECT id FROM moz_bookmarks WHERE id = :root`,
- { root: PlacesUtils.placesRootId });
- if (rows.length === 0) {
- // Note: these must be unshifted in reverse order.
- // Reparent other roots as children of the Places root.
- cleanupStatements.unshift({
- query:
- `UPDATE moz_bookmarks SET parent = :places_root WHERE guid IN
- ( :menuGuid, :toolbarGuid, :unfiledGuid, :tagsGuid )`,
- params: {
- places_root: PlacesUtils.placesRootId,
- menuGuid: PlacesUtils.bookmarks.menuGuid,
- toolbarGuid: PlacesUtils.bookmarks.toolbarGuid,
- unfiledGuid: PlacesUtils.bookmarks.unfiledGuid,
- tagsGuid: PlacesUtils.bookmarks.tagsGuid,
- }
- });
- // Try to recreate the root.
- cleanupStatements.unshift({
- query:
- `INSERT INTO moz_bookmarks (id, type, fk, parent, position, title, guid)
- VALUES (:places_root, 2, NULL, 0, 0, :title, :guid)`,
- params: {
- places_root: PlacesUtils.placesRootId,
- title: "",
- guid: PlacesUtils.bookmarks.rootGuid,
- }
- });
- }
-
// Create triggers for updating Sync metadata. The "sync change" trigger
// bumps the parent's change counter when we update a GUID or move an item
// to a different folder, since Sync stores the list of child GUIDs on the
// parent. The "sync tombstone" trigger inserts tombstones for deleted
// synced bookmarks.
cleanupStatements.unshift({
query:
`CREATE TEMP TRIGGER IF NOT EXISTS moz_bm_sync_change_temp_trigger
--- a/toolkit/components/places/tests/unit/test_preventive_maintenance.js
+++ b/toolkit/components/places/tests/unit/test_preventive_maintenance.js
@@ -341,44 +341,16 @@ tests.push({
// Check that an annotation to a nonexistent page has been removed
stmt = mDBConn.createStatement("SELECT id FROM moz_annos WHERE place_id = 1337");
Assert.ok(!stmt.executeStep());
stmt.finalize();
}
});
// ------------------------------------------------------------------------------
-tests.push({
- name: "C.1",
- desc: "fix missing Places root",
-
- setup() {
- // Sanity check: ensure that roots are intact.
- Assert.equal(bs.getFolderIdForItem(bs.placesRoot), 0);
- Assert.equal(bs.getFolderIdForItem(bs.bookmarksMenuFolder), bs.placesRoot);
- Assert.equal(bs.getFolderIdForItem(bs.tagsFolder), bs.placesRoot);
- Assert.equal(bs.getFolderIdForItem(bs.unfiledBookmarksFolder), bs.placesRoot);
- Assert.equal(bs.getFolderIdForItem(bs.toolbarFolder), bs.placesRoot);
-
- // Remove the root.
- mDBConn.executeSimpleSQL("DELETE FROM moz_bookmarks WHERE parent = 0");
- let stmt = mDBConn.createStatement("SELECT id FROM moz_bookmarks WHERE parent = 0");
- Assert.ok(!stmt.executeStep());
- stmt.finalize();
- },
-
- check() {
- // Ensure the roots have been correctly restored.
- Assert.equal(bs.getFolderIdForItem(bs.placesRoot), 0);
- Assert.equal(bs.getFolderIdForItem(bs.bookmarksMenuFolder), bs.placesRoot);
- Assert.equal(bs.getFolderIdForItem(bs.tagsFolder), bs.placesRoot);
- Assert.equal(bs.getFolderIdForItem(bs.unfiledBookmarksFolder), bs.placesRoot);
- Assert.equal(bs.getFolderIdForItem(bs.toolbarFolder), bs.placesRoot);
- }
-});
tests.push({
name: "C.1",
desc: "fix invalid parents for Places folders",
setup() {
// Reparent the roots to something invalid.
mDBConn.executeSimpleSQL(`