diff --git a/install/install.php b/install/install.php index c6b85a3bebdde2886c0f42e8aa4456067a535a98..00391d5a034b8268c8ec98f891bc20dffbc16a46 100644 --- a/install/install.php +++ b/install/install.php @@ -34,6 +34,8 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. error_reporting(E_ALL|E_STRICT); +define('INSTALLER_RUN', true); + //** The banner on the command line echo "\n\n".str_repeat('-',80)."\n"; echo " _____ ___________ _____ __ _ ____ diff --git a/install/lib/update.lib.php b/install/lib/update.lib.php index 5beca810208fe486d995df9675ed704b6a59bec8..8362b8aaf8941d6aa5001727c036df61e015361a 100644 --- a/install/lib/update.lib.php +++ b/install/lib/update.lib.php @@ -27,6 +27,15 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +//* Installer patch stub class +class installer_patch_update { + protected function onBeforeSQL() { + } + protected function onAfterSQL() { + } +} + +//* DB dump function function prepareDBDump() { global $conf; @@ -151,16 +160,39 @@ function updateDbAndIni() { $found = true; while($found == true) { $next_db_version = intval($current_db_version + 1); - $patch_filename = realpath(dirname(__FILE__).'/../').'/sql/incremental/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.sql'; - if(is_file($patch_filename)) { + $sql_patch_filename = realpath(dirname(__FILE__).'/../').'/sql/incremental/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.sql'; + $php_patch_filename = realpath(dirname(__FILE__).'/../').'/patches/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.php'; + + if(is_file($sql_patch_filename)) { + + //* Load php patch file and instantiate object + if(is_file($php_patch_filename)) { + $php_patch_class_name = 'upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT); + include_once($php_patch_filename); + $php_patch = new $php_patch_class_name; + } + + //* Exec onBeforeSQL function + if(isset($php_patch) && is_object($php_patch)) { + $php_patch->onBeforeSQL(); + swriteln($inst->lng('Executing PHP patch file').': '.$php_patch_filename); + } + //* Load patch file into database if( !empty($conf["mysql"]["admin_password"]) ) { - system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." ".escapeshellarg($conf['mysql']['database'])." < ".$patch_filename); + system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename); } else { - system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['mysql']['database'])." < ".$patch_filename); + system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename); + } + swriteln($inst->lng('Loading SQL patch file').': '.$sql_patch_filename); + + //* Exec onAfterSQL function + if(isset($php_patch) && is_object($php_patch)) { + $php_patch->onAfterSQL(); } - swriteln($inst->lng('Loading SQL patch file').': '.$patch_filename); + $current_db_version = $next_db_version; + if(isset($php_patch)) unset($php_patch); } else { $found = false; } @@ -332,4 +364,6 @@ function updateDbAndIni() { unset($new_ini); } + + ?> diff --git a/install/patches/upd_0001.php b/install/patches/upd_0001.php new file mode 100644 index 0000000000000000000000000000000000000000..93d6967b9d2f5d77b69e57466548daf9560df71c --- /dev/null +++ b/install/patches/upd_0001.php @@ -0,0 +1,21 @@ + diff --git a/install/update.php b/install/update.php index b7753dc7e70f61fa8af951df53ff4ba5ae6b4f44..cbaeaed2aaa7060d7267a273af3f86411213826e 100644 --- a/install/update.php +++ b/install/update.php @@ -34,6 +34,8 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. error_reporting(E_ALL|E_STRICT); +define('INSTALLER_RUN', true); + //** The banner on the command line echo "\n\n".str_repeat('-',80)."\n"; echo " _____ ___________ _____ __ _ ____