Skip to content
Permalink
Browse files

Fix for #175: remove/change all calls to assert() that use a string p…

…arameter to fix PHP 7.2 deprecation warning.
  • Loading branch information
craigk5n committed Feb 27, 2020
1 parent e420cdf commit 412be585cf059173a3d5312a3018a1391e2f3ba1
Showing with 26 additions and 27 deletions.
  1. +2 −2 edit_template.php
  2. +1 −1 import_handler.php
  3. +16 −17 includes/access.php
  4. +7 −7 includes/dbi4php.php
@@ -28,8 +28,8 @@
}

if ( $user == '__system__' )
assert ( '($is_admin && ! access_is_enabled() ) ||
access_can_access_function ( ACCESS_SYSTEM_SETTINGS )' );
assert ( ($is_admin && ! access_is_enabled() ) ||
access_can_access_function ( ACCESS_SYSTEM_SETTINGS ) );

// Get existing value.
$res = dbi_execute ( 'SELECT cal_template_text FROM webcal_user_template
@@ -118,7 +118,7 @@
echo '
<br /><br />
<b>' . translate ( 'Error' ) . ':</b> '
. translate( 'There was an error parsing the import file or no events were returned.' )
. translate( 'There was an error parsing the import file or no events were returned.' ) . "<br>" . translate("Error") . ": " . htmlentities($errormsg)
. '<br />';
} else
echo '
@@ -236,8 +236,7 @@ function access_load_user_permissions( $useCache = true ) {
$res = dbi_execute( 'SELECT cal_login, cal_other_user, cal_can_view,
cal_can_edit, cal_can_approve, cal_can_email, cal_can_invite,
cal_see_time_only FROM webcal_access_user' );
assert( '$res' );
while( $row = dbi_fetch_row( $res ) ) {
while( $res && $row = dbi_fetch_row( $res ) ) {
// TODO should we set admin_override here to apply to
// DEFAULT CONFIGURATION only?
// $admin_override = ( $row[1] == '__default__' && $is_admin
@@ -311,12 +310,12 @@ function access_load_user_functions( $user ) {
for( $i = 0, $cnt = count( $users ); $i < $cnt && empty( $ret ); $i++ ) {
$res = dbi_execute( 'SELECT cal_permissions FROM webcal_access_function
WHERE cal_login = ?', array( $users[$i] ) );
assert( '$res' );
if ( $res ) {
if( $row = dbi_fetch_row( $res ) )
$rets[$users[$i]] = $row[0];

if( $row = dbi_fetch_row( $res ) )
$rets[$users[$i]] = $row[0];

dbi_free_result( $res );
dbi_free_result( $res );
}
}
// If still no setting found, then assume access to everything
// if an admin user, otherwise access to all non-admin functions.
@@ -351,7 +350,7 @@ function access_init( $user = '' ) {
if( empty( $user ) && ! empty( $login ) )
$user = $login;

assert( '! empty( $user )' );
assert( ! empty( $user ) );

$access_user = access_load_user_functions( $user );

@@ -378,16 +377,16 @@ function access_can_access_function( $function, $user = '' ) {
if( empty( $user ) && ! empty( $login ) )
$user = $login;

assert( '! empty( $user )' );
assert( 'isset( $function )' );
assert( ! empty( $user ) );
assert( isset( $function ) );

$access = access_load_user_functions( $user );
$yesno = substr( $access, $function, 1 );

if( empty( $yesno ) )
$yesno = get_default_function_access( $function, $user );

assert( '! empty( $yesno )' );
assert( ! empty( $yesno ) );

return ( $yesno == 'Y' );
}
@@ -418,12 +417,12 @@ function access_can_view_page( $page = '', $user = '' ) {
if( empty( $user ) && ! empty( $login ) )
$user = $login;

assert( '! empty( $user )' );
assert( ! empty( $user ) );

if( empty( $page ) && ! empty( $PHP_SELF ) )
$page = $PHP_SELF;

assert( '! empty( $page )' );
assert( ! empty( $page ) );

$page = basename( $page );

@@ -450,7 +449,7 @@ function access_can_view_page( $page = '', $user = '' ) {
: // User is not logged in. Need to load info from db now.
access_load_user_functions( $user ) );

assert( '! empty( $access )' );
assert( ! empty( $access ) );

// If we did not find a page id, then this is also a WebCalendar bug.
// (Someone needs to add another entry in the $page_lookup[] array.)
@@ -460,7 +459,7 @@ function access_can_view_page( $page = '', $user = '' ) {
if( empty( $yesno ) )
$yesno = get_default_function_access( $page_id, $user );

assert( '! empty( $yesno )' );
assert( ! empty( $yesno ) );
return ( $yesno == 'Y' );
}

@@ -509,8 +508,8 @@ function access_user_calendar( $cal_can_xxx = '', $other_user, $cur_user = '',
? 'Y' : CAN_DOALL );
}

assert( '! empty( $other_user )' );
assert( '! empty( $cur_user )' );
assert( ! empty( $other_user ) );
assert( ! empty( $cur_user ) );

if( ! access_is_enabled() ) {
if( ! empty( $ALLOW_VIEW_OTHER ) && $cur_user != '__public__'
@@ -515,10 +515,10 @@ function dbi_update_blob( $table, $column, $key, $data ) {
array( '"dbi_update_blob"', $GLOBALS['db_type'] ),
translate( 'Unfortunately, XXX is not implemented for YYY' ) );

assert( '! empty( $table )' );
assert( '! empty( $column )' );
assert( '! empty( $key )' );
assert( '! empty( $data )' );
assert( ! empty( $table ) );
assert( ! empty( $column ) );
assert( ! empty( $key ) );
assert( ! empty( $data ) );

$sql = 'UPDATE ' . $table . ' SET ' . $column;

@@ -567,9 +567,9 @@ function dbi_update_blob( $table, $column, $key, $data ) {
function dbi_get_blob( $table, $column, $key ) {
global $unavail_DBI_Update_blob, $db_connection_info;

assert( '! empty( $table )' );
assert( '! empty( $column )' );
assert( '! empty( $key )' );
assert( ! empty( $table ) );
assert( ! empty( $column ) );
assert( ! empty( $key ) );

$res =
dbi_execute( 'SELECT ' . $column . ' FROM ' . $table . ' WHERE ' . $key );

0 comments on commit 412be58

Please sign in to comment.
You can’t perform that action at this time.