1

执行此行时出现该错误:

if( 'POST' === $request->getMethod( ) ) {

在 $request->getMethod( ) 上做一个 var 转储给了我:string(3) "GET"很好。

所以我不明白为什么我得到一个 preg macth 错误。更多细节:

1 error
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest". 
INFO - Matched route "done_punctis_brand_apicodes_edit" (parameters: "_controller": "Done\PunctisBundle\Controller\BrandController::apiEditAction", "id": "1", "apicode": "3", "_route": "done_punctis_brand_apicodes_edit") 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest". 
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest". 
DEBUG - Read SecurityContext from the session 
DEBUG - Reloading user from user provider. 
DEBUG - SET NAMES UTF8 
DEBUG - SELECT t0.id AS id1, t0.username AS username2, t0.referer AS referer3, t0.salt AS salt4, t0.password AS password5, t0.verified AS verified6, t0.score AS score7, t0.avatar AS avatar8, t0.registration AS registration9, t0.role AS role10, t0.info_id AS info_id11 FROM user t0 WHERE t0.id = ? 
DEBUG - Username "--------------" was reloaded from user provider. 
DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\AsseticBundle\EventListener\RequestListener::onKernelRequest". 
DEBUG - Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelController". 
DEBUG - Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController". 
DEBUG - SELECT t0.id AS id1, t0.name AS name2, t0.avatar AS avatar3, t0.description AS description4, t0.url AS url5, t0.address AS address6, t0.registration AS registration7, t0.verified AS verified8, t0.maxpoints AS maxpoints9, t0.explimitsocial AS explimitsocial10, t0.explimitpoll AS explimitpoll11, t0.explimitapi AS explimitapi12, t0.credit AS credit13, t0.world_id AS world_id14 FROM brand t0 WHERE t0.id = ? LIMIT 1 
DEBUG - SELECT t0.id AS id1, t0.username AS username2, t0.referer AS referer3, t0.salt AS salt4, t0.password AS password5, t0.verified AS verified6, t0.score AS score7, t0.avatar AS avatar8, t0.registration AS registration9, t0.role AS role10, t0.info_id AS info_id11 FROM user t0 INNER JOIN user_brand_administered ON t0.id = user_brand_administered.user_id WHERE user_brand_administered.brand_id = ? 
DEBUG - SELECT t0.id AS id1, t0.title AS title2, t0.description AS description3, t0.actionid AS actionid4, t0.secretid AS secretid5, t0.brand AS brand6, t0.points AS points7, t0.premium AS premium8, t0.image AS image9, t0.ppa AS ppa10 FROM apicodes t0 WHERE t0.brand = ? AND t0.id = ? LIMIT 1 
DEBUG - Notified event "kernel.exception" to listener "Symfony\Component\Security\Http\Firewall\ExceptionListener::onKernelException". 
DEBUG - Notified event "kernel.exception" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelException". 
DEBUG - Notified event "kernel.exception" to listener "Symfony\Component\HttpKernel\EventListener\ExceptionListener::onKernelException". 
CRITICAL - ErrorException: Warning: preg_match() expects parameter 2 to be string, object given in /var/www/vhosts/mysite.com/httpdocs/app/cache/dev/classes.php line 1129 (uncaught exception) at /var/www/vhosts/mysite.com/httpdocs/app/cache/dev/classes.php line 1129 

堆栈跟踪

in kernel.root_dir/cache/dev/classes.php at line 1129   
            if ('variable' === $token[0]) {
                if (false === $optional || !array_key_exists($token[3], $defaults) || (isset($parameters[$token[3]]) && (string) $parameters[$token[3]] != (string) $defaults[$token[3]])) {
                    if (!$isEmpty = in_array($tparams[$token[3]], array(null, '', false), true)) {
                                                if ($tparams[$token[3]] && !preg_match('#^'.$token[2].'$#', $tparams[$token[3]])) {
                            $message = sprintf('Parameter "%s" for route "%s" must match "%s" ("%s" given).', $token[3], $name, $token[2], $tparams[$token[3]]);
                            if ($this->strictRequirements) {
                                throw new InvalidParameterException($message);
4

0 回答 0