1.How to work/flow applyInApp() in magento? (Magento ver. 1.13.0.2)Class : Enterprise_PageCache_Model_Container_Abstract

/** This function generate and apply container content in controller after application is initialized **/

   public function applyInApp(&$content)    [Line No : 1] 
    {
        $blockContent = $this->_renderBlock();      [Line No : 2]
        if ($blockContent === false) {     [Line No : 3]
            return false;
        }
       if (Mage::getStoreConfig(Enterprise_PageCache_Model_Processor::XML_PATH_CACHE_DEBUG)) {
 [Line No : 4] 
            $debugBlock = new Enterprise_PageCache_Block_Debug();
            $debugBlock->setDynamicBlockContent($blockContent);
            $debugBlock->setTags($this->_getPlaceHolderBlock()->getCacheTags());
            $debugBlock->setType($this->_placeholder->getName());
            $this->_applyToContent($content, $debugBlock->toHtml());
        } else {
          $this->_applyToContent($content, $blockContent);   [Line No : 5]
        }

        $subprocessor = $this->_processor->getSubprocessor();  [Line No : 6]
        if ($subprocessor) {
            $contentWithoutNestedBlocks =           [Line No : 7]
            $subprocessor->replaceContentToPlaceholderReplacer($blockContent);    [Line No : 8]
            $this->saveCache($contentWithoutNestedBlocks);   [Line No : 9]
        }

        return true;
    }

Purpose of function applyInApp() :

When applyWithoutApp($content) is not able to fetch the block contents from cache, for that purpose block contents need to initialize application even when rest of the page is already found in full page cache. Full page cache set the request and the Magento application initialization and routing is followed.

The front controller request to the RequestController::processAction() method.
The method fetches the previously initialized container class for the dynamic block, and calls applyInApp($content).

This method runs $this->_renderBlock() to render block contents from placeholder and shows the page.

Stack for applyInApp ()

mage-ent-test/app/code/core/Enterprise/PageCache/Model/Container/
Abstract.php.Enterprise_PageCache_Model_Container_Abstract->applyInApp : lineno 124()

mage-ent-test/app/code/core/Enterprise/PageCache/controllers/
RequestController.php.Enterprise_PageCache_RequestController->processAction : lineno 38()

mage-ent-test/app/code/core/Mage/Core/Controller/Varien/
Action.php.Mage_Core_Controller_Varien_Action->dispatch : lineno 418()

mage-ent-test/app/code/core/Mage/Core/Controller/Varien/Router/
Standard.php.Mage_Core_Controller_Varien_Router_Standard->match : lineno 250()

mage-ent-test/app/code/core/Mage/Core/Controller/Varien/
Front.php.Mage_Core_Controller_Varien_Front->dispatch : lineno 172()

mage-ent-test/app/code/core/Mage/Core/Model/App.php.Mage_Core_Model_App->run : lineno 354()

mage-ent-test/app/Mage.php.Mage::run : lineno 683()

mage-ent-test/index.php.{main} : lineno 87()

applyInApp() function call for two containers

$containers = array[2]
[0] = Enterprise_PageCache_Model_Container_Catalognavigation
[1] = Enterprise_PageCache_Model_Container_Sidebar_Poll

Sample data for function : applyInApp () for class

Enterprise_PageCache_Model_Container_Catalognavigation

[Line No : 1]$content =
some content …………………………

</div>
<p class="welcome-msg">Default welcome msg!></p>
    <ul class="links">
            <li class="first" ><a href="http://localhost/oscp-store/mage-ent- 
                          test/customer/account/login/" title="Log In" >Log In</a>&</li>
           <li class=" last" > or <a href="http://localhost/oscp-store/mage-ent-
                               test/customer/account/create/" title="register" >register</a>.</li>
           </ul>
</div>
<!--{TOPMENU container="Enterprise_PageCache_Model_Container_Catalognavigation"   block="Mage_Page_Block_Html_Topmenu" cache_id="2c1ade7cb687f833f35fccbe8672da94de75af2e" cache_lifetime="86400" template="page/html/topmenu.phtml" name="catalog.topnav" entity_key="1/3/10/22" short_cache_id="14b4590a0f18236983beae282f8d6aa6"}-->
<!--{POLL container="Enterprise_PageCache_Model_Container_Sidebar_Poll" block="Mage_Poll_Block_ActivePoll" cache_id="feaadbf853e3113eeb0920254c977017e09110e2" cache_lifetime="86400" template="poll/active.phtml" templates="a:2:{s:4:"poll";s:17:"poll/active.phtml";s:7:"results";s:17:"poll/result.phtml";}"}-->

some content …………………………

[Line No : 2] $blockContent :

<ul id="nav">
<li  class="level0 nav-1 first active level-top parent">
<a href="http://localhost/oscp-store/mage-ent-test/furniture"  class="level-top" ><span>Furniture</span></a>
<ul class="level0"><li  class="level1 nav-1-1 first active">
<a href="http://localhost/oscp-store/mage-ent-test/furniture/living-room"><span>Living Room</span></a></li>
<li  class="level1 nav-1-2 last"><a href="http://localhost/oscp-store/mage-ent-test/furniture/bedroom" ><span>Bedroom</span></a>
</li></ul>
</li>
<li  class="level0 nav-2 level-top parent">
<a href="http://localhost/oscp-store/mage-ent-test/electronics"  class="level-top" ><span>Electronics</span></a>
<ul class="level0"><li  class="level1 nav-2-1 first">
<a href="http://localhost/oscp-store/mage-ent-test/electronics/cell-phones" ><span>Cell Phones</span></a></li>
<li  class="level1 nav-2-2 parent"><a href="http://localhost/oscp-store/mage-ent-test/electronics/cameras"><span>Cameras</span></a>
<ul class="level1"><li  class="level2 nav-2-2-1 first">
<a href="http://localhost/oscp-store/mage-ent-test/electronics/cameras/accessories" ><span>Accessories</span></a></li>
<li  class="level2 nav-2-2-2 last"><a href="http://localhost/oscp-store/mage-ent-test/electronics/cameras/digital-cameras" ><span>Digital Cameras</span></a></li>
</ul></li>
<li  class="level1 nav-2-3 last parent">
<a href="http://localhost/oscp-store/mage-ent-test/electronics/computers" ><span>Computers</span></a>
<ul class="level1"><li  class="level2 nav-2-3-1 first">
<a href="http://localhost/oscp-store/mage-ent-test/electronics/computers/build-your-own" ><span>Build Your Own</span></a></li>
<li  class="level2 nav-2-3-2"><a href="http://localhost/oscp-store/mage-ent-test/electronics/computers/laptops"><span>Laptops</span></a></li>
<li  class="level2 nav-2-3-3"><a href="http://localhost/oscp-store/mage-ent-test/electronics/hard-drives" ><span>Hard Drives</span></a></li>
<li  class="level2 nav-2-3-4"><a href="http://localhost/oscp-store/mage-ent-test/electronics/monitors" ><span>Monitors</span></a></li>
<li  class="level2 nav-2-3-5"><a href="http://localhost/oscp-store/mage-ent-test/electronics/ram-memory"><span>RAM / Memory</span></a></li>
<li  class="level2 nav-2-3-6"><a href="http://localhost/oscp-store/mage-ent-test/electronics/cases" ><span>Cases</span></a></li>
<li  class="level2 nav-2-3-7"><a href="http://localhost/oscp-store/mage-ent-test/electronics/processors" ><span>Processors</span></a>

[Line No : 5]
$content : Here showing topmenu contents with the pattern of starting tag and ending tag

<!--{TOPMENU_af42519c18e9db64e7d32c6861bdbec7}-><div class="nav-container">
<ul id="nav">
<li  class="level0 nav-1 first active level-top parent">
<a href="http://localhost/oscp-store/mage-ent-test/furniture"  class="level-top" ><span>Furniture</span></a>
<ul class="level0"><li  class="level1 nav-1-1 first active">
<a href="http://localhost/oscp-store/mage-ent-test/furniture/living-room"><span>Living Room</span></a></li>
<li  class="level1 nav-1-2 last"><a href="http://localhost/oscp-store/mage-ent-test/furniture/bedroom"><span>Bedroom</span></a>
</li></ul>
</li>
<li  class="level0 nav-2 level-top parent">
<a href="http://localhost/oscp-store/mage-ent-test/electronics"  class="level-top" ><span>Electronics</span></a>
<ul class="level0"><li  class="level1 nav-2-1 first">
<a href="http://localhost/oscp-store/mage-ent-test/electronics/cell-phones" ><span>Cell Phones</span>Cameras</span></a>
<ul class="level1"><li  class="level2 nav-2-2-1 first">
<a href="http://localhost/oscp-store/mage-ent-test/electronics/cameras/accessories" ><span>Accessories</span></a></li>
<li  class="level2 nav-2-2-2 last"><a href="http://localhost/oscp-store/mage-ent-test/electronics/cameras/digital-cameras" ><span>Digital Cameras</span></a></li>
</ul></li>
<li  class="level1 nav-2-3 last parent">
<a href="http://localhost/oscp-store/mage-ent-test/electronics/computers" ><span>Computers</span></a>
<ul class="level1"><li  class="level2 nav-2-3-1 first">
<a href="http://localhost/oscp-store/mage-ent-test/electronics/computers/build-your-own" ><span>Build Your Own</a></li>
<li  class="level2 nav-2-3-2"><a href="http://localhost/oscp-store/mage-ent-test/electronics/computers/laptops"><span>Laptops<a href="http://localhost/oscp-store/mage-ent-test/electronics/hard-drives" >Hard Drives</a>

<li class=”level2 nav-2-3-4″><a href=”http://localhost/oscp-store/mage-ent-test/electronics/monitors”><span>Monitors</span></a></li> <li class=”level1 nav-2-3 last parent”> <a href=”http://localhost/oscp-store/mage-ent-test/electronics/computers” ><span>Computers</span></a> <ul class=”level1″><li class=”level2 nav-2-3-1 first”> <a href=”http://localhost/oscp-store/mage-ent-test/electronics/computers/build-your-own” ><span>Build Your Own</span></a></li> <li class=”level2 nav-2-3-2″><a href=”http://localhost/oscp-store/mage-ent-test/electronics/computers/laptops” ><span>Laptops</span></a></li> <li class=”level2 nav-2-3-3″><a href=”http://localhost/oscp-store/mage-ent-test/electronics/hard-drives”><span>Hard Drives</span></a></li> <li class=”level2 nav-2-3-4″><a href=”http://localhost/oscp-store/mage-ent-test/electronics/monitors” ><span>Monitors</span></a></li> <li class=”level2 nav-2-3-5″><a href=”http://localhost/oscp-store/mage-ent-test/electronics/ram-memory” ><span >RAM / Memory</span ></a></li> <li class=”level2 nav-2-3-6″><a href=”http://localhost/oscp-store/mage-ent-test/electronics/cases” ><span>Cases</span></a></li> <li class=”level2 nav-2-3-7″><a href=”http://localhost/oscp-store/mage-ent-test/electronics/processors” ><span>Processors</span></a></li> <li class=”level2 nav-2-3-8 last”><a href=”http://localhost/oscp-store/mage-ent-test/electronics/peripherals”><span>Peripherals</span></a></li> </ul></li> </ul></li></ul>

[Line No : 6]
$subprocessor = Enterprise_PageCache_Model_Processor_Category

[Line No : 9]
$this = Enterprise_PageCache_Model_Container_Catalognavigation

  • $_processor = Enterprise_PageCache_Model_Processor	
    		$_requestId  = localhost/oscp-store/mage-ent-test/furniture/living-room	
    		$_requestCacheId = REQEST_3df7a0ae168d5737abfb79482946350f	
    		$_requestTags = Array [1]
    			       [0]= fpc
    		$_metaData = Array [8]	
    	                cache_subprocessor = Enterprise_PageCache_Model_Processor_Category	
    	                catalog_category_id = 22	
    	                response_headers = Array [2]	
    		     routing_aliases = Array [1]	
    		     routing_requested_route = catalog	
    		     routing_requested_controller = category	
    	                routing_requested_action = view	
    		     sid_cookie_name = frontend	
    
    		$_designExceptionExistsInCache = 1407744214	
    		$_requestProcessor = 	
    		$_subprocessor = Enterprise_PageCache_Model_Processor_Category
  • $_placeholder = Enterprise_PageCache_Model_Container_Placeholder

    $_definitionMap = Array [13]

    WELCOME_e55e974aa0f258c6459ff9c5c304650b = WELCOME container=”Enterprise_PageCache_Model_Container_Welcome” block=”Mage_Page_Block_Html_Welcome” cache_id=”bf3668918d4f26657cdbfe6550c62f39a86211ba” cache_lifetime=”2″ template=””

    ACCLINKS_a799cfcb0f7186a8890e62c44be35df8 = ACCLINKS container=”Enterprise_PageCache_Model_Container_Accountlinks” block=”Mage_Page_Block_Template_Links” cache_id=”b8f9b3383abc7a26a71bfdc86c4a9d5bff6e3693″ cache_lifetime=”14400″ template=”page/template/links.phtml” links=”” name=”account.links”

    CART_SIDEBAR_ccd944c424b10c67d0f564f5cd4534e0 = CART_SIDEBAR container=”Enterprise_PageCache_Model_Container_Sidebar_Cart” block=”Mage_Checkout_Block_Cart_Sidebar” cache_id=”3ee95d5974c12590e902688083b2097637487b5d” cache_lifetime=”86400″ template=”checkout/cart/cartheader.phtml” item_renders=”default|checkout/cart_item_renderer|checkout/cart/sidebar/default.phtml|simple|checkout/cart_item_renderer|checkout/cart/sidebar/default.phtml|grouped|checkout/cart_item_renderer_grouped|checkout/cart/sidebar/default.phtml|configurable|checkout/cart_item_renderer_configurable|checkout/cart/sidebar/default.phtml|bundle|bundle/checkout_cart_item_renderer|checkout/cart/sidebar/default.phtml”

    WISHLISTLINKS_2aacb34d580ee7a80664f8eb4e97a5dc = WISHLISTLINKS container=”Enterprise_PageCache_Model_Container_Wishlistlinks” block=”Enterprise_Wishlist_Block_Links” cache_id=”7ac999da79a72413ae6eccac0959315c33f886fa” cache_lifetime=”86400″ template=”page/template/linksblock.phtml”

    GLOBAL_MESSAGES_aae3749ba9c2e308ffa9c240ac185959 = GLOBAL_MESSAGES container=”Enterprise_PageCache_Model_Container_Messages” block=”Mage_Core_Block_Messages” cache_id=”ef4266def0c9e841338aa82b69f010e6fbfb6079″ cache_lifetime=”86400″ storage_types=”a:1:{i:0;s:12:”core/session”;}”

    MESSAGES_5c12d9044af2fcdbff09809e4bf847db = MESSAGES container=”Enterprise_PageCache_Model_Container_Messages” block=”Mage_Core_Block_Messages” cache_id=”5b3dd32f8b360ff5aed2122d085c17ee46600383″ cache_lifetime=”86400″ storage_types=”a:3:{i:0;s:12:”core/session”;i:1;s:15:”catalog/session”;i:2;s:16:”checkout/session”;}”

    VIEWED_PRODUCTS_1ce9ca4562e882280a7ec73cffd0ee6f =VIEWED_PRODUCTS container=”Enterprise_PageCache_Model_Container_Viewedproducts” block=”Mage_Reports_Block_Product_Viewed” cache_id=”be2dfae752d351b68c3abdbd171ef94e0bc96ba7″ cache_lifetime=”86400″ template=”reports/product_viewed.phtml”

    COMPARELIST_SIDEBAR_ede9c0d7caf456a3087c8f697d76e0e8 = COMPARELIST_SIDEBAR container=”Enterprise_PageCache_Model_Container_Sidebar_Comparelist” block=”Mage_Catalog_Block_Product_Compare_Sidebar” cache_id=”d1a49345fbc58ac57be876cd890779d5c2081aeb” cache_lifetime=”86400″ template=”catalog/product/compare/sidebar.phtml” RECENTLYCOMPARED_SIDEBAR_9e01c4074f7a0f60735fd24ecf101069 = RECENTLYCOMPARED_SIDEBAR container=”Enterprise_PageCache_Model_Container_Sidebar_Recentlycompared” block=”Mage_Reports_Block_Product_Compared” cache_id=”a3f5a714387eb2056dc1a2eeb7d35fa365cbab8b” cache_lifetime=”86400″ template=”reports/product_compared.phtml”

    WISHLIST_c9a378697770624b35e97a92edb3a62b = WISHLIST container=”Enterprise_PageCache_Model_Container_Wishlist” block=”Enterprise_Wishlist_Block_Customer_Sidebar” cache_id=”7e20b8be3ad3f09da8d9959ccc41fd96ffaced01″ cache_lifetime=”86400″ template=”wishlist/sidebar.phtml”

    ORDERS_4d335e1e77f34918975962c57188745a = ORDERS container=”Enterprise_PageCache_Model_Container_Orders” block=”Mage_Sales_Block_Reorder_Sidebar” cache_id=”84bda5539caea745fe0c812ec240b2893090ddd7″ cache_lifetime=”86400″ template=”sales/reorder/sidebar.phtml”

    WISHLISTS_ab717b0bfcc6c0c5acca8eb5c9becd44 WISHLISTS container=”Enterprise_PageCache_Model_Container_Wishlists” block=”Enterprise_Wishlist_Block_Behaviour” cache_id=”1150a5209c9b5890af3d687df7e0d8ea1811b4d9″ cache_lifetime=”86400″ template=”wishlist/behaviour.phtml”

    TOPMENU_af42519c18e9db64e7d32c6861bdbec7 = TOPMENU container=”Enterprise_PageCache_Model_Container_Catalognavigation” block=”Mage_Page_Block_Html_Topmenu” cache_id=”2c1ade7cb687f833f35fccbe8672da94de75af2e” cache_lifetime=”86400″ template=”page/html/topmenu.phtml” name=”catalog.topnav” entity_key=”1/3/10/22″ short_cache_id=”14b4590a0f18236983beae282f8d6aa6″

    $_definition = TOPMENU container=”Enterprise_PageCache_Model_Container_Catalognavigation” block=”Mage_Page_Block_Html_Topmenu” cache_id=”2c1ade7cb687f833f35fccbe8672da94de75af2e” cache_lifetime=”86400″ template=”page/html/topmenu.phtml” name=”catalog.topnav” entity_key=”1/3/10/22″ short_cache_id=”14b4590a0f18236983beae282f8d6aa6″ $_name = TOPMENU

    $_attributes = Array [8] container = Enterprise_PageCache_Model_Container_Catalognavigation block = Mage_Page_Block_Html_Topmenu cache_id = 2c1ade7cb687f833f35fccbe8672da94de75af2e cache_lifetime = 86400 template = page/html/topmenu.phtml name = catalog.topnav entity_key = 1/3/10/22 short_cache_id = 14b4590a0f18236983beae282f8d6aa6

  • $_placeholderBlock = Mage_Page_Block_Html_Topmenu

Flowchart of function applyInApp():

magento fpc applyInApp function