@@ -78,13 +78,7 @@ public function findOrCreateComponent($model, $identifier = null, $flush = true)
7878 {
7979 $ resolvedComponentData = $ this ->resolveModelAndIdentifier ($ model , $ identifier );
8080
81- $ component = $ this ->getComponentRepository ()
82- ->createQueryBuilder ('c ' )
83- ->where ('c.hash = :hash ' )
84- ->setParameter ('hash ' , $ resolvedComponentData ->getHash ())
85- ->getQuery ()
86- ->getOneOrNullResult ()
87- ;
81+ $ component = $ this ->findComponentWithHash ($ resolvedComponentData ->getHash ());
8882
8983 if ($ component ) {
9084 $ component ->setData ($ resolvedComponentData ->getData ());
@@ -100,13 +94,23 @@ public function findOrCreateComponent($model, $identifier = null, $flush = true)
10094 */
10195 public function findComponentWithHash ($ hash )
10296 {
97+ $ component = $ this ->getComponentRepository ()
98+ ->createQueryBuilder ('c ' )
99+ ->where ('c.hashMigrated = :hash ' )
100+ ->setParameter ('hash ' , $ hash )
101+ ->getQuery ()
102+ ->getOneOrNullResult ();
103+
104+ if (null !== $ component ) {
105+ return $ component ;
106+ }
107+
103108 return $ this ->getComponentRepository ()
104109 ->createQueryBuilder ('c ' )
105110 ->where ('c.hash = :hash ' )
106111 ->setParameter ('hash ' , $ hash )
107112 ->getQuery ()
108- ->getOneOrNullResult ()
109- ;
113+ ->getOneOrNullResult ();
110114 }
111115
112116 /**
@@ -120,12 +124,16 @@ public function findComponents(array $hashes)
120124
121125 $ qb = $ this ->getComponentRepository ()->createQueryBuilder ('c ' );
122126
123- return $ qb ->where (
124- $ qb ->expr ()->in ('c.hash ' , $ hashes )
125- )
127+ $ components = $ qb ->where ($ qb ->expr ()->in ('c.hashMigrated ' , $ hashes ))
126128 ->getQuery ()
127- ->getResult ()
128- ;
129+ ->getResult ();
130+ if (!empty ($ components )) {
131+ return $ components ;
132+ }
133+
134+ return $ qb ->where ($ qb ->expr ()->in ('c.hash ' , $ hashes ))
135+ ->getQuery ()
136+ ->getResult ();
129137 }
130138
131139 protected function getQueryBuilderForSubject (ComponentInterface $ subject )
0 commit comments