由于我从symfony 2.0更新到2.1,我无法通过Facebook登录。Symfony将我重定向到我的登录页面并显示此错误:
注意:供应商\doctrine\dbal\lib\Doctrine\DBAL\Statement.php第 103 行中的数组到字符串的转换
您可以在下面看到我的日志文件:
[2012-11-19 09:17:48] event.DEBUG: Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerProfilerListener::onKernelRequest". [] []
[2012-11-19 09:17:48] event.DEBUG: Notified event "kernel.request" to listener "SymfonyBundleFrameworkBundleEventListenerSessionListener::onKernelRequest". [] []
[2012-11-19 09:17:48] event.DEBUG: Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerRouterListener::onKernelRequest". [] []
[2012-11-19 09:17:49] request.INFO: Matched route "fos_facebook_security_check" (parameters: "_controller": "StrictUserBundleControllerLoginController::loginFbAction", "_locale": "pl", "_route": "fos_facebook_security_check") [] []
[2012-11-19 09:17:49] event.DEBUG: Notified event "kernel.request" to listener "SymfonyComponentHttpKernelEventListenerLocaleListener::onKernelRequest". [] []
[2012-11-19 09:17:49] event.DEBUG: Notified event "kernel.request" to listener "SymfonyComponentSecurityHttpFirewall::onKernelRequest". [] []
[2012-11-19 09:17:49] doctrine.DEBUG: SELECT t0.username AS username1, t0.username_canonical AS username_canonical2, t0.email AS email3, t0.email_canonical AS email_canonical4, t0.enabled AS enabled5, t0.salt AS salt6, t0.password AS password7, t0.last_login AS last_login8, t0.locked AS locked9, t0.expired AS expired10, t0.expires_at AS expires_at11, t0.confirmation_token AS confirmation_token12, t0.password_requested_at AS password_requested_at13, t0.roles AS roles14, t0.credentials_expired AS credentials_expired15, t0.credentials_expire_at AS credentials_expire_at16, t0.id AS id17, t0.facebookId AS facebookId18, t0.name AS name19, t0.text AS text20, t0.location AS location21, t0.picturePath AS picturePath22, t0.www AS www23, t0.language AS language24, t0.facebookWww AS facebookWww25, t0.male AS male26, t0.reviewsCount AS reviewsCount27, t0.postsCount AS postsCount28, t0.emailEnabled AS emailEnabled29, t0.messagesEnabled AS messagesEnabled30, t0.wwwNofollow AS wwwNofollow31, t0.facebookWwwNofollow AS facebookWwwNofollow32, t0.yearBirth AS yearBirth33, t0.lastModified AS lastModified34, t0.picture_id AS picture_id35 FROM fos_user t0 WHERE t0.facebookId = ? LIMIT 1 ["000_facebook_id_here_0000"] []
[2012-11-19 09:17:51] doctrine.DEBUG: SELECT t0.username AS username1, t0.username_canonical AS username_canonical2, t0.email AS email3, t0.email_canonical AS email_canonical4, t0.enabled AS enabled5, t0.salt AS salt6, t0.password AS password7, t0.last_login AS last_login8, t0.locked AS locked9, t0.expired AS expired10, t0.expires_at AS expires_at11, t0.confirmation_token AS confirmation_token12, t0.password_requested_at AS password_requested_at13, t0.roles AS roles14, t0.credentials_expired AS credentials_expired15, t0.credentials_expire_at AS credentials_expire_at16, t0.id AS id17, t0.facebookId AS facebookId18, t0.name AS name19, t0.text AS text20, t0.location AS location21, t0.picturePath AS picturePath22, t0.www AS www23, t0.language AS language24, t0.facebookWww AS facebookWww25, t0.male AS male26, t0.reviewsCount AS reviewsCount27, t0.postsCount AS postsCount28, t0.emailEnabled AS emailEnabled29, t0.messagesEnabled AS messagesEnabled30, t0.wwwNofollow AS wwwNofollow31, t0.facebookWwwNofollow AS facebookWwwNofollow32, t0.yearBirth AS yearBirth33, t0.lastModified AS lastModified34, t0.picture_id AS picture_id35 FROM fos_user t0 WHERE t0.email = ? LIMIT 1 ["my_email_address_here"] []
[2012-11-19 09:17:52] doctrine.DEBUG: "START TRANSACTION" [] []
[2012-11-19 09:17:52] doctrine.DEBUG: "ROLLBACK" [] []
[2012-11-19 09:17:52] security.INFO: Authentication request failed: Notice: Array to string conversion in vendordoctrinedballibDoctrineDBALStatement.php line 103 [] []
[2012-11-19 09:17:52] security.DEBUG: Redirecting to fos_user_security_login [] []
上面的两个sql SELECT查询不会导致任何错误,也不会返回任何结果(在phpmyadmin中检查)。
Composer.json:
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.2.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.0.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.1.*",
"symfony/swiftmailer-bundle": "2.1.*",
"symfony/monolog-bundle": "2.1.*",
"sensio/distribution-bundle": "2.2.*",
"sensio/framework-extra-bundle": "2.2.*",
"sensio/generator-bundle": "2.2.*",
"jms/security-extra-bundle": "1.3.*",
"jms/di-extra-bundle": "1.2.*",
"facebook/php-sdk": "dev-master",
"friendsofsymfony/user-bundle": "*",
"friendsofsymfony/facebook-bundle": "dev-master",
"besimple/i18n-routing-bundle": "dev-master",
"gregwar/captcha-bundle": "dev-master"
},
老实说,我不知道可能出了什么问题以及如何找到错误。如果您需要一些额外的数据/配置文件,请发表评论。
我已经找到了解决方案。问题是Facebook不会返回picture
字符串属性以传递给实体中的setFBData
User
。
picture
包含图像 url 的字符串属性。现在它包含:
字符串;如果为应用启用了"2012 年 10 月重大更改"迁移设置,则此字段将是包含 url 和is_silhouette字段的对象;如果用户尚未上传个人资料图片,则is_silhouette为 true
我的设置FB数据如下所示:
public function setFBData($fbdata)
{
...
if (isset($fbdata['picture']))
{
$this->setPicturePath($fbdata['picture']);
}
}
如您所见,它正在尝试将对象/数组设置为字符串字段。