Forum

Thread tagged as: Error

Perch 3.0 - Bug - perch_content_create() wiped all data?

Hi,

This morning I think I uncovered a potential bug - I was updating a subsection of a client website domain.com/coreproduce/ which contains 4 pages:

  1. index.php
  2. potatoes.php
  3. onions.php
  4. carrots.php

I was adding a new line to the later 3 pages.

<?php perch_layout('product-forms'); ?>

The Product Forms layout php looks like this:

<section id="ProductForms">
    <div class="flex">
        <div class="form">
            <h3>Download Brochure?</h3>
            <?php
                perch_content_create('Download', array(
                    'template' => 'download.html',
                    'searchable' => false,
                ));

                PerchSystem::set_var('action', $_SERVER[REQUEST_URI]);
                perch_content_custom('Download', array(
                    'template'=>'download.html'
                ));
            ?>
        </div>
        <div class="form">
            <h3>Want to know more?</h3>
            <?php perch_form('default.html'); ?>
        </div>
    </div>

</section>

Upon applying the update and visiting the pages all 4 pages lost their content / template information stored within the CMS meaning that it had to be reinput.

The same update was applied just before in another section with an almost identical structure and nothing unusual happened and everything updated as expected.

My gut instinct is that perch_content_create() somehow reset the section?

Thanks

Jason

Jason Fuller

Jason Fuller 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

That doesn't sound likely. What does debug output?

Hi Drew,

See below

index.php

Debug Message - Perch 3.0.1
[1] SELECT u.*, r.* FROM perch3_users u, perch3_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='595bb412cce9c850a116f06d2b97ee92' LIMIT 1
UPDATE perch3_users SET userHash='8c4d32c097433b027a955340468b6e63' WHERE userID='1'
[38] SELECT p.privKey FROM perch3_user_privileges p
[24] SELECT settingID, settingValue, userID FROM perch3_settings WHERE userID=1 OR userID=0 ORDER BY userID ASC
[8] SELECT itemValue FROM perch3_menu_items WHERE itemType='app'
[1] SELECT * FROM perch3_pages WHERE pageID=95 LIMIT 1
[2] SELECT SQL_CALC_FOUND_ROWS DISTINCT * FROM perch3_content_regions WHERE pageID=95 AND regionPage!='*' ORDER BY regionOrder ASC LIMIT 0, 100
[2] SELECT FOUND_ROWS() AS `count`
[1] SELECT * FROM perch3_menu_items WHERE itemActive=1 AND itemType='menu' AND parentID=0 ORDER BY itemOrder ASC LIMIT 0, 1
[3] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=1 ORDER BY mi.itemOrder ASC
[1] SELECT itemTitle FROM perch3_menu_items WHERE itemType='app' AND itemValue='content' LIMIT 1
[1] SELECT * FROM perch3_menu_items WHERE itemActive=1 AND itemType='menu' AND parentID=0 ORDER BY itemOrder ASC LIMIT 1, 10
[2] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=2 ORDER BY mi.itemOrder ASC
File: /core/apps/content/modes/page.post.php
[1] SELECT COUNT(*) FROM perch3_content_items WHERE itemJSON!='' AND regionID=308 AND itemRev=2
[1] SELECT COUNT(*) FROM perch3_content_items WHERE itemJSON!='' AND regionID=309 AND itemRev=4
Queries: 16
Memory: 0.7315

potatoes.php

Debug Message - Perch 3.0.1
[1] SELECT u.*, r.* FROM perch3_users u, perch3_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='7f325f70be81f75312d0c8894a5d62a6' LIMIT 1
UPDATE perch3_users SET userHash='0f3bcc879feffc5c3c295913e5bf168d' WHERE userID='1'
[38] SELECT p.privKey FROM perch3_user_privileges p
[24] SELECT settingID, settingValue, userID FROM perch3_settings WHERE userID=1 OR userID=0 ORDER BY userID ASC
[8] SELECT itemValue FROM perch3_menu_items WHERE itemType='app'
[1] SELECT * FROM perch3_pages WHERE pageID=92 LIMIT 1
[5] SELECT SQL_CALC_FOUND_ROWS DISTINCT * FROM perch3_content_regions WHERE pageID=92 AND regionPage!='*' ORDER BY regionOrder ASC LIMIT 0, 100
[5] SELECT FOUND_ROWS() AS `count`
[1] SELECT * FROM perch3_menu_items WHERE itemActive=1 AND itemType='menu' AND parentID=0 ORDER BY itemOrder ASC LIMIT 0, 1
[3] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=1 ORDER BY mi.itemOrder ASC
[1] SELECT itemTitle FROM perch3_menu_items WHERE itemType='app' AND itemValue='content' LIMIT 1
[1] SELECT * FROM perch3_menu_items WHERE itemActive=1 AND itemType='menu' AND parentID=0 ORDER BY itemOrder ASC LIMIT 1, 10
[2] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=2 ORDER BY mi.itemOrder ASC
File: /core/apps/content/modes/page.post.php
[1] SELECT COUNT(*) FROM perch3_content_items WHERE itemJSON!='' AND regionID=293 AND itemRev=3
[1] SELECT COUNT(*) FROM perch3_content_items WHERE itemJSON!='' AND regionID=294 AND itemRev=1
[1] SELECT COUNT(*) FROM perch3_content_items WHERE itemJSON!='' AND regionID=295 AND itemRev=1
[1] SELECT COUNT(*) FROM perch3_content_items WHERE itemJSON!='' AND regionID=296 AND itemRev=5
[1] SELECT COUNT(*) FROM perch3_content_items WHERE itemJSON!='' AND regionID=297 AND itemRev=1
Queries: 19
Memory: 0.7428

download region (which was generated by layout file mentioned above)

Debug Message - Perch 3.0.1
[1] SELECT u.*, r.* FROM perch3_users u, perch3_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='c150aa685ffabd3559ef5c8221896e56' LIMIT 1
UPDATE perch3_users SET userHash='e59b211a1431a1ec7d2bf07aa5523946' WHERE userID='1'
[38] SELECT p.privKey FROM perch3_user_privileges p
[24] SELECT settingID, settingValue, userID FROM perch3_settings WHERE userID=1 OR userID=0 ORDER BY userID ASC
[8] SELECT itemValue FROM perch3_menu_items WHERE itemType='app'
[1] SELECT * FROM perch3_content_regions WHERE regionID=297 LIMIT 1
[1] SELECT * FROM perch3_pages WHERE pageID='92' LIMIT 1
Using template: /templates/content/download.html
[1] SELECT * FROM perch3_content_items c WHERE c.regionID=297 AND c.itemRev=1 ORDER BY c.itemOrder ASC
Using template: /templates/content/download.html
[1] SELECT * FROM perch3_content_items c WHERE c.regionID=297 AND c.itemRev=1 ORDER BY c.itemOrder ASC
Using template: /templates/content/download.html
Form not posted or did not validate
[1] SELECT * FROM perch3_menu_items WHERE itemActive=1 AND itemType='menu' AND parentID=0 ORDER BY itemOrder ASC LIMIT 0, 1
[3] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=1 ORDER BY mi.itemOrder ASC
[1] SELECT itemTitle FROM perch3_menu_items WHERE itemType='app' AND itemValue='content' LIMIT 1
[1] SELECT * FROM perch3_menu_items WHERE itemActive=1 AND itemType='menu' AND parentID=0 ORDER BY itemOrder ASC LIMIT 1, 10
[2] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=2 ORDER BY mi.itemOrder ASC
File: /core/apps/content/modes/edit.form.post.php
[1] SELECT * FROM perch3_resources WHERE resourceID='354' LIMIT 1
Mode: edit.form
Queries: 16
Memory: 0.928
Drew McLellan

Drew McLellan 2638 points
Perch Support

These are all control panel pages. Are you having a problem with those? Perhaps I misunderstood, but I thought the issue was with a page on your site.

Can you show me the debug from the page that isn't working?

Sorry Drew, My misunderstanding.

Just to clarify the page is now working correctly since the content was re-entered. It was just that when the new layout tag was placed in this section initially it caused the whole section and weirdly the index.php of this section which doesn't have this line to loose all the content.

Debug from potatoes.php

Debug Message - Perch 3.0.1
[1] SELECT * FROM perch3_pages WHERE pagePath='/coreproduce/potatoes.php' LIMIT 1
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
Using sub-template: /templates/pages/attributes/facebook.html
Using sub-template: /templates/pages/attributes/twitter.html
[5] SELECT regionKey, regionHTML FROM perch3_content_regions WHERE regionPage='/coreproduce/potatoes.php' OR regionPage='*' ORDER BY regionPage DESC
[1] SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch3_content_regions WHERE regionKey='Download' AND (regionPage='/coreproduce/potatoes.php' OR regionPage='*')
[1] SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch3_content_index idx JOIN perch3_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch3_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=297 AND idx.itemRev=1)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval, regionID ORDER BY sortval ASC
[1] Using template: /templates/content/download.html
[24] SELECT DISTINCT settingID, settingValue FROM perch3_settings WHERE userID=0
Using template: /templates/forms/default.html
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok. It's probably not going to be possible to debug what happened if you're already back up and running, but since there's no longer a problem we'll leave it there.

No problem - Thanks for your support as always!