diff --git a/include/Models/CompatibilityModel.php b/include/Models/CompatibilityModel.php index 2d283700..4150707f 100644 --- a/include/Models/CompatibilityModel.php +++ b/include/Models/CompatibilityModel.php @@ -29,6 +29,7 @@ class CompatibilityModel extends BasicModel if ($version === 'DEV') { $version = "99.99.99"; } + $cachekey = $version; $version = \explode('.', $version); $data = CompatibilityQuery::create() ->withColumn("max(release_date)") @@ -44,7 +45,7 @@ class CompatibilityModel extends BasicModel ->filterByReleaseDate($releaseDate, Criteria::LESS_EQUAL) ->endUse() ->find(); - $this->saveToCache($data, $version); + $this->saveToCache($data, $cachekey); } return $data; } diff --git a/include/Models/DownloadsModel.php b/include/Models/DownloadsModel.php index 20e39efc..0ae23eb5 100644 --- a/include/Models/DownloadsModel.php +++ b/include/Models/DownloadsModel.php @@ -27,7 +27,7 @@ class DownloadsModel extends BasicModel $sections[$category] = new DownloadsSection([ 'anchor' => $category, 'title' => $sectionsData[$category]['title'], - 'notes' => $sectionsData[$category]['notes'] + 'notes' => $sectionsData[$category]['notes'] ?? null ]); } @@ -37,7 +37,7 @@ class DownloadsModel extends BasicModel $sections[$category]->addSubsection(new DownloadsSection([ 'anchor' => $subCategory, 'title' => $sectionsData[$subCategory]['title'], - 'notes' => $sectionsData[$subCategory]['notes'] + 'notes' => $sectionsData[$subCategory]['notes'] ?? null ])); } diff --git a/include/Models/GameDownloadsModel.php b/include/Models/GameDownloadsModel.php index d149a282..c986c911 100644 --- a/include/Models/GameDownloadsModel.php +++ b/include/Models/GameDownloadsModel.php @@ -25,7 +25,7 @@ class GameDownloadsModel extends BasicModel $sections[$category] = new DownloadsSection([ 'anchor' => $category, 'title' => $sectionsData[$category]['title'], - 'notes' => $sectionsData[$category]['notes'] + 'notes' => $sectionsData[$category]['notes'] ?? null ]); } @@ -43,7 +43,7 @@ class GameDownloadsModel extends BasicModel $sections[$category]->addSubsection(new DownloadsSection([ 'anchor' => $gameId, 'title' => $gameName, - 'notes' => $sectionsData[$gameId]['notes'] + 'notes' => $sectionsData[$gameId]['notes'] ?? null ])); } diff --git a/include/Objects/Article.php b/include/Objects/Article.php index 534d2eb0..e7df7e87 100644 --- a/include/Objects/Article.php +++ b/include/Objects/Article.php @@ -16,10 +16,10 @@ class Article extends BasicObject public function __construct($data) { parent::__construct($data); - $this->url = $data['url']; - $this->language = $data['language']; - $this->source = $data['source']; - $this->date = $data['date']; + $this->url = $data['url'] ?? null; + $this->language = $data['language'] ?? null; + $this->source = $data['source'] ?? null; + $this->date = $data['date'] ?? null; } /* Get the URL. */ diff --git a/include/Objects/BasicObject.php b/include/Objects/BasicObject.php index ae0236e0..8ae77ae4 100644 --- a/include/Objects/BasicObject.php +++ b/include/Objects/BasicObject.php @@ -12,8 +12,8 @@ abstract class BasicObject public function __construct($data) { - $this->description = $data['description']; - $this->name = $data['name']; + $this->description = $data['description'] ?? null; + $this->name = $data['name'] ?? null; } public function __toString() diff --git a/include/Objects/File.php b/include/Objects/File.php index 3a3366f1..36c8bbd1 100644 --- a/include/Objects/File.php +++ b/include/Objects/File.php @@ -16,8 +16,8 @@ class File extends BasicObject { parent::__construct($data); $this->category_icon = $data['category_icon']; - $this->extra_info = $data['extra_info']; - $this->type = strtolower($data['type']); + $this->extra_info = $data['extra_info'] ?? null; + $this->type = strtolower($data['type'] ?? ''); $this->user_agent = isset($data["user_agent"]) ? $data["user_agent"] : ""; $fname = ""; @@ -93,7 +93,8 @@ class File extends BasicObject * Get the filesize/last modified information and put it in * $this->extra_info. */ - if ($attributes['extra_info'] == 'true') { + if (isset($attributes['extra_info']) + && $attributes['extra_info'] == 'true') { if (is_file($fname) && is_readable($fname)) { $this->extra_info['date'] = date('F j, Y, g:i a', @filemtime($fname)); if (!is_null($data['extra_info'])) { diff --git a/include/Pages/CompatibilityPage.php b/include/Pages/CompatibilityPage.php index 442bae0f..b5e999ba 100644 --- a/include/Pages/CompatibilityPage.php +++ b/include/Pages/CompatibilityPage.php @@ -52,8 +52,8 @@ class CompatibilityPage extends Controller /* Display the index page. */ public function index($args) { - $version = $args['version']; - $target = $args['game']; + $version = $args['version'] ?? null; + $target = $args['game'] ?? null; $versions = VersionQuery::create() ->orderByMajor('desc') diff --git a/include/Pages/NewsPage.php b/include/Pages/NewsPage.php index 3f905622..2797c2ce 100644 --- a/include/Pages/NewsPage.php +++ b/include/Pages/NewsPage.php @@ -22,7 +22,7 @@ class NewsPage extends Controller /* Display the index page. */ public function index($args) { - $filename = $args['date']; + $filename = $args['date'] ?? null; if ($filename != null) { if (strtolower($filename) == 'archive' || $filename == '') { diff --git a/include/Pages/ScreenshotsPage.php b/include/Pages/ScreenshotsPage.php index 584d18a4..c9726b82 100644 --- a/include/Pages/ScreenshotsPage.php +++ b/include/Pages/ScreenshotsPage.php @@ -18,8 +18,8 @@ class ScreenshotsPage extends Controller /* Display the index page. */ public function index($args) { - $category = $args['category']; - $game = $args['game']; + $category = $args['category'] ?? null; + $game = $args['game'] ?? null; $this->addJSFiles( array( @@ -27,7 +27,7 @@ class ScreenshotsPage extends Controller ) ); - if (!empty($category)) { + if ($category) { return $this->getCategory($category, $game); } diff --git a/templates/components/box.tpl b/templates/components/box.tpl index 617868d4..ca046706 100644 --- a/templates/components/box.tpl +++ b/templates/components/box.tpl @@ -1,10 +1,10 @@ -<{if $article}article{else}section{/if} class="box" {if $id}id="{$id}" {/if}> - {if $head} +<{if isset($article)}article{else}section{/if} class="box" {if isset($id)}id="{$id}" {/if}> + {if isset($head)}
{$head}
{/if} - {if $intro} + {if isset($intro)}
{$intro}
@@ -12,4 +12,4 @@
{$content}
- \ No newline at end of file + diff --git a/templates/components/roundbox.tpl b/templates/components/roundbox.tpl index e99af406..0c659ce8 100644 --- a/templates/components/roundbox.tpl +++ b/templates/components/roundbox.tpl @@ -1,10 +1,10 @@
- {if $header} + {if isset($header)}
{$header}
{/if} -
+
{$content}
-
\ No newline at end of file +
diff --git a/templates/pages/index.tpl b/templates/pages/index.tpl index a3dcbcb9..21361495 100644 --- a/templates/pages/index.tpl +++ b/templates/pages/index.tpl @@ -41,7 +41,7 @@ {/foreach} - {if $smarty.cookies.cookie_consent == "true"} + {if isset($smarty.cookies.cookie_consent) && $smarty.cookies.cookie_consent == "true"} - {if $smarty.cookies.cookie_consent == "true"} + {if isset($smarty.cookies.cookie_consent) && $smarty.cookies.cookie_consent == "true"} {* Google analytics javascript. *} {* End Google analytics javascript. *} - {else if $smarty.cookies.cookie_consent == "false"} + {else if isset($smarty.cookies.cookie_consent) && $smarty.cookies.cookie_consent == "false"} {* Do nothing *} {else} {include file='components/cookie.tpl'}