Hello,

I'm not sure if I should be posting this here or on the Doctrine mailing 
list since it's related to both Symfony2 and Doctrine 2.

Anyway, I'm having a *really* weird issue when persisting data to my 
database. Data gets posted to a specific URL after a user completes a 
transaction and I have an action that then dispatches an event to add this 
subscription data to my database. The problem is that whenever the payment 
processor posts data to this URL, the data is never persisted. If I manually 
post data to this URL to simulate the payment processor (same variable 
names, values, etc.), everything works fine. I've verified that the data is 
being sent from the payment processor correctly and that my event is being 
dispatched correctly. But as soon as I try to persist the data, it just 
completely fails. I haven't been able to catch any exceptions or error 
messages.

What makes this difficult is I don't have control over the payment 
processor's scripts and I'm unable to see which exception is actually being 
thrown (if any). This data is also posted in the background while it 
redirects the user to an intermediary URL with subscription information. 
I've repeatedly checked database permissions, entity 
names/methods/properties, cleared my cache more times than I can count, and 
I've even recreated the database from scratch multiple times. None of these 
things have done the trick and in every case, the problem remains the same. 
Data is just never persisted unless I use my own script to post data to the 
action that handles this. There aren't any error messages in either of my 
log files and it doesn't seem to matter which environment I use. The problem 
is always the same.

I thought that this might be a security issue of some sort but I'm not 
entirely sure what to look at. It seems like the solution to this should be 
incredibly obvious.

Here's my relevant code:

    public function approvedAction()
    {
        $request      = $this->container->get('request');
        $subscription = null;
        $user         = null;
        
        if ($request->getMethod() == 'POST')
        {
            $subscription = 
$this->subscriptionManager->createFromPost($request->request);
            $subscription->setReasonForDecline(null);
            $subscription->setReasonForDeclineCode(null);

            $signup = $this->subscriptionManager->createSignup();
            $signup->setId($request->request->get('sid'));
            $signup->setSubscriptionId($subscription->getId());

            $this->dispatcher->dispatch(Events::onSaveSubscription, new 
SaveSubscriptionEvent($subscription, $signup));

            return new Response('Subscription added', 302);
        }
        else
        {
            if ($this->session->has('signup_id'))
            {
                $signupId = $this->session->get('signup_id');
                $user     = $this->security->getToken()->getUser();
                $signup   = $this->subscriptionManager->createSignup();
                $signup->setId($signupId);
                
                $subscription = 
$this->subscriptionManager->findBySignupId($signupId);
                $this->subscriptionManager->removeSignup($signup);
                $this->session->remove('signup_id');
            }

            if (!($subscription instanceof SubscriptionInterface))
            {
                throw new RuntimeException('Unable to find sign-up ID');
            }

            return 
$this->container->get('templating')->renderResponse('LWProdCCBillBundle:Billing:subscription_approved.html.twig',
 
array(
                'subscription' => $subscription,
                'user'         => $user
            ));
        }
    }

    public function onSaveSubscription(SaveSubscriptionEvent $event)
    {
        $subscription = $event->getSubscription();
        $signup       = $event->getSignup();

        $subscription->setUserId(-1);
        $subscription->setActive(false);
        $subscription->setExpired(false);

        $this->subscriptionManager->saveSubscription($subscription, 
$signup);
    }

    public function saveSubscription(SubscriptionInterface $subscription, 
SignupInterface $signup, $flush = true)
    {
        $this->em->persist($subscription);
        $this->em->persist($signup);
        
        if ($flush)
        {
            $this->em->flush();
        }
    }

As you can see, it's incredibly simple and relatively straightforward. Help? 
Thanks!

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to