Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maximum execution time of 30 seconds exceeded #306

Closed
minixxie opened this issue Jun 14, 2013 · 7 comments
Closed

Maximum execution time of 30 seconds exceeded #306

minixxie opened this issue Jun 14, 2013 · 7 comments

Comments

@minixxie
Copy link

Hi Johannes,

I'm trying to integrate this bundle into my symfony2.2.*, to facilitate the JSON serialization.
All my objects are stored under MySQL and fetched with Doctrine2.

I got this error when I'm just doing a select on my "User" table with only one JOIN:

Maximum execution time of 30 seconds exceeded

If I fetched the user object and saved into the symfony2's session first, and serialize the object retrieved from the session, it has no problem. So I'm quite sure that this was caused by the LAZY LOADING that this bundle is using. From the dev log, I can see that there are not only ONE SQL statement, but there are MANY SQL statements fetching a bunch of tables. So I believe the LAZY LOADING is helping me fetch all related table that "User" table references.

I've been searching for this on stackoverflow and got this:
http://stackoverflow.com/questions/11851197/avoiding-recursion-with-doctrine-entities-and-jmsserializer

Seems that only the last answer is the most updated because I couldn't even find the class Serializer\Handler\DoctrineProxyHandler. But by following the last answer (which got 0 marks), the problem is not solved. I think the rewrite of the DoctrineProxySubscriber class is the correct direction but the line in "parameters.yml" is not being effective.

Can you give me some hints? It is perfect if you told me somewhere to switch off the LAZY LOADING. Thanks.

Simon

@minixxie
Copy link
Author

Today I found that it issues many SQL statements when the code runs into this function:

$serializedData = $serializer->serialize($user, 'json');

Although I commented out the line

//$object->__load();

in "vendor/jms/serializer/src/JMS/Serializer/EventDispatcher/Subscriber/DoctrineProxySubscriber.php",
and fetch the user object previously saved in the session,
it stills issues many SQL statements.

I'm sure this is caused by the LAZY LOADING but don't know if this is the correct way to suppress it. Any advice?

Simon

@alex-ception
Copy link

You might want to take a look at http://jmsyst.com/libs/serializer/master/reference/annotations
Especially @ExclusionPolicy, @expose and @exclude

@minixxie
Copy link
Author

Thanks very much pataprout. But what should I do if sometimes I want to exclude, and sometimes I want to include?

For example:
User <---1-to-many---> Phone

In some AJAX requests, I want to just return the User object, while in some other I want to return the User with the array of Phone.

I thought that if I don't fetch-join the Phone table, it should not lazy-load it for me.

Simon

@Baachi
Copy link

Baachi commented Jul 19, 2013

@minixxie
Copy link
Author

Thanks very much pataprout. It's going to be very useful info to me.

@tiagooc
Copy link

tiagooc commented Mar 11, 2014

I am currently using "exclusion_policy: ALL" on entity via YAML configuration but i still have the same issue. I've created a simple test entity with only three fields and I had no problems but when I use my entity which is related to others entities I still get the message "Maximum execution time of 30 seconds exceeded".

Any thoughts?

EDIT: I've added a pastebin link with my Controller, Entity and YAML Serialization file:
http://pastebin.com/v5eNrx6y

EDIT2: I finally found what was wrong. It happens that the YAML Serialization file must be in the same bundle of the Entity you want to use. My bad. ;)

@goetas
Copy link
Collaborator

goetas commented Jan 20, 2017

Sorry for the long feedback loop. This issue is probably already solved.
(if not feel free to re open the issue or to comment here)

Thanks

@goetas goetas closed this as completed Jan 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants