summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-18 09:25:11 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-18 09:25:11 +0100
commit1ee603f2af7630a79cd8ebd7149d5da85e02331b (patch)
treee4a14836d79930837dd1a73ccd7cad76f06c9b62
parent4eca49d068924970f4218841aee102f8068c1d05 (diff)
downloadliberty-1ee603f2af7630a79cd8ebd7149d5da85e02331b.tar.gz
liberty-1ee603f2af7630a79cd8ebd7149d5da85e02331b.tar.bz2
liberty-1ee603f2af7630a79cd8ebd7149d5da85e02331b.zip
Tidy install process handling following other changes
Missed from BIT_INSTALL fixes
-rwxr-xr-xincludes/classes/LibertySystem.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/includes/classes/LibertySystem.php b/includes/classes/LibertySystem.php
index 6eca60b..114fe07 100755
--- a/includes/classes/LibertySystem.php
+++ b/includes/classes/LibertySystem.php
@@ -619,16 +619,26 @@ class LibertySystem extends BitSingleton {
if( !isset( $this->mContentTypes ) ) {
$this->loadContentTypes();
}
+ // loadContentTypes() is a no-op during install (BIT_INSTALL guard); ensure mContentTypes is an array
+ if( !is_array( $this->mContentTypes ) ) {
+ $this->mContentTypes = [];
+ }
$pTypeParams['content_type_guid'] = $pGuid;
// automagically populate plural name value if none is set using most comment english of appending 's'
if( empty( $pTypeParams['content_name_plural'] ) ){
$pTypeParams['content_name_plural'] = $pTypeParams['content_name'].'s';
}
if( empty( $this->mContentTypes[$pGuid] ) && !empty( $pTypeParams ) ) {
- $this->StartTrans();
- $result = $this->mDb->associateInsert( BIT_DB_PREFIX."liberty_content_types", $pTypeParams );
- $this->CompleteTrans();
- // we just ran some SQL - let's flush the loadContentTypes query cache
+ // During install mContentTypes may be empty even for pre-existing types; check DB before inserting
+ $existsInDb = $this->mDb->getOne( "SELECT `content_type_guid` FROM `".BIT_DB_PREFIX."liberty_content_types` WHERE `content_type_guid`=?", [$pGuid] );
+ if( !$existsInDb ) {
+ $this->StartTrans();
+ $result = $this->mDb->associateInsert( BIT_DB_PREFIX."liberty_content_types", $pTypeParams );
+ $this->CompleteTrans();
+ }
+ // cache in-memory to prevent duplicate INSERT attempts in same request
+ $this->mContentTypes[$pGuid] = $pTypeParams;
+ // flush the loadContentTypes query cache (no-op during install, fine to call)
$this->loadContentTypes( 0 );
} else {
if( $pTypeParams['handler_package'] != $this->mContentTypes[$pGuid]['handler_package'] ||