jkovalsky commented on code in PR #72:
URL: https://github.com/apache/netbeans-tools/pull/72#discussion_r1965831265


##########
pp3/module/Application/src/Application/Controller/VerificationController.php:
##########
@@ -226,25 +250,62 @@ public function createAction() {
                 'action' => 'list'
             ));
         }
-        // create verification
-        $verification = new Verification();
-        $verification->setStatus(Verification::STATUS_REQUESTED);
-        $verification->setCreatedAt(new \DateTime('now'));
-        $verification->setPluginVersionId($nbvPvId);
-        $this->_verificationRepository->persist($verification);
-        // join it to nbVersionPluginVersion
-        $nbVersionPluginVersion->setVerification($verification);
-        
$this->_nbVersionPluginVersionRepository->persist($nbVersionPluginVersion);
-        $verification->setNbVersionPluginVersion($nbVersionPluginVersion);
-        // generate requests for all verifiers
-        $verifiers = $this->_userRepository->findVerifier();
-        $verification->createRequests($verifiers, $plugin);
-        $this->_verificationRepository->persist($verification);
-        foreach($verification->getVerificationRequests() as $req) {
-            $req->sendVerificationMail($plugin);
+
+        $existingVerification = null;
+        
foreach($nbVersionPluginVersion->getPluginVersion()->getNbVersionsPluginVersions()
 as $nvpv) {
+            if($nvpv->getVerification() != null && 
$nvpv->getVerification()->getStatus() == Verification::STATUS_GO) {
+                $existingVerification = $nvpv->getVerification();
+            }
+        }
+
+        if ($existingVerification == null) {
+            // create verification
+            $verification = new Verification();
+            $verification->setStatus(Verification::STATUS_REQUESTED);
+            $verification->setCreatedAt(new \DateTime('now'));
+            $verification->setPluginVersionId($nbvPvId);
+            $this->_verificationRepository->persist($verification);
+            // join it to nbVersionPluginVersion
+            $nbVersionPluginVersion->setVerification($verification);
+            
$this->_nbVersionPluginVersionRepository->persist($nbVersionPluginVersion);
+            $verification->setNbVersionPluginVersion($nbVersionPluginVersion);
+            // generate requests for all verifiers
+            $verifiers = $this->_userRepository->findVerifier();
+            $verification->createRequests($verifiers, $plugin);
+            $this->_verificationRepository->persist($verification);
+            foreach ($verification->getVerificationRequests() as $req) {
+                $req->sendVerificationMail($plugin);
+            }
+            
$this->flashMessenger()->setNamespace('success')->addMessage('Verification 
Requested.');
+        } else {
+            // Create a copy of the existing verification
+            $verification = new Verification();
+            $verification->setStatus($existingVerification->getStatus());
+            $verification->setCreatedAt($existingVerification->getCreatedAt());
+            $verification->setPluginVersionId($nbvPvId);
+            $this->_verificationRepository->persist($verification);
+            // join it to nbVersionPluginVersion
+            $nbVersionPluginVersion->setVerification($verification);

Review Comment:
   I am afraid that we need to check the version better, else this might result 
in two different plugin versions verified for one NetBeans version.
   
   Consider 3.0 verified for NB 11.2 and 3.1 verified for NB 11.3. Then you 
declare that 3.0 also works with NB 11.3 and make a mistake, forget about 3.1 
and request verification of 3.0 with NB 11.3. Your request is auto-approved and 
catalog for NB 11.3 now contains both 3.0 and 3.1 versions of your plugin.
   
   Can you improve this code to prevent this from happening?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to