=') && version_compare(phpversion(), '5.5.0', '<'))) { die('PHP 5.3.x - 5.4.x required (Your version ' . phpversion() . ').'); } require_once '_lib/_sys/init.php'; $db = Qs_Db::getInstance(); printnl('STARTED'); patchHtmlBlockContent(); patchHtmlBlockContent(true); patchTable('News', 'content'); patchTable('Faq', 'answer'); patchTable('GalleryCategory', 'description'); patchTable('Product', 'description'); printnl('FINISH'); /* Functions */ function printnl($text) { echo date('Y-m-d H:i:s'), ' - ', $text, '
', PHP_EOL; flush(); ob_flush(); return true; } function patchHtmlBlockContent($isDraft = false) { global $db; $tableAlias = (($isDraft) ? 'Draft' : '') . 'HtmlBlockContent'; printnl($tableAlias); $tableName = Qs_Db::getTableName($tableAlias); $table = new Qs_Db_Table(array('name' => $tableName)); $select = $db->select(); $select->from($tableName, array('idBlock', 'language', 'content')); $statement = $select->query(); foreach ($statement as $row) { $rawContent = Qs_Text_Mark::prepareSearchText($row, array('content')); if ('' != $rawContent) { $key = array('idBlock' => $row['idBlock'], 'language' => $row['language']); $data = array('rawContent' => $rawContent); $table->updateDataByKey($data, $key); } } return true; } function patchTable($tableAlias, $contentField, $rawContentField = null) { global $db; printnl($tableAlias); $tableName = Qs_Db::getTableName($tableAlias); if (!$tableName) { throw new Qs_Exception('Table not found.'); } if (null === $rawContentField) { $rawContentField = 'raw' . ucfirst($contentField); } $table = new Qs_Db_Table(array('name' => $tableName)); $select = $db->select(); $select->from($tableName, array('id', $contentField)); $statement = $select->query(); foreach ($statement as $row) { $rawContent = Qs_Text_Mark::prepareSearchText($row, array($contentField)); if ('' != $rawContent) { $table->updateDataByKey(array($rawContentField => $rawContent), $row['id']); } } return true; }