diff --git a/core/modules/node/src/Tests/NodeCreationTest.php b/core/modules/node/src/Tests/NodeCreationTest.php
index 96ee49a..3a14650 100644
--- a/core/modules/node/src/Tests/NodeCreationTest.php
+++ b/core/modules/node/src/Tests/NodeCreationTest.php
@@ -192,7 +192,15 @@ function testNodeAddWithoutContentTypes () {
    * @return array
    */
   protected static function getWatchdogIdsForTestExceptionRollback() {
-    return db_query("SELECT wid FROM {watchdog} WHERE variables LIKE '%Test exception for rollback.%'")->fetchAll();
+    $matches = array();
+    $query = db_query("SELECT wid, variables FROM {watchdog}");
+    foreach ($query as $row) {
+      $variables = (array) unserialize($row->variables);
+      if (isset($variables['!message']) && $variables['!message'] === 'Test exception for rollback.') {
+        $matches[] = $row->wid;
+      }
+    }
+    return $matches;
   }
 
   /**
