Typo3 Extension: Injection of repository doesn't work anyway - typo3-9.x

I followed the official Guide from Typo3 for creating a new extension (https://docs.typo3.org/m/typo3/book-extbasefluid/9.5/en-us/4-FirstExtension/Index.html). But when I finished, the page with the plugin gives me only an ERROR 500. No Error-Log anyway.
When I enabled ErrorDisplay I found, that there was a problem with boolean values. So I deleted them and tried again. Again all I got was ERROR 500. ErrorDisplay said the constructor cannot have a return value - hu?? Found inline 7 - but the declaration is in line 22 -??
public function __construct(int $j = 0, int $n = 0, int $i = 0, int $p = 0, int $y = 0, int $a = 0): void {...}
So I tried to delete the return value. But then it told me, that the class couldn't be found. Next, I tried to find anything about that error but found even less than nothing.
I wasn't even able to find extensions that are implementing the way explained by the official guide. Is there anybody who can tell me, what is going wrong and where I can find a solution - I have no idea anymore.

After hours and hours trial and error I found the solution. The Problem is, that Typo3 doesn't give a proper error message due to failing with the exception handling. You have to enable normal PHP Errors to get a clue what is wrong. If there is any php error, Typo3 fails and gives an reflection error, because it thinks the class isn't available.
First Error was: following the official guide instructions for first extension. Compiler ist failing if you try to give the constructor a return value.
Second Error: Typo3 doesn't recognize if a parameter in constructor is missing. It tries to take the next parameter and fails by comparing the parameters type.
Third Error: If the class is missing the instructions for underlying symphony framework the reflection also fails with registering the class without giving any error message.
After I found and corrected all the errors, all worked fine.

Related

Getting FusionAuthClient is not a constructor error

I am trying the fusionauth-node-client and following the wiki https://fusionauth.io/docs/v1/tech/client-libraries/node. But I am getting the following error
const client = new FusionAuthClient('6b87a398-39f2-4692-927b-13188a81a9a3', 'http://localhost:9011');
^
TypeError: FusionAuthClient is not a constructor
at Object.<anonymous>
I have pasted the exact code mentioned in the doc still it is not working. Can anyone help me in identifying what I am missing here.
I dug around in the library and noticed that we are exporting several objects and our example is no longer correct.
To get the client you need to change your syntax a little bit to get the correct object.
const {FusionAuthClient} = require('fusionauth-node-client');
This translates to: require the library fusionauth-node-client and give me the FusionAuthClient from inside it. There are also a RESTClient and JWTManager available in the library but you shouldn't need either of those to code with FusionAuth.
I will also update our example to correct this discrepancy.

Magento SOAP API: Error in retrieving catalogCategoryTree

Currently I'm using Magento 1.9.01 and PHP 5.3.28. In ASP .NET I'm trying to retrieve the catalog tree by using the SOAP API using the following code:
var magentoService = new MagentoService.Mage_Api_Model_Server_Wsi_HandlerPortTypeClient();
var sessionId = magentoService.login(userName, apiKey);
var categoryTree = magentoService.catalogCategoryTree(sessionId, "", "");
The errror I get is "Internal Error. Please see log for details."
And in the logs I can see the following:
Argument 1 passed to Mage_Catalog_Model_Category_Api::_nodeToArray() must be an instance of Varien_Data_Tree_Node, null given
From what I've read it can be a bug with PHP 5.4 or greater, but not the version I'm using... So if someone has any idea how to solve this, it will be greatly appreaciated.
Seems pretty straight forward, though the error thrown suggests a much bigger problem. First make sure that the variables are exactly as you specified in your Magento installation (pay attention to caps). Second you can't pass empty strings, instead try "Null".
Good luck

Underlying provided failed to open ? mvc4 , wcf

This code section i am getting error any ideas ?
public IEnumerable<LOBinfo> getLobinfo()
{
// var obj = from n in lobj.LOBinfoes select n;
return lobj.LOBinfoes.Select(m=>m).ToList();
// return obj.ToList();
}
I am not even using USING keyword ?
This issue been for a while and i referred many articles in stackoverflow itself but things looking bad for me .
Thank you for your suggestions
Underlying provider failed to open means, that at some point a database could not be reached, due to wrong connection settings for example or a previous failure etc...
The code you show here is allright, except for the fact you write a useless .Select you can drop the .Select(m=>m) and just leave the .ToList there.
Further, to find out what is causing your crash post the exact error message as well as the inner exception. (and the inner exception's inner exception and so on...)
Next to that the part "lobj.LOBinfoes" is probably a repository or something? You might as well post the code of that and the code of your data access object as well.

Doctrine2: Type x already exists

I have a problem with the Doctrine API.
I want to add a new Doctrine Type. I followed this documentation to create the class, and I have added the type in my custom driver.
Type::addType("custom", "Namespace\NameBundle\Types\CustomType");
$this->registerDoctrineTypeMapping("CustomType", "custom");
My problem append when I execute php app/console cache:clear.
[Doctrine\DBAL\DBALException]
Type custom already exists.
After few searches, I have found in Doctrine\DBAL\Types\Type::addType(…) throw an exception if the type is knew… I don't understand why this error is throwing.
I have found my problem !
I don't know why, but my custom type is loading again and again.
To resolve this problem, adding this code like checking.
if (!Type::hasType("custom")) {
Type::addType("custom", "Namespace\NameBundle\Types\CustomType");
$this->registerDoctrineTypeMapping("CustomType", "custom");
}
It works !

PHP error_log errors to MySQL

In a previous ticket i asked about logging PHP errors in MySQL which gives me:
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
// mysql connect etc here...
$sql = "INSERT INTO `error_log` SET
`number` = ".mysql_real_escape_string($errno).",
`string` = ".mysql_real_escape_string($errstr).",
`file` = ".mysql_real_escape_string($errfile).",
`line` = ".mysql_real_escape_string($errline);
mysql_query($sql);
// Don't execute PHP internal error handler
return true;
}
// set to the user defined error handler
$new_error_handler = set_error_handler("myErrorHandler");
I can make this work but only if it is triggerred like this:
trigger_error("message here");
However, I also want the error handler to be called for all errors such as syntax errors like:
echo "foo;
But these errors are just outputted to the screen, what am i doing wrong?
You can only handle runtime errors with a custom error handler. The echo "foo error in your example happens when parsing (i.e. reading in) the source. Since PHP can not fully parse the code, it can also not run your error handler on this error.
If You're forced to test if syntax is correct, You can use php_check_syntax function, with filename parameter PHP Manual php_check_syntax
php_check_syntax also provides second parameter, witch when used will be populated by the error string, as far as i remember
That's indeed terrible way of error logging
You don't need not a single advantage of a database. Would you make a database lookup for the certain line number? Or order your results by file name?
database is a subject of many errors itself.
You've been told already that it's impossible to catch a parse error at the program logic level, because a syntactically wrong program will never run.
Let's take your code as an example. It will raise a MySQL error (because of poorly formed query) which you will never see. As well as any other errors occurred. That's what I am talking about.