createEnvelope with CompositeTemplate error - php

Modifying the sample code for embedded signing to use a CompositeTemplate resulted in the following error.
msg: Access to undeclared static property: stdClass::$swaggerTypes
file: $home/lib/docusign/src/ObjectSerializer.php
line: 68
This happens on the attempt to serialize SignHere:scale_value, which is an object, but a standard object, not a Swagger object, and the serializer assumes ALL objects are Swagger objects. Not sure if the SDK is mistakenly assuming scale_value is an object (seems it should just be a scalar) or there's a missing ScaleValue model class.
Anyone run into this before?

Yep, this was definitely a bug in the SDk. Bug reported but no idea how long it will take to be fixed.
If you run into this issue, just open src/Model/SignHere.php and change the type of scale_value to string instead of object.

Related

Symfony BadMethodCallException: Cannot serialize FilesystemAdapter When Using AWS Presigned URLs (DynamoDB Issue)

I'm working in Symfony 6.0 and PHP 8.1, and the following error appeared in my logs when injecting my custom AWSService into a custom object:
Uncaught PHP Exception BadMethodCallException: "Cannot serialize Symfony\Component\Cache\Adapter\FilesystemAdapter" at /app/vendor/symfony/cache/Traits/FilesystemCommonTrait.php line 176
Channel: request
Context: exception:
{
"class": "BadMethodCallException",
"message": "Cannot serialize Symfony\\Component\\Cache\\Adapter\\FilesystemAdapter",
"code": 0,
"file": "/app/vendor/symfony/cache/Traits/FilesystemCommonTrait.php:176",
"trace": [
"/app/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:241",
"/app/vendor/symfony/http-foundation/Session/Session.php:195",
"/app/vendor/symfony/http-kernel/EventListener/AbstractSessionListener.php:132",
"/app/vendor/symfony/event-dispatcher/EventDispatcher.php:270",
"/app/vendor/symfony/event-dispatcher/EventDispatcher.php:230",
"/app/vendor/symfony/event-dispatcher/EventDispatcher.php:59",
"/app/vendor/symfony/http-kernel/HttpKernel.php:185",
"/app/vendor/symfony/http-kernel/HttpKernel.php:173",
"/app/vendor/symfony/http-kernel/HttpKernel.php:74",
"/app/vendor/symfony/http-kernel/Kernel.php:202",
"/app/public/index.php:25"
]
}
I've added other logging throughout the code, and it appears that this happens AFTER my controller exits and returns successfully. I am not clear on how to further debug this issue, since after the controller exits it goes into Symfony-land.
My AWSService handles things like storage to and retrieval from AWS services, such as S3 or DynamoDB. I'm injecting it into an object that keeps the caller's info in the session for easy access, and for the call that throws this error, I'm using it to create a Presigned URL for one of the object's attributes.
The thing that seems strange to me is that the AWSService isn't accessing the filesystem explicitly... it's taking an object and creating a string from it using AWS' $s3->createPresignedRequest() call. Even the AWS docs for createPresignedRequest() imply that the function just spits out an answer based on the settings it was provided:
Important
The URL returned by this method is not validated to ensure that the bucket or key exists, nor does this method ensure that the object allows unauthenticated access.
Further, as stated above, the function call completes with out error, and the Controller that called it also completes without error, before this exception is thrown. So it's hard to believe that the AWSService itself is causing this problem.
Clearly this has something to do with how objects are serialized, but I'm not sure exactly what as this error is pretty vague, and I'm creating a string (not a resource). Any thoughts would be appreciated!
After banging my head against this for a few hours, I finally figured it out... and since I couldn't find anything here at StackOverflow that addresses the issue specifically, here are my notes.
It turns out that Symfony appears to serialize all of the objects in session so that they can be de/re-hydrated after the main processing is complete, and before listeners, post processors, etc. are called.
I got a hint from this StackOverflow post, which told me that resources are not supported in serialized data. But I didn't think that getting a Presigned URL would cause an issue... and as it turned out, that was correct.
I finally created a helper class for the object, and just set the attributes externally instead of internally when the object was constructed. Only at that point did I get a better error:
request.CRITICAL: Uncaught PHP Exception RuntimeException: "Instances of Aws\DynamoDb\DynamoDbClient cannot be serialized" at /app/vendor/aws/aws-sdk-php/src/AwsClient.php line 276
So... because the AWSService included an instance of DynamoDbClient, and because I was putting the AWSService into an object, which was then being stored in the session, Symfony was crashing when the object hit the internal serializer.
I'm not sure why that exception isn't bubbled up better, but... at least now it's documented here. Hope it helps someone else!

PHP Unit Fatal error: Call to undefined method PHPUnit_Framework_MockObject_InvocationMocker

I'm having an issue with php unit on hhvm where getmock() failing on phpunit 4.8.27 for a class with the following message
Fatal error: Call to undefined method PHPUnit_Framework_MockObject_InvocationMocker::getTableColumns() in /joomla-cms/libraries/joomla/table/table.php on line 241
Test Code failing is located at https://github.com/photodude/joomla-cms/blob/patch-1/tests/unit/suites/libraries/cms/installer/JInstallerAdapterTest.php#L111
for the test code this "fails/errors" the test with no Fatal error
$mockTableExtension = $this->getMock('JTableExtension', array('find', 'load'), array($this->getMockDatabase()));
but if I use the stored value
$mockDatabase = $this->getMockDatabase();
and type cast the mockDatabase object to array I get the Fatal error listed above.
$mockTableExtension = $this->getMock('JTableExtension', array('find', 'load'), (array) $mockDatabase);
Travis test with the mockDatabase object and object type cast to array var_dumped https://travis-ci.org/photodude/joomla-cms/jobs/172201634#L1427-L2178
Everything passes and works just fine in php, the issue is specific to testing on hhvm
Am I doing something wrong in the mock setup? or is there something else going on?
note: I recently tested this portion of the test suit on php unit 5.6 and got the same issue. So I'm not sure what we've don't wrong in the setup of these tests.
I found there is some issue with array($this->getMockDatabase()) in one of the tests on hhvm. Replacing array($this->getMockDatabase()) with array(self::$driver) all of the issues were resolved.
I also replaced the direct use of getMock with the getMockBuilder (for compatibility with phpunit 5.6)

Error notices using Linkedin Plugin in Cakephp

I am trying to put a Linkedin plugin in cakephp, using this tutorial http://excellencetechnologies.co.in/Telephonia/blog/linked-login-integration-in-cakephp/
Everything works fine until I login in linkedin but after that I get directed to a page with just this two errors:
Notice (8): OAuthRequest::from_consumer_and_token(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "OAuthToken" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition [APP\Plugin\Linkedin\Vendor\OAuth\OAuth.php, line 316]
Notice (8): OAuthSignatureMethod_HMAC_SHA1::build_signature() [oauthsignaturemethod-hmac-sha1.build-signature]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "OAuthToken" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition [APP\Plugin\Linkedin\Vendor\OAuth\OAuth.php, line 126]
I can't find what may be causing them anywhere online so I was wondering if anyone here might know what is causing this.
Wherever in the code the plugin is pulling the access token from session like this:
$accessToken = $this->Session->read($this->sessionAccess);
It is pulling the token in the form of __PHP_Incomplete_Class object. To correct this problem you would have to unserialize the $accessToken like this:
$accessToken = $this->Session->read($this->sessionAccess);
$accessToken = unserialize (serialize ($accessToken));
I did it at the three spots in the code to correct it.
Hopefully it will work for you as well.

How do I view the last request from Zend_Soap_Client->getLastRequest() after a soap fault exception?

I am using a Zend_Soap_Client to call a web service. I am getting an exception from the error which I suspect is down to me not sending something along with the request:
Fatal error: Uncaught SoapFault exception: [Sender] SOAP-ERROR:
Encoding: object hasn't 'V24Flag' propert
Because it throws an exception I want to try view what is the actual request being sent, however because of the exception, I can not use Zend_Soap_Client->getLastRequest() to get the request (it returns null). Looking at the Zend_Soap_Client->getLastRequest() its a thin wrapper for soapClient->__soapCall() which I'm not sure how to dig deeper from.
Your problem is actually slightly different to what you think it is. The reason Zend_Soap_Client::getLastRequest() returns NULL for you is that no request was ever made: the error is being thrown at the stage where the request internally is being compared against the WSDL you are using. So the method is perfectly correct to return NULL.
As to how to form the parameter for your SOAP call so this error isn't thrown, I can't be of much greater help right now (I expect it depends partly on the services you are integrating with), but there's a userland answer on the php.net page for SoapClient::__soapCall() which may point you in a fruitful direction. Essentially, some people seem to have got somewhere by doing a deep conversion of an array structure into stdClass objects. That doesn't seem to be the whole story (it isn't for the issue I'm currently investigating), and indeed this may be down to a bug in PHP, but I hope it helps you towards an answer.
How about
try {
$client = new Zend_Soap_CLient();
$client->doSomething($params);
} catch(SoapFault $f) {
echo $f->getTraceAsString();
}
Btw. Zend_Soap_Client->getLastRequest() wraps SoapClient::__getLastRequest();

Zend AMF throwing InvocationTargetException

I am trying to make a service call to a php function from flex, through Zend AMF. Most of the functions get called fine, but for one particular function, it throws the following exception:
InvocationTargetException:There was an
error while invoking the operation.
Check your operation inputs or server
code and try invoking the operation
again.
Reason: Fatal error: Call to a member
function getInvokeArguments() on a
non-object in
D:\wamp\www\ZendFramework\library\Zend\Amf\Server.php
on line 328
I am not able to debug through this - has anyone faced any issue like this before, or have any ideas how this can be debugged?
At a quick glance through ZFW's source, this appears to be a bug on their framework.
// There is no check if $this->_table[$qualifiedName] is an object, implements an interface, extends a class, only if it's set (the key exists).
$info = $this->_table[$qualifiedName];
$argv = $info->getInvokeArguments(); // Here's when you get the error.
Source: http://framework.zend.com/code/filedetails.php?repname=Zend+Framework&path=/trunk/library/Zend/Amf/Server.php
I looked in their bug tracker and haven't found anything related to this, perhaps you should open a new issue?
Additionally, you can debug the problem by grabbing the message that Flex is sending to the PHP client and making a test case out of it.
We finally realized that this was a problem in the flex project setup - don't know exactly what it was, but once we deleted and created the project again, things started working fine!

Categories