I'm using Sonata Admin as my admin backend for Symfony2, and I'm trying to load a page where my admin entity (transaction) has a many to one relationship to another entity (rate). The rate table is massive and grows very quickly, and there's not really anything I can do to change that.
When I hit the transaction list page, I get a memory sized exhausted error. Assuming this was a database problem (because the code works on my local environment), I cleared out the transaction table and the problem still happened. Once I cleared out the rates table, the page loaded immediately. I can only imagine this means that related entities are being eager-loaded on the admin pages.
Does anyone know how to force Sonata to lazy-load related entities? I've looked through the documentation and forums, and the only things I've seen either aren't relevant or say that Sonata does lazy-load automatically. Ideas?
I found the problem. Sonata may or may not lazy load, but that's not what the issue was; it was never even getting to the configureListFields() function. Instead, you don't want to add a field that has a lot of rows to your filter, it apparently loads all options at runtime.
Related
I have the following problem, I have a template layout.html.twig which is loaded everywhere, in it I have a menu with categories downloaded from the database, and now my question is how to make a list of categories from the database in each controller from the machine, instead of each time download a category repository and all categories from it. I have been working in Symfony for a long time, but I create the API without views, hence the problem. Generally, I would like that after loading layout.html.twig a list of categories has been downloaded without my intervention, bypassing the loading of this list in every action of the controller.
I have fixed elements on the site, such as: category menu downloaded from the database, on the main page I have popular articles that also have to be on every subpage, and it makes no sense to download everything in every controller every time.
Any ideas?
I would create a menuFragment method in my DefaultController, and use a sub-request to render it.
https://symfony.com/doc/current/templating/embedding_controllers.html
Some people will tell you that sub requests slow down your code, but it is not significant if you don't go overboard with it. 1-3 subrequest won't be a problem at all.
I have just installed dexterity into our office's intranet site so that I can create some new types for particular styles of documents. I had hoped just to use just the TTW capabilities, but I'm seeing extraordinary behaviour. When I try to create the fields of a new type, any, or all of the following problems can be seen, almost non-deterministically:
After saving the attributes of a new field, the field sometimes doesn't get shown in the page showing the fields of that new type.
Sometime a page refesh does show it, other times it doesn't.
Clicking on the Settings for a field (when it is visible) sometimes shows the error dialog indicationg that this page does not exist.
Sometimes the settings dialog does come up, and then attempts to save it fail with another error dialog to say that this page does not exist.
With a bit of persistance by retrying and refreshing often, I can get a type defined with a couple fields. Then when If I create an instance of this new type, often only some subset of those new fields are shown in the creation form. When I try to save it, the form is shown again but this time with the required fields that were originally hidden now highlighted in red. Finally saving that object then displays it with some fields (but not all) missing.
It's seems utterly random.
I have added the following to my buildout:
extends =
base.cfg
versions.cfg
http://good-py.appspot.com/release/dexterity/1.0.3?plone=4.1
...
eggs =
...
plone.app.dexterity
My Plone is:
Plone 4111
CMF 2.2.4
Zope 2.13.8
The event.log doesn't have any messages in it when these problem are occuring.
Any insights appreciated.
Do you have a caching server in front of Plone? Maybe that is being too agressive and it is caching stale content. Try accessing Plone directly without any caching servers in between and see if that helps.
I have a block which displays all news belonging to terms of a category. However, sometimes, all news related to a term disappear while other terms' news are still visible. This disappear chunk appears on its own later. Is there a way I can fix it.
Both temporary or Permanent solutions are welcomed. Thanks in advance.
I have tried repairing tables, flushing cache but to no avail.
I checked the queries, they seem to be working fine.. I have used APC cache. Could that be a cause of old cached data. I tried flushing APC cache using apc_clear_cache() w and calling apc_clear_cache('user') but it hangs the server into indefinite loop.
Ok, I figured out the problem. The problem was that one of the news belonging to the set of news of a particular taxonomy was saved partially. Though there was an entry in the node table, other related data was missing.
On deleting this partial node manually from the database, the set of missing news articles reappeared.
I have recently created an application where a lot of data is loaded into objects when the application starts up, and other data as it is required. For example if the user requests the catalogue page then it will load all the top level category data into objects of type Category. This will then stay there to be used by other users (who will therefore not have to load this data into objects) and can be altered by admin if they happen to login during the same application instance. I know this is not the most efficient solution, as pointed out below, but it works and the page load, at the moment, is not too long. It is very quick if most of the required data is already loaded into objects. It is also tailored to the business' needs - unlike other techniques such as Linq-to-SQL.
The problem I am facing is when a page is requested which requires lots of data to be displayed about different types of object. For example when a catalogue page is requested which displays information on a product which can be bought, it then loads all the products and categories (as the products make reference to the category object, not just the category name).
I would like to display a loading symbol with a message whilst all this data is being loaded into objects, so the user knows its not just in a loop or anything. Is there any way to do this? I am open to using JS / jQuery if I need to.
Thanks in advance.
Regards,
Richard
PS I am working on ways to make it more efficient - such as using HashTables or HashMaps. However this is taking time as there are so many different types of item (News, Events, Catalogue Item - Range, Collection, Design, RangeCollection, CollectionDesign, RangeCollectionDesign and RangeDesign - Users, PageViews and the list goes on).
Please correct me if I'm wrong, but I do believe that Javascript is required in order to display a "loading" image... Using server-side scriping alone would typically require an entire page load after all the content loads unless you want to start messing with IFrames.
This is a job for AJAX. A common solution to your problem is to have a small page that displays a loading icon. The page has some JavaScript that makes additional HTTP requests to the server to download the rest of the page. JQuery has a "$.ajax" method that is designed to simplify this process.
I would suggest looking at the documentation to the .ajax method in the jQuery documentation. Unfortunately, it seems to be a rather delicate process to get all the scripting code right and it takes a while to learn it all.
I have a fairly new drupal installation with a few hundred nodes. I moved it from the development server to the production server.
However, when I opened my homepage, it says page not found. After checking all my links, it seems that I can't get to any of my content. They exist in the node database, as well as the content type tables. I verified that all my URL aliases are also in place. In most cases, I can still see all the information from views I had created, but when clicking to see the full node view, I get the "Page not found".
I did trim all my cache tables before importing to reduce the size of the DB. Has anyone had these symptoms before? Perhaps there is a particular table, that when truncated, will lead to this problem?
**Update: Imported my revision table again, and presto - Although my content came back, I'm still having a sort of permissions problem. When an anonymous visitor comes to the site, they are told they don't have permission to see items like content type "Page", yet in user permissions, everything looks good (definitely good before migration) perhaps another deleted table?
Yes, node content information is in the revisions table, not the node table. You REALLY need the revisions table. I assume you can just remigrate again, this time without truncating revisions.
if table is broken, it shouldn't show "Page not found". It may show that sql error that table or column doesn't exists.
Try troubleshoot in http://drupal.org/node/201875 (you will see Page Not Found links in middle).
Also may be you use some redirecting in your node theming, check this.
p.s. In any case, node saving touch 2 tables: node and node_revisions