diff --git a/src/Utils/DOMDataUtils.php b/src/Utils/DOMDataUtils.php
index <HASH>..<HASH> 100644
--- a/src/Utils/DOMDataUtils.php
+++ b/src/Utils/DOMDataUtils.php
@@ -375,11 +375,11 @@ class DOMDataUtils {
 	 * @param stdClass $data data
 	 */
 	public static function storeInPageBundle( DOMElement $node, Env $env, stdClass $data ): void {
-		$uid = $node->getAttribute( 'id' );
+		$uid = $node->getAttribute( 'id' ) ?? '';
 		$document = $node->ownerDocument;
 		$pb = self::getPageBundle( $document );
 		$docDp = $pb->parsoid;
-		$origId = $uid;
+		$origId = $uid ?: null;
 		if ( array_key_exists( $uid, $docDp->ids ) ) {
 			$uid = null;
 			// FIXME: Protect mw ids while tokenizing to avoid false positives.
Match php storeInPageBundle with js

This prevents shadowing id when none was present, fixing some roundtrip
diffs.

Bug: T<I>
Change-Id: Ia8d<I>e<I>b<I>af0d<I>e<I>bb<I>e<I>ab