Skip to content

Commit

Permalink
Fix some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberpower678 committed May 24, 2023
1 parent 1927e43 commit f48810b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .idea/phpunit.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions app/src/Core/APII.php
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,17 @@ public static function getTemplateData( $templates, $force = false ) {
$batch = array_slice( $toLookup, 0, $limit );
continue;
}
if( !empty( $data['error']['code'] ) && $data['error']['code'] == "templatedata-corrupt" ) {
if( $limit == 1 ) {
self::$cachedTemplateData[$batch[0]] = [ false, time() ];
unset( $toLookup[array_search( $batch[0], $toLookup )] );
$batch = array_slice( $toLookup, 0, $limit );
continue;
}
$limit = 1;
$batch = array_slice( $toLookup, 0, $limit );
continue;
}

if( !empty( $data['pages'] ) ) {
foreach( $data['pages'] as $pageData ) {
Expand Down
61 changes: 33 additions & 28 deletions app/src/Core/CiteMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ protected function buildMap( $mapString = "" ) {
if( !$this->useTemplateData && in_array( $this, self::$mapObjects ) ) $this->useTemplateData = true;

if( $this->informalName != "__GLOBAL__" )
$data = API::getTemplateData( [$this->informalName] )[$this->informalName];
$data = API::getTemplateData( [ $this->informalName ] )[$this->informalName];
else
$data = false;

Expand Down Expand Up @@ -771,7 +771,7 @@ protected static function preloadTemplateSourceBatch( $templates ) {

if( !$sources ) return false;

foreach( $sources as $template=>$source ) {
foreach( $sources as $template => $source ) {
self::$sources[$template] = $source;
self::$lastSourceUpdate[$template] = time();
}
Expand Down Expand Up @@ -1381,7 +1381,9 @@ protected static function getDeadValues( $configArray, $moduleCode ) {
break;
}
}
} else $returnArray['__DEFAULT__'] = 'dead';
}

if( empty( $returnArray['__DEFAULT__'] ) ) $returnArray['__DEFAULT__'] = 'dead';

return $returnArray;
} else return false;
Expand Down Expand Up @@ -1596,10 +1598,12 @@ public static function setDefaultTemplate( $templateName ) {
if( in_array( $templateName, self::$templateList ) ) {
self::$globalTemplate = trim( $templateName, '{}' );
self::saveMaps();

return true;
} elseif( in_array( "{{{$templateName}}}", self::$templateList ) ) {
self::$globalTemplate = $templateName;
self::saveMaps();

return true;
}

Expand Down Expand Up @@ -1773,36 +1777,37 @@ public static function updateMaps() {
self::updateDefaultObject();

$templateLookup = [];
foreach( self::$templateList as $template ) {
$template = trim( $template, '{}' );
$template = API::getTemplateNamespaceName() . ":$template";
$templateLookup[] = $template;
}
$templatesExist = API::pagesExist( $templateLookup );
$toLookup = [];
foreach( self::$templateList as $template ) {
$template = trim( $template, '{}' );
$template = API::getTemplateNamespaceName() . ":$template";
$templateLookup[] = $template;
}
$templatesExist = API::pagesExist( $templateLookup );
$toLookup = [];

foreach( $templatesExist as $template => $exists ) {
$template = explode( ':', $template, 2 )[1];
if( !$exists ) {
self::unregisterMapObject( $template );
continue;
}
if( !isset( $citoidData['template_data'][$template] ) ) {
$toLookup[] = $template;
}
foreach( $templatesExist as $template => $exists ) {
$template = explode( ':', $template, 2 )[1];
if( !$exists ) {
self::unregisterMapObject( $template );
continue;
}
if( !isset( $citoidData['template_data'][$template] ) ) {
$toLookup[] = $template;
}
}

if( !empty( $toLookup ) )
$citoidData['template_data'] = array_replace( $citoidData['template_data'], API::getTemplateData( $toLookup ) );
if( !empty( $toLookup ) )
$citoidData['template_data'] =
array_replace( $citoidData['template_data'], API::getTemplateData( $toLookup ) );

foreach( $citoidData['template_data'] as $template => $exists ) {
if( $exists ) {
self::registerMapObject( $template );
$toPreload[] = API::getTemplateNamespaceName() . ":$template";
} elseif( empty( $exists ) ) {
self::unregisterMapObject( $template );
}
foreach( $citoidData['template_data'] as $template => $exists ) {
if( $exists ) {
self::registerMapObject( $template );
$toPreload[] = API::getTemplateNamespaceName() . ":$template";
} elseif( empty( $exists ) ) {
self::unregisterMapObject( $template );
}
}

do {
self::$requireUpdate = false;
Expand Down
4 changes: 2 additions & 2 deletions app/src/Core/Metrics/InfluxDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public function initialize( $exceptOnFail = false ): bool {
if( $this->usingLegacy ) {
$this->client = new \InfluxDB\Client( $this->configuration['host'],
$this->configuration['port'],
$this->configuration['user'],
$this->configuration['password'],
@$this->configuration['user'],
@$this->configuration['password'],
isset( $this->configuration['ssl'] ) &&
is_bool( $this->configuration['ssl']
) &&
Expand Down

0 comments on commit f48810b

Please sign in to comment.