Jordi Boggiano 13 лет назад
Родитель
Сommit
21ae387adc

+ 2 - 2
src/Packagist/WebBundle/Controller/WebController.php

@@ -97,9 +97,9 @@ class WebController extends Controller
                     $em->persist($package);
                     $em->flush();
 
-                    $this->get('session')->setFlash('success', $package->getName().' has been added to the package list, the repository will be parsed for releases in a bit.');
+                    $this->get('session')->setFlash('success', $package->getName().' has been added to the package list, the repository will be parsed for releases soon.');
 
-                    return new RedirectResponse($this->generateUrl('home'));
+                    return new RedirectResponse($this->generateUrl('view_package', array('name' => $package->getName())));
                 } catch (\Exception $e) {
                     $this->get('logger')->crit($e->getMessage(), array('exception', $e));
                     $this->get('session')->setFlash('error', $package->getName().' could not be saved.');

+ 7 - 5
src/Packagist/WebBundle/Entity/Package.php

@@ -150,11 +150,13 @@ class Package
 
     public function isPackageUnique(ExecutionContext $context)
     {
-        if ($this->entityRepository->findOneByName($this->name)) {
-            $propertyPath = $context->getPropertyPath() . '.repository';
-            $context->setPropertyPath($propertyPath);
-            $context->addViolation('A package with the name '.$this->name.' already exists.', array(), null);
-        }
+        try {
+            if ($this->entityRepository->findOneByName($this->name)) {
+                $propertyPath = $context->getPropertyPath() . '.repository';
+                $context->setPropertyPath($propertyPath);
+                $context->addViolation('A package with the name '.$this->name.' already exists.', array(), null);
+            }
+        } catch (\Doctrine\ORM\NoResultException $e) {}
     }
 
     /**