Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1101704
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, Aug 17, 2:28 AM
Size
2 KB
Mime Type
text/x-diff
Expires
Tue, Aug 19, 2:28 AM (8 h, 27 m)
Engine
blob
Format
Raw Data
Handle
713574
Attached To
rINP In-Portal
in-portal
View Options
Index: trunk/core/install/upgrades.php
===================================================================
--- trunk/core/install/upgrades.php (revision 8037)
+++ trunk/core/install/upgrades.php (revision 8038)
@@ -1,21 +1,74 @@
<?php
$upgrade_class = 'CoreUpgrades';
/**
* Class, that holds all upgrade scripts for "Core" module
*
*/
class CoreUpgrades extends kHelper {
-
+
/**
* Changes table structure, where multilingual fields of TEXT type are present
*
* @param string $mode when called mode {before, after)
*/
function Upgrade_4_0_2($mode)
{
+ $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper');
+ /* @var $ml_helper kMultiLanguageHelper */
+
+ $lang_count = $ml_helper->getLanguageCount();
+ $this->Application->UnitConfigReader->iterateConfigs( Array (&$this, 'updateTextFields', $lang_count) );
+ }
+
+ /**
+ * Callback function, that makes all ml fields of text type null with same default value
+ *
+ * @param string $prefix
+ * @param Array $config_data
+ * @param int $language_count
+ * @return bool
+ */
+ function updateTextFields($prefix, &$config_data, $language_count)
+ {
+ if (!isset($config_data['TableName']) || !isset($config_data['Fields'])) {
+ // invalid config found or prefix not found
+ return false;
+ }
+
+ $table_name = $config_data['TableName'];
+ $table_structure = $this->Conn->Query('DESCRIBE '.$table_name, 'Field');
+ if (!$table_structure) {
+ // table not found
+ return false;
+ }
+ $sqls = Array ();
+ foreach ($config_data['Fields'] as $field => $options) {
+ if (isset($options['formatter']) && $options['formatter'] == 'kMultiLanguage' && !isset($options['master_field'])) {
+ // update all l<lang_id>_<field_name> fields (new format)
+ for ($i = 1; $i <= $language_count; $i++) {
+ $ml_field = 'l'.$i.'_'.$field;
+ if ($table_structure[$ml_field]['Type'] == 'text') {
+ $sqls[] = 'CHANGE '.$ml_field.' '.$ml_field.' TEXT NULL DEFAULT NULL';
+ }
+ }
+
+ // update <field_name> if found (old format)
+ if (isset($table_structure[$field]) && $table_structure[$field]['Type'] == 'text') {
+ $sqls[] = 'CHANGE '.$field.' '.$field.' TEXT NULL DEFAULT NULL';
+ }
+ }
+ }
+
+ if ($sqls) {
+ $sql = 'ALTER TABLE '.$table_name.' '.implode(', ', $sqls);
+ $this->Conn->Query($sql);
+ }
+
+ return true;
}
+
}
?>
\ No newline at end of file
Property changes on: trunk/core/install/upgrades.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Event Timeline
Log In to Comment