Bug 478035 - Remove the now unnecessary code that attempts to fix a missing places root. r=mak
authorMark Banner <standard8@mozilla.com>
Thu, 19 Apr 2018 11:17:36 +0100
changeset 468221 e726894fdd13ddb380001a627c3b8df2cefa283a
parent 468220 fe5121c793e4923e45bd622cf92c8687c001b0ff
child 468222 8a24709c044b029aca91b7048bea89a734f537cf
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs478035
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 478035 - Remove the now unnecessary code that attempts to fix a missing places root. r=mak MozReview-Commit-ID: LP3O1JX9V0d
toolkit/components/places/PlacesDBUtils.jsm
toolkit/components/places/tests/unit/test_preventive_maintenance.js
--- 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(`