Entity property not found error in symfony - symfony

In prod mode of symfony, I get the below error.
"message": "[Semantical Error] line 0, col 134 near 'stock = :sto':
Error: Class AppBundle\\Entity\\CartItem has no field or association named stock",
Actually before few days I added a stock property in my CartItem Entity.
This is working in dev environment but giving error in prod environment.

Related

Symfony 6.1 Doctrine QueryBuilder "class xxx is not defined"

I'm trying to move a Symfony 3.4 app to 6.1. I've done this by creating a brand new, clean 6.1 app and am copying things over.
I'm stuck with some Doctrine queryBuilders, eg.
$this->query = $em->createQueryBuilder()
->select('c')
->from('Customer' , 'c');
This code is in a Controller, not a Repository. This gives the error
[Semantical Error] line 0, col 14 near 'Customer c ORDER': Error: Class 'Customer' is not defined.
In the 3.4 version, 'Customer' was prefixed by the bundle name. In the 6.1 version, there is no bundle. I understand that the bundle name in 3.4 showed Doctrine which Entity 'Customer' referred to, how do I do the same in 6.1 with no bundle?
Prefixing with App\Entity\ works! Eg:
$this->query = $em->createQueryBuilder()
->select('c')
->from('App\Entity\Customer' , 'c');

dynamodb with help of np dynamodb or np vogels, throwing Invalid schema content error

I am trying to create a schema using node package dynamodb/vogels but it is throwing Invalid schema content. I used the below sample schema
var Account = vogels.define('Account', {
hashKey : 'email',
// add the timestamp attributes (updatedAt, createdAt)
timestamps : true,
schema : {
email : Joi.string().email(),
name : Joi.string(),
age : Joi.number(),
roles : vogels.types.stringSet(),
settings : {
nickname : Joi.string(),
acceptedTerms : Joi.boolean().default(false)
}
}
});
error details
Uncaught Error: Invalid schema content:
node_modules/vogels/node_modules/hoek/lib/index.js:731
Debugger attached.
Waiting for the debugger to disconnect...
c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\hoek\lib\index.js:731
throw new Error(msgs.join(' ') || 'Unknown error');
^
Error: Invalid schema content:
at Object.exports.assert (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\hoek\lib\index.js:731:11)
at Object.exports.schema (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\joi\lib\cast.js:65:10)
at internals.Object.keys (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\joi\lib\object.js:269:25)
at Object.exports.schema (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\joi\lib\cast.js:46:33)
at internals.Object.keys (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\joi\lib\object.js:269:25)
at Object.exports.schema (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\joi\lib\cast.js:46:33)
at internals.Object.keys (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\joi\lib\object.js:269:25)
at c:\my-workspace\dynamoDB\node_modules\vogels\lib\schema.js:105:74
at internals.Object.internals.Any._validateWithOptions (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\joi\lib\any.js:460:16)
at module.exports.internals.Any.root.validate (c:\my-workspace\dynamoDB\node_modules\vogels\node_modules\joi\lib\index.js:102:23)
Process exited with code 1
Has anyone come across this or know how to create the schema using node page dynamodb/vogels?

Dependency component issue

I'm new in Symfony and after I finished course "Create your own PHP Framework" (which is based on symfony components), I wanted to expand my framework by inject constructor of controller by model, but I got stuck. I got following error.
Error:
Catchable fatal error: Argument 1 passed to Controller\HelloController::__construct() must be an instance of Model\TestModel, none given, called in /var/www/html/vendor/symfony/http-kernel/Controller/ControllerResolver.php on line 195 and defined in /var/www/html/src/Controller/HelloController.php on line 21
HelloController constructor
public function __construct(TestModel $testModel)
{
$this->testModel = $testModel;
}
In container
....
$containerBuilder->register('model', \Model\TestModel::class);
$containerBuilder->register('hello', \Controller\HelloController::class)
->addArgument(new Reference('model'));
....
Routes
$routes->add('index', new Routing\Route('/hello/{name}',array(
'name' => 'World',
'_controller' => 'Controller\HelloController::index'
)));
I will be grateful for every advice.
Thanks

can't update database symfony 4 with sonataClassificationBundle

im using Symfony 4.1
When you install SonataMediaBundle and SonataClassificationBundle after configure the both of them.
and you want execute the commande
php bin/console doctrine:schema:update --force
you got this Error
The table with name 'shop.classification__collection' already exists.
same for all other table of classification like category and tag
if you try to change the name of table in the entity of classification__collection to classification_collection
you will get a second error like
An exception occurred while executing 'CREATE UNIQUE INDEX tag_collection ON classification__collection (slug, context):
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
I run in this problem recently and find the solution.
The issue is address here
https://github.com/sonata-project/SonataClassificationBundle/issues/407
You just need to remove the entity created in App/Entity by classification or remapped the class to the App/Entity in sonata.yaml and sonata_classification.yaml
If you deleted the entities in App/Entity add the following cofiguration to your sonata.yaml and sonata_classification.yaml
/** sonata_classification.yaml**/
sonata_classification:
class:
tag: App\Application\Sonata\ClassificationBundle\Entity\Tag
category: App\Application\Sonata\ClassificationBundle\Entity\Category
media: App\Application\Sonata\MediaBundle\Entity\Media
collection: App\Application\Sonata\ClassificationBundle\Entity\Collection
context: App\Application\Sonata\ClassificationBundle\Entity\Context
/** sonata.yaml**/
class:
media: App\Application\Sonata\MediaBundle\Entity\Media
gallery: App\Application\Sonata\MediaBundle\Entity\Gallery
gallery_has_media: App\Application\Sonata\MediaBundle\Entity\GalleryHasMedia
category: App\Application\Sonata\ClassificationBundle\Entity\Category

Use pydrill storage_update() to create Apache drill storage

I am trying to create MySQL apache drill storage plugin using pydrill. It is throwing error:
RequestError: TransportError(400, 'Unrecognized field "type" (class org.apache.drill.exec.server.rest.PluginConfigWrapper), not marked as ignorable (2 known properties: "config", "name"])\n at [Source: org.glassfish.jersey.message.internal.EntityInputStream#1843f42f; line: 1, column: 138] (through reference chain: org.apache.drill.exec.server.rest.PluginConfigWrapper["type"])')
Here is my code:
drill = PyDrill(host='host',port='8047',user='xx')
configu = '{"type": "jdbc","driver": "com.mysql.jdbc.Driver","url": "jdbc:mysql://host:3306","username": "xx","password": "xx",enabled:true}'
drill.storage_update('MySQL1',configu)
Any help is highly appreciated!
I found out the solution. We need to pass the storage name as a parameter, and as a json 'key':'value' in the config parameter.
Here is the corrected code:
configu={'config': {'driver': 'com.mysql.jdbc.Driver','enabled': True,'password': 'xyz','type': 'jdbc','url': 'jdbc:mysql://host:3306','username': 'xx'},'name':'xxx'}
drill.storage_update('xxx',config=configu)
And Bingo! It worked!

Resources