Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new update task file; update draft field value from '0' to NULL
- Loading branch information
Showing
1 changed file
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
<?php | ||
|
||
/** | ||
* Project: Welcompose | ||
* File: 0001-014.php | ||
* | ||
* Copyright (c) 2009 creatics | ||
* | ||
* Project owner: | ||
* creatics, Olaf Gleba | ||
* 50939 Köln, Germany | ||
* http://www.creatics.de | ||
* | ||
* This file is licensed under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE v3 | ||
* http://www.opensource.org/licenses/agpl-v3.html | ||
* | ||
* @copyright 2011 creatics, Olaf Gleba | ||
* @author Olaf Gleba | ||
* @package Welcompose | ||
* @license http://www.opensource.org/licenses/agpl-v3.html GNU AFFERO GENERAL PUBLIC LICENSE v3 | ||
*/ | ||
|
||
// get loader | ||
$path_parts = array( | ||
dirname(__FILE__), | ||
'..', | ||
'..', | ||
'core', | ||
'loader.php' | ||
); | ||
$loader_path = implode(DIRECTORY_SEPARATOR, $path_parts); | ||
require($loader_path); | ||
|
||
// start base | ||
/* @var $BASE base */ | ||
$BASE = load('base:base'); | ||
|
||
// deregister globals | ||
$deregister_globals_path = dirname(__FILE__).'/../../core/includes/deregister_globals.inc.php'; | ||
require(Base_Compat::fixDirectorySeparator($deregister_globals_path)); | ||
|
||
try { | ||
// start output buffering | ||
@ob_start(); | ||
|
||
// load smarty | ||
$smarty_update_conf = dirname(__FILE__).'/../smarty.inc.php'; | ||
$BASE->utility->loadSmarty(Base_Compat::fixDirectorySeparator($smarty_update_conf), true); | ||
|
||
// load gettext | ||
$gettext_path = dirname(__FILE__).'/../../core/includes/gettext.inc.php'; | ||
include(Base_Compat::fixDirectorySeparator($gettext_path)); | ||
gettextInitSoftware($BASE->_conf['locales']['all']); | ||
|
||
// start Base_Session | ||
/* @var $SESSION session */ | ||
$SESSION = load('base:session'); | ||
|
||
// connect to database | ||
$BASE->loadClass('database'); | ||
|
||
// define major/minor task number | ||
define('TASK_MAJOR', '0001'); | ||
define('TASK_MINOR', '014'); | ||
|
||
// get schema version from database | ||
$sql = " | ||
SELECT | ||
`schema_version` | ||
FROM | ||
".WCOM_DB_APPLICATION_INFO." | ||
LIMIT | ||
1 | ||
"; | ||
$version = $BASE->db->select($sql, 'field'); | ||
list($major, $minor) = explode('-', $version); | ||
|
||
/* | ||
* References | ||
* ---------- | ||
* | ||
* Changeset: no decent allocation possible | ||
* | ||
* Changes to be applied | ||
* --------------------- | ||
* | ||
* - Update table content_pages row 'draft' => Set from '0' to NULL | ||
* This is required for all Welcompose Installations below 0.9.4 as | ||
* we introduce a different handling on function 'exclude' and 'draft' | ||
* with 0.9.4 | ||
*/ | ||
if ($major < TASK_MAJOR || ($major == TASK_MAJOR && $minor < TASK_MINOR)) { | ||
try { | ||
// begin transaction | ||
$BASE->db->begin(); | ||
|
||
$sql = " | ||
UPDATE | ||
".WCOM_DB_CONTENT_PAGES." | ||
SET | ||
`draft` = NULL | ||
WHERE | ||
`draft` = '0' | ||
"; | ||
|
||
// execute update | ||
$BASE->db->execute($sql); | ||
|
||
// update schema version | ||
$sqlData = array( | ||
'schema_version' => TASK_MAJOR.'-'.TASK_MINOR | ||
); | ||
|
||
$BASE->db->update(WCOM_DB_APPLICATION_INFO, $sqlData); | ||
|
||
// commit | ||
$BASE->db->commit(); | ||
} catch (Exception $e) { | ||
// do rollback | ||
$BASE->db->rollback(); | ||
|
||
// re-throw exception | ||
throw $e; | ||
} | ||
} | ||
|
||
// flush the buffer | ||
@ob_end_flush(); | ||
|
||
exit; | ||
} catch (Exception $e) { | ||
// clean the buffer | ||
if (!$BASE->debug_enabled()) { | ||
@ob_end_clean(); | ||
} | ||
|
||
// raise error | ||
$BASE->error->displayException($e, $BASE->utility->smarty); | ||
$BASE->error->triggerException($e); | ||
|
||
// exit | ||
exit; | ||
} | ||
|
||
?> |