Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F773554
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Feb 2, 3:54 PM
Size
9 KB
Mime Type
text/x-diff
Expires
Tue, Feb 4, 3:54 PM (1 h, 44 m)
Engine
blob
Format
Raw Data
Handle
555370
Attached To
rINP In-Portal
in-portal
View Options
Index: trunk/admin/install/upgrades/inportal_check_v1.0.12.php
===================================================================
--- trunk/admin/install/upgrades/inportal_check_v1.0.12.php (nonexistent)
+++ trunk/admin/install/upgrades/inportal_check_v1.0.12.php (revision 1444)
@@ -0,0 +1,106 @@
+<?php
+// !!! do not use variable $rs as record-set;
+ // rid - ResourceId
+
+ $rid_modules=GetModuleArray();
+ foreach($rid_modules as $rid_module_name)
+ {
+ $rid_path=$pathtoroot.$rid_module_name.'admin/include/parser.php';
+ if(file_exists($rid_path)) include_once($rid_path);
+ }
+
+ function dupe_ResourceIDs_check()
+ {
+ global $objModules, $ado;
+
+ // 1. get required info about each module installed
+ $ret=Array();
+ $table_info=$objModules->ExecuteFunction('GetModuleInfo', 'dupe_resourceids');
+
+ foreach($table_info as $module_name => $module_info)
+ {
+ foreach($module_info as $module_sub_info)
+ {
+ $module_sub_info['Module']=$module_name;
+ array_push($ret,$module_sub_info);
+ }
+ }
+
+ // 2. build mega sql joining all tables in on and search resource id throught them
+ $ado->Execute('DROP TABLE IF EXISTS '.GetTablePrefix().'DupeRIDs');
+
+ $sql = Array();
+ $sql_template = 'SELECT %1$s AS ID, \'%1$s\' AS IDField, ResourceId, \'%2$s\' AS TableName, \'%3$s\' AS Module FROM '.GetTablePrefix().'%2$s ';
+ foreach($ret as $sql_part)
+ {
+ $sql[]=sprintf($sql_template,$sql_part['IDField'],$sql_part['Table'],$sql_part['Module']);
+ }
+
+ $module_table=GetTablePrefix().'DupeRIDs ';
+
+ $sql='CREATE TABLE '.$module_table.' '.implode(' UNION ',$sql);
+ $ado->Execute($sql);
+
+ $sql='SELECT ResourceId FROM '.$module_table.' GROUP BY ResourceId HAVING COUNT(*)>1';
+ $duplicate_rids=$ado->GetCol($sql);
+ if(!$duplicate_rids) return;
+
+ $sql='SELECT * FROM '.$module_table.' WHERE ResourceId IN ('.implode(',',$duplicate_rids).') ORDER BY TableName,ResourceId,ID';
+ $rs=$ado->Execute($sql);
+
+ $originals=Array(); // this are originals
+ $dupes=Array(); // this is dupes
+
+ $update_tpl='UPDATE '.GetTablePrefix().'%s SET ResourceId=%s WHERE %s=%s';
+
+ $non_category_items = Array();
+ while(!$rs->EOF)
+ {
+ $rec=&$rs->fields;
+ if( isset($originals[$rec['ResourceId']]) )
+ {
+ // this is dupe
+ $next_id = GetNextResourceId();
+ $update_sql = sprintf($update_tpl,$rec['TableName'],$next_id,$rec['IDField'],$rec['ID']);
+ $ado->Execute($update_sql);
+ $dupes[$next_id] = $rec['ID'];
+ if($rec['Module'] == 'In-Portal') $non_category_items[$next_id] = $rec['ID'];
+ }
+ else
+ {
+ // this is original
+ $originals[ $rec['ResourceId'] ]=$rec['ID'];
+ }
+ $rs->MoveNext();
+ }
+
+ if($dupes)
+ {
+ // find lost+found category
+ global $objCatList;
+ if( !(isset($objCatList) && is_object($objCatList)) ) $objCatList=new clsCatList();
+
+ $cat=$objCatList->GetItemByField('Name','Lost & Found');
+ if( !is_object($cat) )
+ {
+ $cat=&$objCatList->Add(0,'Lost & Found','Lost & Found Items',time(),0,0,2,2,2,0,'','');
+ }
+
+ $cat_id=$cat->UniqueId();
+
+ // move to lost + found category
+ foreach($dupes as $dupe_rid => $dupe_id)
+ {
+ if( !isset($non_category_items[$dupe_rid]) )
+ {
+ $ado->Execute('INSERT INTO '.GetTablePrefix().'CategoryItems VALUES ('.$cat_id.','.$dupe_rid.',1)');
+ }
+ }
+
+ }
+ $ado->Execute('DROP TABLE IF EXISTS '.$module_table);
+ }
+
+ dupe_ResourceIDs_check();
+
+?>
\ No newline at end of file
Property changes on: trunk/admin/install/upgrades/inportal_check_v1.0.12.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/admin/install/upgrades/changelog_1_0_12.txt
===================================================================
--- trunk/admin/install/upgrades/changelog_1_0_12.txt (revision 1443)
+++ trunk/admin/install/upgrades/changelog_1_0_12.txt (revision 1444)
@@ -1,92 +1,93 @@
File in-portal/globals.php changed
File in-portal/admin/browse.php changed
File in-portal/admin/relation_select.php changed
File in-portal/admin/browse/fw_menu.js changed
File in-portal/admin/config/addlang.php changed
File in-portal/admin/help/manual.pdf changed
File in-portal/admin/include/mainscript.php changed
File in-portal/admin/install/inportal_data.sql changed
File in-portal/admin/install/inportal_schema.sql changed
File in-portal/admin/install/langpacks/english.lang changed
File in-portal/admin/install/upgrades/changelog_1_0_12.txt is new
File in-portal/admin/install/upgrades/inportal_check_v1.0.10.php changed
+File in-portal/admin/install/upgrades/inportal_check_v1.0.12.php is new
File in-portal/admin/install/upgrades/inportal_upgrade_v1.0.11.sql changed
File in-portal/admin/install/upgrades/inportal_upgrade_v1.0.12.sql is new
File in-portal/admin/install/upgrades/readme_1_0_12.txt is new
File in-portal/kernel/action.php changed
File in-portal/kernel/frontaction.php changed
File in-portal/kernel/parser.php changed
File in-portal/kernel/startup.php changed
File in-portal/kernel/admin/advanced_view.php changed
File in-portal/kernel/admin/include/help/browse.txt changed
File in-portal/kernel/admin/include/toolbar/advanced_view.php changed
File in-portal/kernel/admin/include/toolbar/browse.php changed
File in-portal/kernel/admin/include/toolbar/editcategory_relationselect.php changed
File in-portal/kernel/admin/include/toolbar/reviews.php changed
File in-portal/kernel/include/category.php changed
File in-portal/kernel/include/customfield.php changed
File in-portal/kernel/include/debugger.php changed
File in-portal/kernel/include/emailmessage.php changed
File in-portal/kernel/include/item.php changed
File in-portal/kernel/include/itemdb.php changed
File in-portal/kernel/include/language.php changed
File in-portal/kernel/include/modlist.php changed
File in-portal/kernel/include/parseditem.php changed
File in-portal/kernel/include/portaluser.php changed
File in-portal/kernel/include/smtp.php changed
File in-portal/kernel/include/usersession.php changed
File in-portal/themes/default/sitemap.tpl is new
File in-portal/themes/default/common/footer.tpl changed
File in-portal/themes/default/common/head.tpl changed
File in-portal/themes/default/index/sitemap_cat_element.tpl is new
File in-portal/themes/default/index/sitemap_subcat_element.tpl is new
File in-portal/themes/default/register/register_form.tpl changed
File in-portal/themes/default/specials/special1.tpl is new
File in-portal/themes/incommerce/index.tpl is new
File in-portal/themes/incommerce/blocks/adv_search.tpl is new
File in-portal/themes/incommerce/blocks/cart_indicator.tpl is new
File in-portal/themes/incommerce/blocks/categories_home.tpl is new
File in-portal/themes/incommerce/blocks/checkout_steps.tpl is new
File in-portal/themes/incommerce/blocks/copyright.tpl is new
File in-portal/themes/incommerce/blocks/credit_cards.tpl is new
File in-portal/themes/incommerce/blocks/current_path.tpl is new
File in-portal/themes/incommerce/blocks/footer.tpl is new
File in-portal/themes/incommerce/blocks/header.tpl is new
File in-portal/themes/incommerce/blocks/login.tpl is new
File in-portal/themes/incommerce/blocks/mailing_list.tpl is new
File in-portal/themes/incommerce/blocks/products.tpl is new
File in-portal/themes/incommerce/blocks/products_featured.tpl is new
File in-portal/themes/incommerce/blocks/products_new_home.tpl is new
File in-portal/themes/incommerce/blocks/products_picks_home.tpl is new
File in-portal/themes/incommerce/blocks/products_recent.tpl is new
File in-portal/themes/incommerce/blocks/products_top_sellers.tpl is new
File in-portal/themes/incommerce/blocks/recommend_site.tpl is new
File in-portal/themes/incommerce/blocks/sub_categories.tpl is new
File in-portal/themes/incommerce/blocks/toolbar.tpl is new
File in-portal/themes/incommerce/img/adv_search.gif is new
File in-portal/themes/incommerce/img/american_express.gif is new
File in-portal/themes/incommerce/img/buy.gif is new
File in-portal/themes/incommerce/img/buy2.gif is new
File in-portal/themes/incommerce/img/delete.gif is new
File in-portal/themes/incommerce/img/logo.gif is new
File in-portal/themes/incommerce/img/master_card.gif is new
File in-portal/themes/incommerce/img/novus.gif is new
File in-portal/themes/incommerce/img/s.gif is new
File in-portal/themes/incommerce/img/visa.gif is new
File in-portal/themes/incommerce/in-commerce/category.tpl is new
File in-portal/themes/incommerce/in-commerce/product.tpl is new
File in-portal/themes/incommerce/in-commerce/shop_cart/billing.tpl is new
File in-portal/themes/incommerce/in-commerce/shop_cart/shipping.tpl is new
File in-portal/themes/incommerce/in-commerce/shop_cart/shop_cart.tpl is new
File in-portal/themes/incommerce/inc/style.css is new
Changes in phrases and events:
Changed label "la_topic_poststopop_prompt" of type "1"
Changed label "la_topic_poststopop_prompt" of type "1"
Changed label "la_news_newstopminrating_prompt" of type "1"
Changed label "la_news_newstopminrating_prompt" of type "1"
Added label "lu_fieldcustom__drop_down" of type "2"
Added label "lu_site_map" of type "0"
Property changes on: trunk/admin/install/upgrades/changelog_1_0_12.txt
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property
Event Timeline
Log In to Comment