summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsetup.php3
-rw-r--r--shared/classes/0sql_row_obj.php3
-rw-r--r--shared/classes/1conf_build_common.php3
-rwxr-xr-xupdate_sql_classes.php16
4 files changed, 12 insertions, 13 deletions
diff --git a/setup.php b/setup.php
index ad3fd2b..915dcbf 100755
--- a/setup.php
+++ b/setup.php
@@ -19,7 +19,8 @@ foreach (get_declared_classes() as $class) {
if (!is_subclass_of($class, 'sql_row_obj')) {
continue;
}
- $o=new $class(); // TODO this will be static once 5.3.0 is out
+ if (substr($class, 0, 4) != 'sql_') continue; // TODO FIXME BAD! Replace with real checks to avoid abstract classes in 5.3.0
+ $o=new $class(); // TODO this will be static once 5.3.0 is out
if (isset($opts['R'])) {
echo_and_query($o->drop_table());
}
diff --git a/shared/classes/0sql_row_obj.php b/shared/classes/0sql_row_obj.php
index 62ef90f..ebff3be 100644
--- a/shared/classes/0sql_row_obj.php
+++ b/shared/classes/0sql_row_obj.php
@@ -397,7 +397,7 @@ abstract class sql_row_obj { // If the name of this class changes, it must be up
return $q;
}
function to_php() {
- $r="class ".get_class($this)." extends sql_row_obj {\n\tprotected \$table='".$this->table."', ";
+ $r="class ".get_class($this)." extends ".get_parent_class($this)." {\n\tprotected \$table='".$this->table."', ";
if (isset($this->primary_key)) {
$r.='$primary_key=array(\''.implode('\', \'', $this->primary_key).'\'), ';
}
@@ -507,6 +507,7 @@ abstract class sql_row_obj { // If the name of this class changes, it must be up
}
foreach (get_declared_classes() as $class) {
if (is_subclass_of($class, 'sql_row_obj')) {
+ if (substr($class, 0, 4) !== 'sql_') continue; // TODO FIXME BAD! In 5.3.0, use a different way of checking if it's abstract
$obj=new $class();
if ($obj->table == $table) {
self::$table_cache[$table]=$class;
diff --git a/shared/classes/1conf_build_common.php b/shared/classes/1conf_build_common.php
index 4e74d09..406ebc1 100644
--- a/shared/classes/1conf_build_common.php
+++ b/shared/classes/1conf_build_common.php
@@ -1,5 +1,6 @@
<?php
-abstract class conf_build_common extends sql_row_obj {
+// TODO In 5.3.0, this can be static without causing fatal errors trying to instantiate it
+class conf_build_common extends sql_row_obj {
private $info;
private function set_vars() {
if (isset($this->info)) {
diff --git a/update_sql_classes.php b/update_sql_classes.php
index da713f8..ddef0b1 100755
--- a/update_sql_classes.php
+++ b/update_sql_classes.php
@@ -1,5 +1,6 @@
#!/usr/bin/php
<?php
+// TODO Get rid of interactive merging
require_once(dirname(__FILE__).'/shared/include/includes.php'); // USE __DIR__ in 5.3.0
require_once(SHARED.'/config.php');
require_once(SHARED.'/include/dbinit.php');
@@ -35,7 +36,7 @@ function write_table_class_to_file($table, $class, $file) {
$stream=fopen($file, 'w');
fputs($stream, "<?php\n");
$tmpclass='genclass_'.randstring(30);
- eval ("class $tmpclass extends sql_row_obj {\nprotected \$table='$table';\t}");
+ eval ("class $tmpclass extends ".(class_exists($class)?get_parent_class($class):'sql_row_obj')." {\nprotected \$table='$table';\t}");
$obj=new $tmpclass();
fputs($stream, str_replace($tmpclass, $class, $obj->to_php()));
fputs($stream, "?>\n");
@@ -84,18 +85,13 @@ foreach ($tables as $i => $table) {
copy($origfile, '.temp_class');
shell_exec('patch .temp_class < .temp_diff');
passthru('colordiff -u "'.$origfile.'" .temp_class');
- if (prompt_bool('Merge differences?')) {
- passthru('sdiff -o .temp_class2 "'.$origfile.'" .temp_class');
- passthru('colordiff -u "'.$origfile.'" .temp_class2');
- if (prompt_bool('Keep changes?')) {
- rename('.temp_class2', $origfile);
- } else {
- unlink('.temp_class2');
- }
+ if (prompt_bool('Keep changes?')) {
+ rename('.temp_class', $origfile);
}
}
unlink('.temp_diff');
- unlink('.temp_class'); // TODO unlink others
+ if (is_file('.temp_class'))
+ unlink('.temp_class'); // TODO unlink others
}
}
}