'Serialization of 'SimpleXMLElement' is not allowed' - hybridauth

I've changed around the path structure for HybridAuth quite a bit, all of the HybridAuth files are in a login directory.
require_once('login/Auth.php');
$auth = new Hybrid_Auth(self::$settings['auth']);
Where self::$settings['auth'] is this json file
{
"debug": 1,
"database": {
"driver": "mysql",
"host": "localhost",
"port": 3306,
"name": "ws_db",
"username": "root",
"password": "",
"charset": "utf8"
},
"auth": {
"base_url": "http://localhost/login/process",
"providers": {
"Twitter": {
"enabled": true
},
"Google": {
"enabled": true,
"keys": {
"id": "",
"secret": ""
}
},
"Facebook": {
"enabled": true,
"keys": {
"id": "",
"secret": ""
},
"trustForwarded": false
},
"Steam": {
"enabled": true
}
},
"debug_mode": true,
"debug_file": "auth.txt"
}
}
I have not yet acquired keys for the providers I intended to use (is that possibly why this is happening?). I tried to login with Steam to test that it was working since it was the only provider that didn't require me to get keys.
$_SESSION['user'] = $auth->authenticate('Steam');
I was correctly redirected to a Steam login page however upon clicking Login I received the above error.
Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in login\Auth.php:153 Stack trace: #0 login\Auth.php(39): Hybrid_Auth::initialize(Array) #1 index.php(83): Hybrid_Auth->__construct(Array) #2 index.php(6): Site::main() #3 {main} thrown in login\Auth.php on line 153
I thought it possibly had something to do with this line:
Hybrid_Logger::debug( "Hybrid_Auth initialize. dump used config: ", serialize( $config ) );
because that is the only line that I see serializing something but commenting that out didn't seem to work. Line 83 in my index.php is the initialization of Hybrid_Auth.
$auth = new Hybrid_Auth(self::$settings['auth']);
I can't seem to figure out what is going wrong with this though. Since that line of code is run when attempting to login and only causes a problem when returning from the Steam authorization page.
Here is the information that was output into auth.txt, I removed some information.
(
[message:protected] => Serialization of 'SimpleXMLElement' is not allowed
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => login\Storage.php
[line:protected] => 73
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => login\Storage.php
[line] => 73
[function] => serialize
[args] => Array
(
[0] => Hybrid_User Object
(
[providerId] => Steam
[timestamp] => 1431707732
[profile] => Hybrid_User_Profile Object
(
[identifier] => ***************
[webSiteURL] =>
[profileURL] => http://steamcommunity.com/id/******/
[photoURL] =>
[displayName] => Renari
[description] => <span>profile information was here</span>
[firstName] => SimpleXMLElement Object
(
[0] => SimpleXMLElement Object
(
)
)
[lastName] =>
[gender] =>
[language] =>
[age] =>
[birthDay] =>
[birthMonth] =>
[birthYear] =>
[email] =>
[emailVerified] =>
[phone] =>
[address] =>
[country] =>
[region] => location information was here
[city] =>
[zip] =>
)
)
)
)
[1] => Array
(
[file] => login\Providers\Steam.php
[line] => 37
[function] => set
[class] => Hybrid_Storage
[type] => ->
[args] => Array
(
[0] => hauth_session.Steam.user
[1] => Hybrid_User Object
(
[providerId] => Steam
[timestamp] => 1431707732
[profile] => Hybrid_User_Profile Object
(
[identifier] => ***************
[webSiteURL] =>
[profileURL] => http://steamcommunity.com/id/******/
[photoURL] =>
[displayName] => ******
[description] => <span>profile information was here</span>
[firstName] => SimpleXMLElement Object
(
[0] => SimpleXMLElement Object
(
)
)
[lastName] =>
[gender] =>
[language] =>
[age] =>
[birthDay] =>
[birthMonth] =>
[birthYear] =>
[email] =>
[emailVerified] =>
[phone] =>
[address] =>
[country] =>
[region] => location information was here
[city] =>
[zip] =>
)
)
)
)
[2] => Array
(
[file] => login\Endpoint.php
[line] => 182
[function] => loginFinish
[class] => Hybrid_Providers_Steam
[type] => ->
[args] => Array
(
)
)
[3] => Array
(
[file] => login\Endpoint.php
[line] => 55
[function] => processAuthDone
[class] => Hybrid_Endpoint
[type] => ->
[args] => Array
(
)
)
[4] => Array
(
[file] => login\Endpoint.php
[line] => 71
[function] => __construct
[class] => Hybrid_Endpoint
[type] => ->
[args] => Array
(
[0] =>
)
)
[5] => Array
(
[file] => index.php
[line] => 90
[function] => process
[class] => Hybrid_Endpoint
[type] => ::
[args] => Array
(
)
)
[6] => Array
(
[file] => index.php
[line] => 6
[function] => main
[class] => Site
[type] => ::
[args] => Array
(
)
)
)
[previous:Exception:private] =>
)

This was an issue with the Steam provider and was fixed in a commit you can download the fixed steam provider from the github repo.

Related

ZF2 - Allow an empty input file on submit

I have a form that allows a user to edit his information and upload an image. The image upload is optional but when I submit the form, I always have an error telling me that the image has not been uploaded.
Here is the partial fieldset code:
public function init() {
$this->add([
'name' => 'avatar',
'type' => 'file',
'attributes' => [
'id' => 'avatar',
'class' => 'input-file',
'accept' => 'image/*'
],
'options' => [
'label' => 'avatar',
]
]);
}
This fieldset implements InputFilterProviderInterface, so here is the code:
public function getInputFilterSpecification() {
return [
'avatar' => [
'type' => '\Zend\InputFilter\FileInput',
'allow_empty' => true,
'required' => false,
'validators' => [
[
'name' => 'FileExtension',
'options' => [
'extension' => ['jpg, jpeg, png'],
'message' => 'wrong_type_file'
]
],
[
'name' => 'FileSize',
'options' => [
'max' => '2MB',
'message' => 'file_too_large'
]
]
],
],
];
}
Despite the fact that this field is not required and allow_empty option is true, when I submit the form and debug the value, I still have validation that fails and this as my debug value:
'avatar' =>
array (size=5)
'name' => string '' (length=0)
'type' => string '' (length=0)
'tmp_name' => string '' (length=0)
'error' => int 4
'size' => int 0
Do you know how could I validate my form event when no file is downloaded?
Thanks in advance for your answers!
EDIT 1: Here are the messages returned by the form after submission:
'avatar' =>
array (size=2)
'fileExtensionNotFound' => string 'Extension d'image non admise (.jpg, .jpeg, .png seulement)'
'fileSizeNotFound' => string 'Le fichier est trop volumineux, 2097152 maximum.' (length=48)
EDIT 2: the action in the controller:
$prg = $this->fileprg($form);
if ($prg instanceof Response) {
return $prg;
} elseif (is_array($prg)) {
$data = $form->getData();
if ($form->isValid()) {
if ($data['person']['file']) {
// #TODO upload file
}
if (!$this->personMapper->updatePerson($data)) {
$this->flashMessenger()->addErrorMessage($this->translator()->translate('error_occurs_backup'));
} else {
$this->flashMessenger()->addSuccessMessage($this->translator()->translate('data_saved'));
}
} else {
// #TODO file error management
\var_dump('not valid');
\var_dump($form->getMessages());
}
}

Search list result null prevPageToken

I'm trying to get videos from my channel using search function. Response include only nextPageToken, but no prevPageToken. prevPageToken is null always, even if I'm listing other pages using nextPageToken. I use an access_token param from Google Oauth.
My request:
$searchResponse = $youtube->search->listSearch('snippet', array(
'forMine' => 'true',
'order' => 'date',
'pageToken' => $pageToken,
'type'=>'video',
'maxResults' => '10',
'q' => $searchQuery,
));
Result:
Google_Service_YouTube_SearchListResponse Object
(
[collection_key:protected] => items
[etag] => "XXX"
[eventId] =>
[itemsType:protected] => Google_Service_YouTube_SearchResult
[itemsDataType:protected] => array
[kind] => youtube#searchListResponse
[nextPageToken] => Cib3-ZrgSf____9uWHdEYVNIVnlOVQD_Af_-blh3RGFTSFZ5TlUAARAPIbmtEhE6-iWlOQAAAAC2H2UGSAFQAFoLCdIYcGeU2-YsEAJgyOjNygE=
[pageInfoType:protected] => Google_Service_YouTube_PageInfo
[pageInfoDataType:protected] =>
[prevPageToken] =>
[regionCode] =>
[tokenPaginationType:protected] => Google_Service_YouTube_TokenPagination
[tokenPaginationDataType:protected] =>
[visitorId] =>
[internal_gapi_mappings:protected] => Array
(
)
[modelData:protected] => Array
(
)
[processed:protected] => Array
(
)
[pageInfo] => Google_Service_YouTube_PageInfo Object
(
[resultsPerPage] => 5
[totalResults] => 55
[internal_gapi_mappings:protected] => Array
(
)
[modelData:protected] => Array
(
)
[processed:protected] => Array
(
)
)
Thank you for your ideas!
Petr
UPDATE
This problem is only if is set param forMine. But I need show only my videos...

Highcharts graph not shown in Yii2

I am getting array data from a function ReportsController::getStudentYearwiseAvgHeightsProvince() in the below format:
Array ( [0] => Array ( [name] => Baluchistan [data] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 ) ) [1] => Array ( [name] => KPK [data] => Array ( [0] => 56 [1] => 58 [2] => 58 [3] => 0 [4] => 0 [5] => 0 [6] => 60 ) ) [2] => Array ( [name] => Punjab [data] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 78 [4] => 90 [5] => 90 [6] => 0 ) ) [3] => Array ( [name] => Sindh [data] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 ) ) )
ReportsController::getStudentYearwiseAvgHeightsProvince() function is:
public function getStudentYearwiseAvgHeightsProvince() {
$result = Yii::$app->db->createCommand ( '
SELECT temp.name AS name,
GROUP_CONCAT(IFNULL(temp.height,0) order by year) AS data
FROM ( SELECT years.year AS year, p.name AS NAME, FLOOR(AVG(sd.height)) AS height
FROM (
SELECT DISTINCT year FROM student_detail ORDER BY year
) years
cross join province p
left join student_detail sd on years.year = sd.year and sd.province_id = p.id
GROUP BY years.year, p.name
ORDER BY years.year )
AS temp
GROUP BY name; ' )->queryAll ();
$i = 0;
foreach ($result as $innerArray) {
$result[$i]['data'] = explode(",", $result[$i]['data']);
//$result[$i]['name'] = $innerArray['name'];
$i++;
}
//$result = array_map(function($var){ return (int) $var['data']; }, $result); // extraction from 2 level associative arry to 1-d associative array
print_r ( $result );
return $result;
}
and I am setting highcharts component as follows:
echo Highcharts::widget([
'scripts' => [
'modules/exporting',
'themes/grid-light',
],
'options' => [
'title' => ['text' => 'Student Province-wise Yearly Avg Heights'],
'plotOptions' => [
'column' => [
'depth' => 25
]
],
'xAxis' => [
'categories' => ReportsController::getDistinctCols("student_detail", "year")
],
'yAxis' => [
'min' => 0,
'title' => ['text' => 'Avg Height']
],
'series' =>
ReportsController::getStudentYearwiseAvgHeightsProvince()
]
]);
No graph is generated :(
I fixed the graph not showing issue by just converting the STRING ARRAY to INTEGER ARRAY which is returned by EXPLODE in my function getStudentYearwiseAvgHeightsProvince()
by editing the code inside FOREACH LOOP as:
foreach ($result as $innerArray) {
$result[$i]['data'] = explode(",", $result[$i]['data']);
$temp = array();
foreach ($result[$i]['data'] AS $index => $value)
$temp[$index] = (int)$value;
$result[$i]['data'] = $temp;
$i++;
}

how to get value from wsdl returned data in PHP?

Below is the data I'm getting from wsdl response... I need to get the separate value for example how to get the firstname from this array...Please anyone help me...
GetReportResponse Object ( [GetReportResult] => MBPeopleSearchRs_Type Object ( [MsgRsHdr] => MsgRsHdr_Type Object ( [RqUID] => {4DB2AD23-228A-465F-938D-BE072CED61C4} [Status] => Status_Type Object ( [StatusCode] => 0 [ServerStatusCode] => [Severity] => Info [StatusDesc] => OK [AdditionalStatus] => ) ) [Subject] => Subject Object ( [RefNum] => [PersonInfo] => PersonInfo_Type Object ( [PersonName] => PersonName_Type Object ( [LastName] => JANARDHANAN [FirstName] => SENTHINBABU [FullName] => [MiddleName] => [TitlePrefix] => [NameSuffix] => [Nickname] => [LegalName] => [MaidenName] => [OfficialTitle] => [Source] => MB [EffDt] => 2013-05-24 ) [ContactInfo] => ContactInfo_Type Object ( [ContactPref] => [PhoneNum] => [ContactName] => [EmailAddr] => [URL] => [PostAddr] => PostAddr_Type Object ( [PreDirection] => [Addr2] => [PostDirection] => N [Addr3] => [StreetType] => AVE [Addr4] => [StreetName] => LEXINGTON [Apt] => APT 4203 [StreetNum] => 4150 [Addr1] => [City] => SAINT PAUL [StateProv] => MN [PostalCode] => 55126-6131 [County] => RAMSEY
I suggest using a framework for this. CXF is a good choice if you write Java.
http://cxf.apache.org/
edit: since you work with php, take a look here: PHP SOAP client Tutorial/Recommendation?

composer autoload not working on production server

I've setup a project localy using composer to autoload my vendors and modules.
This is done on a Windows XP machine running Nginx.
When I sync everything to my production server, running LAMP, the autoloader stops working and every class i call its not found.
Since this is a shared host i cant run composer.phar update to try to refresh the classmap namespace.
Anyone knows what might be happening?
+INFO:
<?php
// autoload_namespaces.php generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname(dirname($vendorDir));
return array(
'Zend\\' => $vendorDir . '/zendframework/zendframework/library/',
'ZendTest\\' => $vendorDir . '/zendframework/zendframework/tests/',
'Symfony\\Component\\Console' => $vendorDir . '/symfony/console/',
'Doctrine\\ORM' => $vendorDir . '/doctrine/orm/lib/',
'Doctrine\\DBAL' => $vendorDir . '/doctrine/dbal/lib/',
'Doctrine\\Common' => $vendorDir . '/doctrine/common/lib/',
'DoctrineORMModule\\' => $vendorDir . '/doctrine/doctrine-orm-module/src/',
'DoctrineORMModuleTest\\' => $vendorDir . '/doctrine/doctrine-orm-module/tests/',
'DoctrineModule\\' => $vendorDir . '/doctrine/doctrine-module/src/',
'DoctrineModuleTest\\' => $vendorDir . '/doctrine/doctrine-module/tests/',
'Application\\' => $baseDir . '/module/Application/src',
);
<?php
// autoload_classmap.php generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname(dirname($vendorDir));
return array(
);
$loader returned:
Composer\Autoload\ClassLoader Object
(
[prefixes:Composer\Autoload\ClassLoader:private] => Array
(
[Zend\] => Array
(
[0] => /home/XXXX/public_html/vendor/zendframework/zendframework/library/
)
[ZendTest\] => Array
(
[0] => /home/XXXX/public_html/vendor/zendframework/zendframework/tests/
)
[Symfony\Component\Console] => Array
(
[0] => /home/XXXX/public_html/vendor/symfony/console/
)
[Doctrine\ORM] => Array
(
[0] => /home/XXXX/public_html/vendor/doctrine/orm/lib/
)
[Doctrine\DBAL] => Array
(
[0] => /home/XXXX/public_html/vendor/doctrine/dbal/lib/
)
[Doctrine\Common] => Array
(
[0] => /home/XXXX/public_html/vendor/doctrine/common/lib/
)
[DoctrineORMModule\] => Array
(
[0] => /home/XXXX/public_html/vendor/doctrine/doctrine-orm-module/src/
)
[DoctrineORMModuleTest\] => Array
(
[0] => /home/XXXX/public_html/vendor/doctrine/doctrine-orm-module/tests/
)
[DoctrineModule\] => Array
(
[0] => /home/XXXX/public_html/vendor/doctrine/doctrine-module/src/
)
[DoctrineModuleTest\] => Array
(
[0] => /home/XXXX/public_html/vendor/doctrine/doctrine-module/tests/
)
[Application\] => Array
(
[0] => /home/XXXX/public_html/module/Application/src
)
)
[fallbackDirs:Composer\Autoload\ClassLoader:private] => Array
(
)
[useIncludePath:Composer\Autoload\ClassLoader:private] =>
[classMap:Composer\Autoload\ClassLoader:private] => Array
(
)
)
++INFO:
spl_autoload_functions:
Array
(
[0] => Array
(
[0] => Composer\Autoload\ClassLoader Object
(
[prefixes:Composer\Autoload\ClassLoader:private] => Array
(
[Zend\] => Array
(
[0] => /home/XXXX/public_html/vendor/zendframework/zendframework/library/
)
[ZendTest\] => Array
(
[0] => /home/XXXX/public_html/vendor/zendframework/zendframework/tests/
)
[Symfony\Component\Console] => Array
(
[0] => /home/XXXX/public_html/vendor/symfony/console/
)
[Doctrine\ORM] => Array
(
[0] => /home/XXXX/public_html/vendor/doctrine/orm/lib/
)
[Doctrine\DBAL] => Array
(
[0] => /home/XXXX/public_html/vendor/doctrine/dbal/lib/
)
[Doctrine\Common] => Array
(
[0] => /home/XXXX/public_html/vendor/doctrine/common/lib/
)
[DoctrineORMModule\] => Array
(
[0] => /home/XXXX/public_html/vendor/doctrine/doctrine-orm-module/src/
)
[DoctrineORMModuleTest\] => Array
(
[0] => /home/XXXX/public_html/vendor/doctrine/doctrine-orm-module/tests/
)
[DoctrineModule\] => Array
(
[0] => /home/XXXX/public_html/vendor/doctrine/doctrine-module/src/
)
[DoctrineModuleTest\] => Array
(
[0] => /home/XXXX/public_html/vendor/doctrine/doctrine-module/tests/
)
[Application\] => Array
(
[0] => /home/XXXX/public_html/module/Application/src
)
)
[fallbackDirs:Composer\Autoload\ClassLoader:private] => Array
(
)
[useIncludePath:Composer\Autoload\ClassLoader:private] =>
[classMap:Composer\Autoload\ClassLoader:private] => Array
(
)
)
[1] => loadClass
)
)
The solutions was str replacing all the \ from the namespaces with / in all the modules autoloaders.
So,this:
public function getAutoloaderConfig() {
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . str_replace('\\', '/', __NAMESPACE__),
),
),
);
}
will get everything working as intended on a LAMP machine.

Resources