Jump to content
godmok

Loop with page fields generates memory problem

Recommended Posts

Hi everyone,

this is more a note than a question but I also wanted to know if it is wanted to be like that, and I didn't find any Info on this.

I had a structure like that: my site has a user-profile page and a PW user. The user has a page field to link it to its profile page. So far so good, but to get some information from the PW user I set a page field into the profile page, so both pages are bound by two lines (profile<=>user). Each line goes in only one direction.

What happened after is this: the server run out of memory (allocation?). Seems like the page input fields run in circles. The page was still shown, but broken, with the error at the bottom.

The fix was easy: just put one page field into the PW user, link that with the profile and do a $users->find("page_field=$page->id") in the template of the site. Easier done could be to use the $page->createdUser profile value, but that makes it a little more complicated to change at creating the user and profile site. Will do that later on. Many ways to go, I like that the most on PW :)

As I understand this can happen to any pages, so be warned to not combine pages like this. There are better ways.

So: is this a wanted logic? Two pages can loop into each other? Are there any security notes on something like this, maybe on the docs? Or something like small notes to DO NOT do something like this or be warned somehow?

Thanks!

  • Like 1

Share this post


Link to post
Share on other sites

You are right, both page fields were set as 'single' fields, forgot to mention that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By celfred
      Hello,
      I'm struggling with this : a 'group' field of 'Page' type.
      The parent of selectable pages is '/groups', the template is 'group', and a member can create some groups in the /groups tree. I would like this user to see only the groups he or she has created so in my 'Find selector' in the backend, I would like to use :

      template=group, created_users_id=$user->id But that doesn't seem to work... I still get the list of all available groups in the /groups tree.
      Any idea ?
      I had a feeling I had already seen that before (something like $user->id must be replaced by users_id or something, but I can't find anything in the Forums... and all my tests keep failing...
    • By louisstephens
      So, I really don't know where to begin with this. I have the thought in my head (the basics), but not really sure how to set it up.
      The desired effect:
      The homepage is set up with a foreach loop that outputs all the child pages (basically just a bunch of pages with pdfs, docs etc stored in a file field). When A user is actually logged in, they can "star" an item or drag and drop (using Dragula) the page to a sidebar. Also, they would be able to reorder the pages in the sidebar.
      The question(s):
      I guess I have multiple questions regarding how to achieve this.
      Would it be best to create a page field in the user template to save the page(s)? How would you actually save the page state (sidebar output, reordering, etc) once the drag and drop has been used? Thanks in advance for any help! A lot of this was just what was in my head, so it might not make full sense. However, I will update this if I can actually wrap my head around everything.
    • By Vigilante
      I'm wondering about creating a query that involves looking across two different parent page trees.
      One parent is for blog posts and it has each post under that.
      Another parent is used for categories and subcategories for the blog.
      Then in the blogs there is a page field that can reference the categories. This is all pretty normal setup so far.
      I created a navigation that lists the current category and its children, but I want to not show categories that have no posts. For some reason I'm drawing a blank.
      So let's say a user clicks category1, and it shows a blog listing for that category. I query for all the child categories of the current one. Now I want to exclude any categories where NO blogs exist that make reference to the category (an unused category). How do I do this in a way that is performant? I don't want to have to query the blogs tree over and over to test for the presence of each category in the list!
      Here is the tree:
      blogs
       - article1  [pagefieldcat = "cat1"]
       - article2 [pagefieldcat = ""]
      categories
      - cat1
      - cat2
      Now when I get all children of categories, I want to exclude cat2 since it's not referenced from any blogs. Can I do this without having to loop and query every category against every blog one by one?
      Thanks
    • By Michael Steinmann
      Hello everyone,
      i guess my php knowledge is not good enough to find a solution for the following problem:
      I'm building a website where i have projects. Each project has tags like "webdesign, responsive, cms, print, flyer" etc. At the end of a project i want to recommend other projects, which have similar tags. I want to limit the recommendations to three other projects sorted by the hightest amount of same tags.
      This is how far i got:
      I'm using
      <?php $interessantes = $pages->find("tags=$page->tags, id!=$page->id"); ?> to find other projects with the same tags, excluding the page i'm already on.
      Then i'm using three foreach-functions to go through the projects i found, the tags they have and compare them with the tags of the project i'm looking at. If i have two identical tags, i count up a variable.
      <?php // Projects i have found foreach($interessantes as $interessant): $i = 0; // Tags of the projects i have found foreach($interessant->tags as $tag): // Tags of the project i'm looking at foreach($page->tags as $tagreferenz): if($tag == $tagreferenz): $i++; endif; endforeach; endforeach; endforeach; ?> You can see what it looks like in the screenshot with a bit of HTML. I marked the tags of the current project green and the identical tags of other projects red with the amount of hits below. So in this example i would want to have three projects with three similar tags and get rid of those with only two and one.

      I guess i have to put my pages into an array (with the number of hits?), sort them and echo them with "limit=3"? Unfortunately i have no idea how to do this. You probably have an even better/shorter solution. Links to other topics are welcome to and i'll try to get my head around it.
      If you need further explanation, i'll try my best.
      Best regards
    • By alxndre
      I'm trying to sort pages based on their parent's fields, which are page references.
      For instance:
      $someOrders = $pages->find("template=order, sort=parent.customer.id"); Here, order's parent has a template called 'orderslip' that has multiple 'order' children. Orderslip contains a page field called customer, and I want to sort based on the parent's customer's id. But i can't make it work. It throws out an exception:
      Error: Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'customer' in 'order clause' (in /srv/rewwwards/wire/core/PageFinder.php line 410) I'm sure customer page field exists and it works everywhere else. It's just that this time, I'm trying to sort it from a page's 'parent' selector. Is it even possible do this?
      As always, any help is greatly appreciated.  Thanks.
×
×
  • Create New...