From 0051bd9eb2e34a8aaa1d65bfe32a39992355595c Mon Sep 17 00:00:00 2001 From: Alec Smecher Date: Thu, 22 Sep 2022 17:32:37 -0700 Subject: [PATCH] pkp/pkp-lib#8284 Patch ADODB for error handling in newer PHPs --- composer.json | 3 ++- lib/adodb-datadict-errors.diff | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 lib/adodb-datadict-errors.diff diff --git a/composer.json b/composer.json index 48129e70add..3992ac3003d 100644 --- a/composer.json +++ b/composer.json @@ -58,7 +58,8 @@ "patches": { "adodb/adodb-php": { "Apply PKP ADODB patches": "lib/adodb.diff", - "Apply PKP ADODB PHP8.1 patches": "lib/adodb-php8.1.diff" + "Apply PKP ADODB PHP8.1 patches": "lib/adodb-php8.1.diff", + "Apply PKP ADODB patches for error handling": "lib/adodb-datadict-errors.diff" } } }, diff --git a/lib/adodb-datadict-errors.diff b/lib/adodb-datadict-errors.diff new file mode 100644 index 00000000000..5f4136bdc42 --- /dev/null +++ b/lib/adodb-datadict-errors.diff @@ -0,0 +1,33 @@ +--- adodb-xmlschema.inc.php 2022-09-22 17:02:09.997038474 -0700 ++++ adodb-xmlschema.inc.php 2022-09-22 17:30:42.099756162 -0700 +@@ -480,8 +480,14 @@ + function create( &$xmls ) { + $sql = array(); + ++ $tableExists = in_array($this->name, $xmls->dict->MetaTables()); + // drop any existing indexes +- if( is_array( $legacy_indexes = $xmls->dict->MetaIndexes( $this->name ) ) ) { ++ if ($tableExists) { ++ $legacy_indexes = $xmls->dict->MetaIndexes($this->name); ++ } else { ++ $legacy_indexes = false; ++ } ++ if( is_array( $legacy_indexes ) ) { + foreach( $legacy_indexes as $index => $index_details ) { + $sql[] = $xmls->dict->DropIndexSQL( $index, $this->name ); + } +@@ -492,8 +498,13 @@ + unset( $this->fields[$field] ); + } + ++ if ($tableExists) { ++ $legacy_fields = $xmls->dict->MetaColumns($this->name); ++ } else { ++ $legacy_fields = false; ++ } + // if table exists +- if( is_array( $legacy_fields = $xmls->dict->MetaColumns( $this->name ) ) ) { ++ if( is_array( $legacy_fields ) ) { + // drop table + if( $this->drop_table ) { + $sql[] = $xmls->dict->DropTableSQL( $this->name );