TYPO3 CMS  TYPO3_6-2
FileTableSplittingUpdate.php
Go to the documentation of this file.
1 <?php
3 
24 
29  protected $metaDataTable = 'sys_file_metadata';
30 
34  protected $title = 'Migrate file metadata from sys_file to an external metadata table';
35 
42  public function checkForUpdate(&$description) {
43  $result = FALSE;
44 
45  $description = 'In TYPO3 CMS 6.2 LTS the metadata has been split off to an external table. This wizard will migrate the data. If you have extended the sys_file table manually your custom data will be included, too, if you create TCA and columns in sys_file_metadata before running this wizard.';
46 
47  if (!array_key_exists($this->metaDataTable, $GLOBALS['TYPO3_DB']->admin_get_tables())) {
48  $result = TRUE;
49  } else {
50  $fields = $GLOBALS['TYPO3_DB']->admin_get_fields('sys_file');
51  // Check if the field exists on sys_file if not there is no data to migrate (TYPO3 < 6.0 or >= 6.2)
52  if (isset($fields['width']) && isset($fields['height'])) {
53  // Check if the 1:1 integrity is ok, if not we need to migrate the metadata.
54  $sysFileCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'sys_file');
55  $sysFileMetaDataCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', $this->metaDataTable);
56  $result = $sysFileCount > $sysFileMetaDataCount;
57  }
58  }
59 
60  return $result;
61  }
62 
72  public function performUpdate(array &$dbQueries, &$customMessages) {
73 
74  if (!array_key_exists($this->metaDataTable, $GLOBALS['TYPO3_DB']->admin_get_tables())) {
75  $customMessages = 'ERROR! Make sure you already created the table. If you added custom metadata to sys_file table add TCA ' .
76  'configuration as well as SQL definitions to sys_file_metadata, too.';
77  return FALSE;
78  }
79 
80  $fieldsToMigrate = $this->detectFieldsToMigrate();
81  if (empty($fieldsToMigrate)) {
82  return TRUE;
83  }
84  $fieldsToWrite = $fieldsToMigrate;
85  $fieldsToWrite[] = 'file';
86  $fieldsToSelect = $fieldsToMigrate;
87  $fieldsToSelect[] = 'uid AS file';
88 
89  $resultObject = $GLOBALS['TYPO3_DB']->sql_query(
90  'INSERT INTO ' . $this->metaDataTable . ' (' . implode(',', $fieldsToWrite) . ')' .
91  ' SELECT ' . implode(',', $fieldsToSelect) .
92  ' FROM sys_file' .
93  ' WHERE uid NOT IN (SELECT file FROM ' . $this->metaDataTable . ')');
94 
95  return $resultObject !== FALSE;
96  }
97 
104  protected function detectFieldsToMigrate() {
105  $fieldsBlackListed = array('uid', 'deleted', 'sys_language_uid');
106  $fieldsInSysFile = array_keys($GLOBALS['TYPO3_DB']->admin_get_fields('sys_file'));
107  $fieldsInSysFileMetaData = array_keys($GLOBALS['TYPO3_DB']->admin_get_fields($this->metaDataTable));
108 
109  $commonFields = array_intersect($fieldsInSysFileMetaData, $fieldsInSysFile);
110  $commonFields = array_diff($commonFields, $fieldsBlackListed);
111 
112  return $commonFields;
113 
114  }
115 }
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]