What does appendChild function in fine-uploader do - php

I am trying out fine-uploader's library. I am getting the following console error whenever I run their traditional UI and PHP server code:
templating.js:638 Uncaught TypeError: Cannot read property 'appendChild' of null
at qq.Templating.render (templating.js:638)
at new qq.FineUploader (uploader.js:162)
at (index):87
What could be the issue (Sorry question may not be detailed but i figure anyone who has interacted with the library gets it)

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!

Uncaught TypeError: Cannot read property 'replace' of null

Jquery datatable is not loading for some user ids. it shows this error in chrome
Uncaught TypeError: Cannot read property 'replace' of null
and in firebug
TypeError: a is null return a.replace( /<.*?>/g, "" ).toLowerCase();
is this the jquery plugin issue or my php code (laravel) code.. i've been debugging this for one day.. didn't find the cause. please if anyone knows tell me what triggers this error?
This is because a is not what you expect, it is null.
Update code:
if (a) return a.replace( /<.*?>/g, "" ).toLowerCase();
If the code is in third-party library then, you are missing something.

Fatal error: Call to undefined method Google_IO_Curl::authenticatedRequest()

When using the described in the Google Contacts API example simple.php, and the Google API PHP Client from GitHub, version 1.0.4-beta, I get the following error:
Fatal error: Call to undefined method Google_IO_Curl::authenticatedRequest()
However, when I change this line...
$val = $client_svc_contacts->getIo()->authenticatedRequest($req);
...to...
$val = $client_svc_contacts->getAuth()->authenticatedRequest($req);
...then it starts working again.
I am using version 1.0.4-beta unmodified except for the addition of the following line at the top of Client.php:
set_include_path(str_replace('/Google','',dirname(__FILE__)));
I recognize that simple.php was written for version 0.6, not v1+, but is the example just out of date compared to the version on GitHub? Or is there something wrong with my implementation?
Found a migration guide that had the answer ...
A new home for authenticatedRequest
The authenticatedRequest method has been moved from the io classes to
the auth classes.
So it appears that replacing getIo() with getAuth() was the correct course of action.

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