Amazon cloudsearch describedoamin usage - php

I am trying to use describeDomains function of AWS CloudSearch. But I am getting the below error.
exception 'ReflectionException' with message 'Method Aws\CloudSearch \CloudSearchClient::describeDomains() does not exist

You've probably already figured this out by now, but I think you just need to fix the casing of the DescribeDomains() method (note the initial capital D).
See PHP SDK documentation:
https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-cloudsearch-2013-01-01.html#describedomains

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!

Laravel - Creating Custom Classes throws error of undefined

I've been following this short tutorial and wanted to make my own class and call it simple like classname::methodname, but without injection.
I get the following error:
exception 'Symfony\Component\Debug\Exception\FatalErrorException' with
message 'Call to undefined method
App\Facades\LiveSearch::getServiceList()'
Link to Tutorial: here
It makes sense and that is why i cannot figure out where the problem lies ..
Hey you also need to do the follow up steps to create laravel classes.
I hope this reference on How to create a laravel class is helpful.

The Bug Genie 'undefined function make_url()'

PHP Fatal error: Call to undefined function thebuggenie\core\helpers\make_url() in ../core/helpers/TextParser.php on line 706
This is the error that I keep getting when trying to set up the VCS-integration successfully in The Bug Genie. It is an issue tracker that has VCS (git) integration. The commits can be linked to a project, and with the correct commit-message to the right issue using a git-hook. Then you can view the commit in the issue tracker. Apparently the commit is getting linked to the project, but it doesn't get linked to the issue because of the error. Can anybody help me?
The source code on GitHub.
Thanks in advance!
I've found the solution. There appears to be an error in the vcs-integration. Apparently the ui.inc.php-library is not loaded when using the git-hook.
So the temporary solution (until they solve it) is:
At modules/vcs_integration/Vcs_integration.php:226, add:
framework\Context::loadLibrary('ui');
As far as i see, make_url function is defined in a global namespace, but is called from namespace thebuggenie\core\helpers. So i suppose that's your problem

PHP-Yii: Using Yiis logger when a request is not completed due to php level error

This is probably a yii specific question, even though I wouldn't surprised if experienced non-Yii we developers will be also able to contribute.
I often encounter the following situation:
My application fails due to a fatal error on the php level. Something like $var->property when $var==null
I want to understand how $var came to be ==null.
I'd use logs for this, however, problem is that no logs are left when a request is ended due to php error.
edit: this only happens for fatal errors. For other php errors I have my logs back
An example:
For
$nonExistingVar->someProperty;
I do have my logs recorded, as it yields PHP Error Undefined variable: nonExistingVar
However, if I do define the variable and set it to null,
$tmp = null;
$tmp->prop;
Then I loose the logs, as it results in "Fatal error: Call to a member function hasErrors() on a non-object"
Does anybody understand why does it happen? And how can the logger be anyway used in this situations? I tried setting autoFlush=1, doesn't help
Thanks
Gidi
The below allowed me to have my logs even on fatal errors:
function yiiCorrectShutdown()
{
Yii::app()->end();
//the following line will work as well
//Yii::app()->log->processLogs(null);
}
register_shutdown_function('yiiCorrectShutdown');
I wrote an extension class that logs in real-time thus avoiding any need to modify flow paths. I posted it here on the Yii Wiki

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