PHP 8 compatibility fixes for the installer
This commit is contained in:
parent
7e48e041a2
commit
90dd334327
@ -28,7 +28,7 @@ if (defined('S9Y_DATA_PATH')) {
|
||||
|
||||
$data['basedir'] = $basedir;
|
||||
$data['phpversion'] = phpversion();
|
||||
$data['versionInstalled'] = $serendipity['versionInstalled'];
|
||||
$data['versionInstalled'] = $serendipity['versionInstalled'] ?? null;
|
||||
$data['templatePath'] = $serendipity['templatePath'];
|
||||
$data['installerHTTPPath'] = str_replace('//', '/', dirname($_SERVER['PHP_SELF']) . '/'); // since different OS handlers for enddir
|
||||
|
||||
@ -93,9 +93,9 @@ if ( sizeof($_POST) > 1 && $serendipity['GET']['step'] == '3' ) {
|
||||
}
|
||||
}
|
||||
|
||||
$data['s9yGETstep'] = $serendipity['GET']['step'];
|
||||
$data['s9yGETstep'] = $serendipity['GET']['step'] ?? null;
|
||||
|
||||
if ( (int)$serendipity['GET']['step'] == 0 ) {
|
||||
if ( (int)($serendipity['GET']['step'] ?? null) == 0 ) {
|
||||
$data['getstepint0'] = true;
|
||||
$data['print_ERRORS_ARE_DISPLAYED_IN'] = sprintf(ERRORS_ARE_DISPLAYED_IN, serendipity_installerResultDiagnose(S9Y_I_ERROR, RED), serendipity_installerResultDiagnose(S9Y_I_WARNING, YELLOW), serendipity_installerResultDiagnose(S9Y_I_SUCCESS, GREEN));
|
||||
$data['s9yversion'] = $serendipity['version'];
|
||||
@ -308,12 +308,12 @@ if ( (int)$serendipity['GET']['step'] == 0 ) {
|
||||
}
|
||||
}
|
||||
|
||||
$data['showWritableNote'] = $showWritableNote;
|
||||
$data['showWritableNote'] = $showWritableNote ?? null;
|
||||
$data['errorCount'] = $errorCount;
|
||||
|
||||
} elseif ( $serendipity['GET']['step'] == '2a' ) {
|
||||
$config = serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE, null, array('simpleInstall'));
|
||||
$data['ob_serendipity_printConfigTemplate'] = serendipity_printConfigTemplate($config, $from, true, false, false);
|
||||
$data['ob_serendipity_printConfigTemplate'] = serendipity_printConfigTemplate($config, $from ?? false, true, false, false);
|
||||
|
||||
} elseif ( $serendipity['GET']['step'] == '2b' ) {
|
||||
$config = serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE);
|
||||
@ -321,9 +321,12 @@ if ( (int)$serendipity['GET']['step'] == 0 ) {
|
||||
|
||||
} elseif ( $serendipity['GET']['step'] == '3' ) {
|
||||
$serendipity['dbPrefix'] = $_POST['dbPrefix'];
|
||||
|
||||
$t = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}authors", false, 'both', false, false, false, true);
|
||||
$data['authors_query'] = $t;
|
||||
try {
|
||||
$t = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}authors", false, 'both', false, false, false, true);
|
||||
$data['authors_query'] = $t;
|
||||
} catch (PDOException $e) {
|
||||
$t = null;
|
||||
}
|
||||
|
||||
if ( is_array($t) ) {
|
||||
// void
|
||||
@ -361,7 +364,7 @@ if ( (int)$serendipity['GET']['step'] == 0 ) {
|
||||
|
||||
include_once dirname(dirname(__FILE__)) . "/functions.inc.php";
|
||||
|
||||
if (!is_object($serendipity['smarty'])) {
|
||||
if (!is_object($serendipity['smarty'] ?? null)) {
|
||||
serendipity_smarty_init();
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
# All rights reserved. See LICENSE file for licensing details
|
||||
|
||||
// PHP 5.5 compat, no longer use deprecated mysql
|
||||
if ($serendipity['dbType'] == 'mysql' && (version_compare(PHP_VERSION, '5.5.0') >= 0 || !function_exists('mysql_connect'))) {
|
||||
if ($serendipity['dbType'] ?? '' == 'mysql' && (version_compare(PHP_VERSION, '5.5.0') >= 0 || !function_exists('mysql_connect'))) {
|
||||
$serendipity['dbType'] = 'mysqli';
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,7 @@ function serendipity_getTemplateFile($file, $key = 'serendipityHTTPPath', $force
|
||||
} else {
|
||||
$directories[] = $serendipity['template_backend'] . '/'; # Since 2.0 s9y can have a independent backend theme
|
||||
}
|
||||
$directories[] = $serendipity['template_engine'] . '/'; # themes can set an engine, which will be used if they do not have the file
|
||||
$directories[] = $serendipity['template_engine'] ?? null . '/'; # themes can set an engine, which will be used if they do not have the file
|
||||
$directories[] = $serendipity['defaultTemplate'] .'/'; # the default theme is the last place we will look in, serving as pure fallback
|
||||
$directories = array_unique($directories); # save performance by not checking for file existence multiple times in the same directory
|
||||
|
||||
@ -674,7 +674,7 @@ function serendipity_load_userdata($username) {
|
||||
* @return boolean TRUE when logged in, FALSE when not.
|
||||
*/
|
||||
function serendipity_userLoggedIn() {
|
||||
if ($_SESSION['serendipityAuthedUser'] === true && IS_installed) {
|
||||
if ($_SESSION['serendipityAuthedUser'] ?? false === true && IS_installed) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -798,7 +798,7 @@ function serendipity_deleteCookie($name) {
|
||||
function serendipity_is_iframe() {
|
||||
global $serendipity;
|
||||
|
||||
if ($serendipity['GET']['is_iframe'] && is_array($_SESSION['save_entry'])) {
|
||||
if ($serendipity['GET']['is_iframe'] ?? false && is_array($_SESSION['save_entry'])) {
|
||||
if (!is_object($serendipity['smarty'])) {
|
||||
// We need smarty also in the iframe to load a template's config.inc.php and register possible event hooks.
|
||||
serendipity_smarty_init();
|
||||
|
@ -290,7 +290,7 @@ function serendipity_query_default($optname, $default, $usertemplate = false, $t
|
||||
function serendipity_parseTemplate($filename, $areas = null, $onlyFlags=null) {
|
||||
global $serendipity;
|
||||
|
||||
$userlevel = $serendipity['serendipityUserlevel'];
|
||||
$userlevel = $serendipity['serendipityUserlevel'] ?? null;
|
||||
|
||||
if ( !IS_installed ) {
|
||||
$userlevel = USERLEVEL_ADMIN;
|
||||
@ -425,11 +425,10 @@ function serendipity_guessInput($type, $name, $value='', $default='') {
|
||||
break;
|
||||
|
||||
case 'list':
|
||||
$cval = (string)$value;
|
||||
$default = (array)$default;
|
||||
foreach ($default as $k => $v) {
|
||||
$selected = ((string)$k == (string)$value);
|
||||
if (empty($cval) && ((string)$k === 'false' || (string)$k === null)) {
|
||||
$selected = ($k == $value);
|
||||
if (empty($value) && ((string)$k === 'false' || (string)$k === null)) {
|
||||
$selected = true;
|
||||
}
|
||||
$curOptions[$name][$k]['selected'] = $selected;
|
||||
@ -469,7 +468,7 @@ function serendipity_printConfigTemplate($config, $from = false, $noForm = false
|
||||
foreach ($config as &$category) {
|
||||
foreach ($category['items'] as &$item) {
|
||||
|
||||
$value = $from[$item['var']];
|
||||
$value = $from[$item['var']] ?? false;
|
||||
|
||||
/* Calculate value if we are not installed, how clever :) */
|
||||
if ($from == false) {
|
||||
@ -485,7 +484,7 @@ function serendipity_printConfigTemplate($config, $from = false, $noForm = false
|
||||
$value = '';
|
||||
}
|
||||
|
||||
if (!$showDangerous && $item['view'] == 'dangerous') {
|
||||
if (!$showDangerous && ($item['view'] ?? null) == 'dangerous') {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -892,7 +891,7 @@ function serendipity_updateConfiguration() {
|
||||
|
||||
// Check permission set. Changes to blogConfiguration or siteConfiguration items
|
||||
// always required authorid = 0, so that it be not specific to a userlogin
|
||||
if ( $serendipity['serendipityUserlevel'] >= $item['userlevel'] || IS_installed === false ) {
|
||||
if ( ($serendipity['serendipityUserlevel'] ?? 0) >= $item['userlevel'] || IS_installed === false ) {
|
||||
$authorid = 0;
|
||||
} elseif ($item['permission'] == 'blogConfiguration' && serendipity_checkPermission('blogConfiguration')) {
|
||||
$authorid = 0;
|
||||
@ -904,8 +903,7 @@ function serendipity_updateConfiguration() {
|
||||
|
||||
if (is_array($_POST[$item['var']])) {
|
||||
// Arrays not allowed. Use first index value.
|
||||
list($a_key, $a_val) = each($_POST[$item['var']]);
|
||||
$_POST[$item['var']] = $a_key;
|
||||
$_POST[$item['var']] = array_key_first($_POST[$item['var']]);
|
||||
|
||||
// If it still is an array, munge it all together.
|
||||
if (is_array($_POST[$item['var']])) {
|
||||
|
@ -492,7 +492,7 @@ function serendipity_buildPermalinks() {
|
||||
*/
|
||||
function serendipity_rewriteURL($path, $key='baseURL', $forceNone = false) {
|
||||
global $serendipity;
|
||||
return $serendipity[$key] . ($serendipity['rewrite'] == 'none' || ($serendipity['rewrite'] != 'none' && $forceNone) ? $serendipity['indexFile'] . '?/' : '') . $path;
|
||||
return ($serendipity[$key] ?? null) . ($serendipity['rewrite'] == 'none' || ($serendipity['rewrite'] != 'none' && $forceNone) ? $serendipity['indexFile'] . '?/' : '') . $path;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -890,7 +890,7 @@ function serendipity_smarty_init($vars = array()) {
|
||||
|
||||
if (!isset($serendipity['smarty'])) {
|
||||
|
||||
$template_dir = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'];
|
||||
$template_dir = $serendipity['serendipityPath'] . $serendipity['templatePath'] . ($serendipity['template'] ?? null);
|
||||
|
||||
if (!defined('IN_serendipity_admin') && file_exists($template_dir . '/template.inc.php')) {
|
||||
// If this file exists, a custom template engine will be loaded.
|
||||
@ -1013,8 +1013,8 @@ function serendipity_smarty_init($vars = array()) {
|
||||
|
||||
// When templates are switched, append a specific version string to make sure the browser does not cache the CSS
|
||||
if (strstr($serendipity['smarty_vars']['head_link_stylesheet'], '?')) {
|
||||
$serendipity['smarty_vars']['head_link_stylesheet'] .= '&v=' . $serendipity['last_template_change'];
|
||||
$serendipity['smarty_vars']['head_link_stylesheet_frontend'] .= '&v=' . $serendipity['last_template_change'];
|
||||
$serendipity['smarty_vars']['head_link_stylesheet'] .= '&v=' . ($serendipity['last_template_change'] ?? null);
|
||||
$serendipity['smarty_vars']['head_link_stylesheet_frontend'] .= '&v=' . ($serendipity['last_template_change'] ?? null);
|
||||
} else {
|
||||
$serendipity['smarty_vars']['head_link_stylesheet'] .= '?v=' . $serendipity['last_template_change'];
|
||||
$serendipity['smarty_vars']['head_link_stylesheet_frontend'] .= '?v=' . $serendipity['last_template_change'];
|
||||
@ -1029,7 +1029,7 @@ function serendipity_smarty_init($vars = array()) {
|
||||
}
|
||||
|
||||
if (strstr($serendipity['smarty_vars']['head_link_script'], '?')) {
|
||||
$serendipity['smarty_vars']['head_link_script'] .= '&v=' . $serendipity['last_template_change'];
|
||||
$serendipity['smarty_vars']['head_link_script'] .= '&v=' . ($serendipity['last_template_change'] ?? null);
|
||||
} else {
|
||||
$serendipity['smarty_vars']['head_link_script'] .= '?v=' . $serendipity['last_template_change'];
|
||||
}
|
||||
@ -1080,20 +1080,20 @@ function serendipity_smarty_init($vars = array()) {
|
||||
'use_popups' => $serendipity['enablePopup'] ?? null,
|
||||
'use_backendpopups' => $serendipity['enableBackendPopup'] ?? null,
|
||||
'force_backendpopups' => $force_backendpopups,
|
||||
'is_embedded' => (!$serendipity['embed'] || $serendipity['embed'] === 'false' || $serendipity['embed'] === false) ? false : true,
|
||||
'is_embedded' => $serendipity['embed'] ?? false,
|
||||
'is_raw_mode' => $serendipity['smarty_raw_mode'] ?? null,
|
||||
'is_logged_in' => serendipity_userLoggedIn(),
|
||||
|
||||
'entry_id' => (isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])) ? $serendipity['GET']['id'] : false,
|
||||
'is_single_entry' => (isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])),
|
||||
|
||||
'blogTitle' => $serendipity['blogTitle'],
|
||||
'blogTitle' => $serendipity['blogTitle'] ?? null,
|
||||
'blogSubTitle' => (!empty($serendipity['blogSubTitle']) ? $serendipity['blogSubTitle'] : ''),
|
||||
'blogDescription' => $serendipity['blogDescription'],
|
||||
'blogDescription' => $serendipity['blogDescription'] ?? null,
|
||||
|
||||
'serendipityHTTPPath' => $serendipity['serendipityHTTPPath'],
|
||||
'serendipityDefaultBaseURL' => $serendipity['defaultBaseURL'],
|
||||
'serendipityBaseURL' => $serendipity['baseURL'],
|
||||
'serendipityHTTPPath' => $serendipity['serendipityHTTPPath'] ?? null,
|
||||
'serendipityDefaultBaseURL' => $serendipity['defaultBaseURL'] ?? null,
|
||||
'serendipityBaseURL' => $serendipity['baseURL'] ?? null,
|
||||
'serendipityRewritePrefix' => $serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '',
|
||||
'serendipityIndexFile' => $serendipity['indexFile'],
|
||||
'serendipityVersion' => ($serendipity['expose_s9y'] ? $serendipity['version'] : ''),
|
||||
@ -1145,7 +1145,7 @@ function serendipity_smarty_init($vars = array()) {
|
||||
}
|
||||
|
||||
|
||||
if (is_array($template_loaded_config)) {
|
||||
if (is_array($template_loaded_config ?? null)) {
|
||||
$template_vars =& $template_loaded_config;
|
||||
$serendipity['smarty']->assignByRef('template_option', $template_vars);
|
||||
} elseif (is_array($template_config)) {
|
||||
@ -1217,7 +1217,7 @@ function serendipity_smarty_shutdown($serendipity_directory = '') {
|
||||
function serendipity_smarty_show($template, $data = null, $debugtype = null, $debug = null) {
|
||||
global $serendipity;
|
||||
|
||||
if (!is_object($serendipity['smarty'])) {
|
||||
if (!is_object($serendipity['smarty'] ?? null)) {
|
||||
serendipity_smarty_init();
|
||||
}
|
||||
|
||||
|
@ -1134,7 +1134,7 @@ class serendipity_plugin_api
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($serendipity['enablePluginACL'] && !serendipity_hasPluginPermissions($event_name)) {
|
||||
if ($serendipity['enablePluginACL'] ?? false && !serendipity_hasPluginPermissions($event_name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1182,7 +1182,7 @@ class serendipity_plugin_api
|
||||
}
|
||||
}
|
||||
|
||||
if ($serendipity['enablePluginACL'] && !serendipity_hasPluginPermissions($plugin)) {
|
||||
if ($serendipity['enablePluginACL'] ?? false && !serendipity_hasPluginPermissions($plugin)) {
|
||||
continue;
|
||||
}
|
||||
$plugins[$plugin]['p']->event_hook($event_name, $bag, $eventData, $addData);
|
||||
|
@ -123,7 +123,7 @@ class Serendipity_Smarty extends Smarty
|
||||
$template_dirs = array();
|
||||
|
||||
// first add template path
|
||||
$template_dirs[] = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'];
|
||||
$template_dirs[] = $serendipity['serendipityPath'] . $serendipity['templatePath'] . ($serendipity['template'] ?? null);
|
||||
// then fallback engines (which should never be a comma separated list)
|
||||
if ($template_engine) {
|
||||
$p = explode(',', $template_engine);
|
||||
|
@ -84,7 +84,7 @@ $no_footer = (isset($serendipity['GET']['noFooter']) || isset($serendipity['POST
|
||||
|
||||
$use_installer = (!isset($serendipity['serendipityPath']) || IS_installed === false || IS_up2date === false );
|
||||
|
||||
$post_action = $serendipity['POST']['action'];
|
||||
$post_action = $serendipity['POST']['action'] ?? null;
|
||||
|
||||
$main_content = '';
|
||||
if (!$use_installer && $is_logged_in) {
|
||||
|
@ -20,11 +20,11 @@
|
||||
{/if}
|
||||
|
||||
{/if}
|
||||
<div id="el{$category@index}" class="config_optiongroup{if $config_groupkeys@last} config_optiongroup_last{/if} option_list">
|
||||
<div id="el{$category@index}" class="config_optiongroup{if is_array($config_groupkeys|default:null) and $config_groupkeys@last} config_optiongroup_last{/if} option_list">
|
||||
<legend class="visuallyhidden">{$category.description}</legend>
|
||||
{foreach $category.items as $item}
|
||||
{cycle assign='zebra_class' values='odd,even'}
|
||||
{if $item.guessedInput}
|
||||
{if isset($item.guessedInput) and $item.guessedInput}
|
||||
{if $item.type == 'bool'}
|
||||
<fieldset class="clearfix {$zebra_class}{if $item.description != ''} has_info{/if}">
|
||||
<span class="wrap_legend"><legend>{$item.title}{if $item.description != ''} <button class="toggle_info button_link" type="button" data-href="#{$item.var}_info"><span class="icon-info-circled" aria-hidden="true"></span><b>i</b><span class="visuallyhidden"> {$CONST.MORE}</span></button>{/if}</legend></span>
|
||||
@ -36,15 +36,15 @@
|
||||
</div>
|
||||
</fieldset>
|
||||
{else}
|
||||
{if $item.ignore}
|
||||
{if $item.ignore|default:false}
|
||||
{cycle advance=true assign='temp'}
|
||||
{/if}
|
||||
<div class="clearfix {$zebra_class} form_{if $item.type == 'list'}select{elseif $item.type == 'multilist'}multiselect{elseif $item.type == 'textarea'}area{else}field{/if}{if $item.description != ''} has_info{/if}{if $item.ignore} hidden{/if}">
|
||||
<div class="clearfix {$zebra_class} form_{if $item.type == 'list'}select{elseif $item.type == 'multilist'}multiselect{elseif $item.type == 'textarea'}area{else}field{/if}{if $item.description != ''} has_info{/if}{if $item.ignore|default:false} hidden{/if}">
|
||||
<label for="{$item.var}">{$item.title}{if $item.description != ''} <button class="toggle_info button_link" type="button" data-href="#{$item.var}_info"><span class="icon-info-circled" aria-hidden="true"></span><b>i</b><span class="visuallyhidden"> {$CONST.MORE}</span></button>{/if}</label>
|
||||
{if $item.description != ''}
|
||||
<span id="{$item.var}_info" class="field_info additional_info">{$item.description}</span>
|
||||
{/if}
|
||||
{$item.guessedInput}
|
||||
{if isset($item.guessedInput)}{$item.guessedInput}{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
@ -25,14 +25,14 @@
|
||||
|
||||
<main class="clearfix serendipityAdminContent installer">
|
||||
<div id="content" class="clearfix">
|
||||
{if $is_errors && is_array($errors)}
|
||||
{if isset($is_errors) && $is_errors && is_array($errors)}
|
||||
<ul class="plainList">
|
||||
{foreach $errors AS $error}
|
||||
<li><span class="msg_error">{$error}</span></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
{/if}
|
||||
{if $getstepint0}
|
||||
{if $getstepint0|default:false}
|
||||
<h2>{$CONST.WELCOME_TO_INSTALLATION}</h2>
|
||||
|
||||
<p>{$CONST.FIRST_WE_TAKE_A_LOOK}</p>
|
||||
@ -262,7 +262,7 @@
|
||||
</form>
|
||||
{elseif $s9yGETstep == '3'}
|
||||
<h3>{$CONST.CHECK_DATABASE_EXISTS}</h3>
|
||||
{if is_array($authors_query)}
|
||||
{if is_array($authors_query|default:null)}
|
||||
<span class="msg_success"><strong>{$CONST.THEY_DO}</strong>, {$CONST.WONT_INSTALL_DB_AGAIN}</span>
|
||||
{else}
|
||||
<span class="msg_success"><strong>{$CONST.THEY_DONT}</strong></span>
|
||||
@ -299,7 +299,7 @@
|
||||
</div>
|
||||
</main>
|
||||
<footer id="meta">
|
||||
<p>{$ADMIN_FOOTER_POWERED_BY|sprintf:$versionInstalled:$phpversion}</p>
|
||||
<p>{$CONST.ADMIN_FOOTER_POWERED_BY|sprintf:$versionInstalled:$phpversion}</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user