We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26503
    • 620 Posts
    hmmmm I’ve got a strange caching issue after I updated - I’m not 100% sure this was NOT happening before the update however...

    I have a chunk that only logged in users are supposed to see, called from a template like this:
    [[!If? &subject=`[[getGroups]]` &operator=`==` &operand=`true` &then=`[[$OncologistSearch]]`]]
    


    The snippet is a simple thing to determine the user group [can I do this by ID somehow??]
    <?php
    	
    	$output = 'false';     
    	if($modx->user->isMember(array('Canadian Medical Oncologists','Canadian Resident'))){
    		$output = 'true';
    	}
    
    return $output;
    



    the chunk is a simple html form:
    <div id="oncologist-search" class="call-out">
    	<h3>Oncologist Database Search</h3>
    	<form name="oncologist-search" action="[[~350]]" method="post" >
    		<ul>
    			<li class="search-icon"></li>
    			<li class="search-terms">
    				<input type="text" name="name" value="" maxlength="50" class="text-input" />
    				</li>
    			<li class="search-submit">
    				<input type="submit" name="search-oncologists" value=" " class="submit-input" />
    			</li>
    			<li class="advanced-search">
    				<a href="[[~350]]" >Advanced Search</a>
    			</li>
    		</ul>
    	</form>
    </div>
    





    So the problem is that the chunk is getting cached along with the page, i.e. a logged in user in location A loads the page & sees the chunk, modx has then cached the page with the chunk in place. Then in location B an anonymous user loads that page, gets the cached version from modx & is able to see the chunk. They can’t do anything with it, if they try to search they get the 0401 error [which is correct] but they are not supposed to be able to even see the chunk at all!


    Any thoughts on how to get around this?

    -thanks
    -sean





      *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

      Sean Kimball CLP, CLS.
      Technical Director / Sr. Developer | BigBlock Studios
      ._______________________________________________.
      Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
      27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
      phone/fax: 905-426-5525
      • 21838
      • 284 Posts
      I don’t have a solution for you. There are some caching bugs in 2.1.1 unfixed. I already mentioned some in the bugtracker. Hope 2.1.2 follows soon and stable!
        MODX Free Template Base: MODX-Boilerplate | my blog (lots of MODX stuff) | my gitHub (translations) | MODX User Groups Germany (Facebook)
        • 26503
        • 620 Posts
        can you provide a link to your bug posting? ... maybe I can find some info to add.
          *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

          Sean Kimball CLP, CLS.
          Technical Director / Sr. Developer | BigBlock Studios
          ._______________________________________________.
          Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
          27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
          phone/fax: 905-426-5525
          • 22303 MODX Staff
          • 10,725 Posts
          There are no known caching bugs that I have confirmed. You need to not cache the getGroups call or everyone visiting the cached page will have the first value returned by that Snippet, regardless if the If is non-cacheable.
            • 26503
            • 620 Posts
            hmmmm just gave this a try [silly oversight]

            [[!If? &subject=`[[!getGroups]]` &operator=`==` &operand=`true` &then=`[[$OncologistSearch]]`]]
            


            I’m still getting the call out cached. should I be doing something in the snippet itself?

            -thanks
            -sean
              *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

              Sean Kimball CLP, CLS.
              Technical Director / Sr. Developer | BigBlock Studios
              ._______________________________________________.
              Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
              27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
              phone/fax: 905-426-5525
              • 22303 MODX Staff
              • 10,725 Posts
              Would be better IMO to have a Snippet called OncologistSearch and let it check the membership of the User and render the chunk only if they are. Still not sure how you would be seeing the cached version though. Are you sure you are not viewing this in a browser while logged into the manager in the same browser session? In that case, the manager user is actually loaded, not the anonymous account with user id of 0.
                • 26503
                • 620 Posts
                Quote from: OpenGeek at Jun 14, 2011, 02:49 PM

                Would be better IMO to have a Snippet called OncologistSearch and let it check the membership of the User and render the chunk only if they are. Still not sure how you would be seeing the cached version though. Are you sure you are not viewing this in a browser while logged into the manager in the same browser session? In that case, the manager user is actually loaded, not the anonymous account with user id of 0.

                Hmmm I’ll give the snippet idea a try [shouldn’t take long] - but this actually popped up during cross browser testing, I generally use chrome for the admin/dev stuff then IE/FF/Safari for the front end.

                I have also noticed that I have to empty the cache twice from the admin->site->clear cache menu, 1st time the little window does nothing, cancel it and clear cache again & the cache gets cleared... [!] - luckily I have shell access & can dump the entire core/cache directory to be sure but - I thought that was odd as well.

                -sean

                *UPDATE*

                Thanks - this is a much sexier solution & works perfectly - caching is behaving properly now, & the extra !If processing is no longer needed.

                calling the new snippet like this:
                     [[!ShowOncologistSearch]]
                


                The new snippet itself:
                <?php
                	
                     $output = false;     
                	if($modx->user->isMember(array('Canadian Medical Oncologists','Canadian Resident'))){
                		$output = $modx->getChunk('OncologistSearch');
                	}
                
                     return $output;
                


                ~the chunk itself was not modified.

                Maybe it was a problem with If & caching? I’ve used If in a couple other places, but noticed no oddities....


                -thanks a bunch!
                -sean
                  *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

                  Sean Kimball CLP, CLS.
                  Technical Director / Sr. Developer | BigBlock Studios
                  ._______________________________________________.
                  Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
                  27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
                  phone/fax: 905-426-5525