Problems, need help? Have a tip or advice? Post it here.
12 posts Page 2 of 2
I've got a problem: I've made the name like this:
Code: Select all
  <cms:db_persist_form
k_page_name = "<cms:concat p1=frm_activity_id p2='_' p3=frm_place />"
  />

But I don't seem to get an error on duplicate? submit_success: 1
The first entry stays in place, but now the second user also gets a success message, while it should have been something like "place already taken, try again" or something, with all other fields filled like they were...
Everything else seems to work fine (ajax call) I did need to move a loop from couch to javascript side, because it resulted in a memory exhausted fatal error. How many pages can couch handle at a time (in a loop)?

I did this:
at the moment I have 8 activities, total_places 100, 5 subscriptions, all on my local machine, and it just went wrong.

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Places' clonable='0'>
</cms:template>

<cms:set requestid="<cms:php>
    if (isset($_GET['activity_id']) && is_numeric($_GET['activity_id'])){
        echo $_GET['activity_id'];
    }
</cms:php>" scope='global'/>

<cms:pages masterpage='activities.php' id=requestid >

   
      <cms:if (total_places!='') && (total_places gt '0')>
      {
            <cms:repeat count=total_places startcount='1' >
            <cms:set found='false' scope='global' />
            <cms:set place=k_count scope='global' />

            <cms:reverse_related_pages masterpage='subscriptions.php' field='activitysubscription'>
                 
                <cms:if place_number=place>
               
                    <cms:set found='true' scope='global' />
                </cms:if>
            </cms:reverse_related_pages>
           
           
            "<cms:show place />":<cms:show found />
            <cms:if k_count ne total_places>
            ,
            </cms:if>
           
        </cms:repeat>
        }
    <cms:else />
        false
    </cms:if>
</cms:pages>


Now I did this and did the loop to check for true/false on the front-end, but since the other one did break very fast, I'm afraid that at some point this might break to. Is there a way to know easily how many records this can handle (other than just filling it manually).
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Places' clonable='0'>
</cms:template>

<cms:set requestid="<cms:php>
    if (isset($_GET['activity_id']) && is_numeric($_GET['activity_id'])){
        echo $_GET['activity_id'];
    }
</cms:php>" scope='global'/>

<cms:pages masterpage='activities.php' id=requestid >

   
      <cms:if (total_places!='') && (total_places gt '0')>
        {
            "total_places":<cms:show total_places />,
            "taken":[
            <cms:reverse_related_pages masterpage='subscriptions.php' field='activitysubscription'>
                    <cms:show place_number />
                    <cms:if k_count ne k_record_to>
                    ,
                    </cms:if>
            </cms:reverse_related_pages>
            ]
        }
    <cms:else />
        false
    </cms:if>
</cms:pages>
<?php COUCH::invoke(); ?>
Hi,

Coming to the second part of your question first -
your original code executed <cms:reverse_related_pages> 100 times (number of places)
Code: Select all
<cms:repeat count=total_places startcount='1' >
    <cms:reverse_related_pages masterpage='subscriptions.php' field='activitysubscription'>
        ...
    </cms:reverse_related_pages>
</cms:repeat>

I'd expect the memory to hold up to this number (unless total memory available to PHP is really low - please check). Regardless, the code was inefficient as the <cms:reverse_related_pages> tag would have fetched exactly the same number of pages at each of the 100 times it gets executed.

To optimize the code, we could have moved the <cms:reverse_related_pages> outside <cms:repeat>, stored the results in an array, and then within the <cms:repeat> loop, checked the values against those in the stored array.

Your second version, in effect, is doing just that. So, I think that it should work without any problem.

Coming to first question you had -
Couch shouldn't create two pages with exactly the same name.
Even if you are not getting the error message (we'll investigate that later), could you please take a look at the admin-panel and see what happens when the page with the duplicate name gets created from the frontend form. Does the new page appear in the admin-panel? If so, what does it show in the name field?

Please let me know.
12 posts Page 2 of 2