Skip to content

Commit

Permalink
Merge origin/master-1.3.x into master (using imerge)
Browse files Browse the repository at this point in the history
There were quite a few merge conflicts here, hopefully I didn't mess
anything up...

Conflicts
- view_all_inc.php
- lang/strings_occitan.txt
- lang/strings_slovene.txt
- core/obsolete.php
- config_defaults_inc.php
- core/email_api.php
- docbook/Admin_Guide/en-US/config/email.xml
- core/classes/TimelineEvent.class.php
  • Loading branch information
dregad committed Nov 12, 2016
2 parents 24e66c5 + 5407ec7 commit b5bf07b
Show file tree
Hide file tree
Showing 85 changed files with 1,932 additions and 395 deletions.
1 change: 0 additions & 1 deletion admin/email_queue.php
Expand Up @@ -80,7 +80,6 @@
$t_email_data->email = config_get_global( 'webmaster_email' );
$t_email_data->subject = 'Testing PHP mail() function';
$t_email_data->body = 'Your PHP mail settings appear to be correctly set.';
$t_email_data->metadata['priority'] = config_get( 'mail_priority' );
$t_email_data->metadata['charset'] = 'utf-8';
$t_result = email_send( $t_email_data );

Expand Down
2 changes: 1 addition & 1 deletion api/soap/mc_issue_api.php
Expand Up @@ -1085,7 +1085,7 @@ function mc_issue_update( $p_username, $p_password, $p_issue_id, stdClass $p_iss

# The issue has been cached earlier in the bug_get() call. Flush the cache since it is
# now stale. Otherwise, the email notification will be based on the cached data.
bugnote_clear_cache( $p_issue_id );
bugnote_clear_bug_cache( $p_issue_id );
}

if( isset( $p_issue['tags'] ) && is_array( $p_issue['tags'] ) ) {
Expand Down
7 changes: 0 additions & 7 deletions config_defaults_inc.php
Expand Up @@ -580,12 +580,6 @@
*/
$g_show_user_realname_threshold = NOBODY;

/**
* Urgent = 1, Not Urgent = 5, Disable = 0
* @global integer $g_mail_priority
*/
$g_mail_priority = 0;

/**
* select the method to mail by:
* PHPMAILER_METHOD_MAIL - mail()
Expand Down Expand Up @@ -4391,7 +4385,6 @@
'logout_redirect_page',
'long_process_timeout',
'lost_password_feature',
'mail_priority',
'manage_config_cookie',
'manage_configuration_threshold',
'manage_custom_fields_threshold',
Expand Down
65 changes: 63 additions & 2 deletions core/bug_api.php
Expand Up @@ -1402,8 +1402,7 @@ function bug_delete( $p_bug_id ) {
$t_query = 'DELETE FROM {bug} WHERE id=' . db_param();
db_query( $t_query, array( $c_bug_id ) );

bug_clear_cache( $p_bug_id );
bug_text_clear_cache( $p_bug_id );
bug_clear_cache_all( $p_bug_id );
}

/**
Expand Down Expand Up @@ -2184,4 +2183,66 @@ function bug_get_status_for_assign( $p_current_handler, $p_new_handler, $p_curre
}
}
return $p_new_status;
}

/**
* Clear a bug from all the related caches or all bugs if no bug id specified.
* @param integer $p_bug_id A bug identifier to clear (optional).
* @return boolean
* @access public
*/
function bug_clear_cache_all( $p_bug_id = null ) {
bug_clear_cache( $p_bug_id );
bug_text_clear_cache( $p_bug_id );
file_bug_attachment_count_clear_cache( $p_bug_id );
bugnote_clear_bug_cache( $p_bug_id );
return true;
}

/**
* Populate the caches related to the selected columns
* @param array $p_bugs Array of BugData objects
* @param array $p_selected_columns Array of columns to show
*/
function bug_cache_columns_data( array $p_bugs, array $p_selected_columns ) {
$t_bug_ids = array();
$t_user_ids = array();
$t_project_ids = array();
$t_category_ids = array();
foreach( $p_bugs as $t_bug ) {
$t_bug_ids[] = (int)$t_bug->id;
$t_user_ids[] = (int)$t_bug->handler_id;
$t_user_ids[] = (int)$t_bug->reporter_id;
$t_project_ids[] = (int)$t_bug->project_id;
$t_category_ids[] = (int)$t_bug->category_id;
}
$t_user_ids = array_unique( $t_user_ids );
$t_project_ids = array_unique( $t_project_ids );
$t_category_ids = array_unique( $t_category_ids );

foreach( $p_selected_columns as $t_column ) {

if( column_is_plugin_column( $t_column ) ) {
$plugin_objects = columns_get_plugin_columns();
$plugin_objects[$t_column]->cache( $p_bugs );
continue;
}

switch( $t_column ) {
case 'attachment_count':
file_bug_attachment_count_cache( $t_bug_ids );
break;
case 'handler_id':
case 'reporter_id':
case 'status':
user_cache_array_rows( $t_user_ids );
break;
case 'project_id':
project_cache_array_rows( $t_project_ids );
break;
case 'category_id':
category_cache_array_rows( $t_category_ids );
break;
}
}
}
32 changes: 30 additions & 2 deletions core/bugnote_api.php
Expand Up @@ -753,10 +753,38 @@ function bugnote_clear_cache( $p_bugnote_id = null ) {

if( null === $p_bugnote_id ) {
$g_cache_bugnote = array();
$g_cache_bugnotes = array();
} else {
unset( $g_cache_bugnote[(int)$p_bugnote_id] );
if( isset( $g_cache_bugnote[(int)$p_bugnote_id] ) ) {
$t_note_obj = $g_cache_bugnote[(int)$p_bugnote_id];
# current note id will be unset in the following call
bugnote_clear_bug_cache( $t_note_obj->bug_id );
}
}
$g_cache_bugnotes = array();

return true;
}

/**
* Clear the bugnotes related to a bug, or all bugs if no bug id specified.
* @param integer $p_bug_id Identifier to clear (optional).
* @return boolean
* @access public
*/
function bugnote_clear_bug_cache( $p_bug_id = null ) {
global $g_cache_bugnotes, $g_cache_bugnote;

if( null === $p_bug_id ) {
$g_cache_bugnotes = array();
$g_cache_bugnote = array();
} else {
if( isset( $g_cache_bugnotes[(int)$p_bug_id] ) ) {
foreach( $g_cache_bugnotes[(int)$p_bug_id] as $t_note_obj ) {
unset( $g_cache_bugnote[(int)$t_note_obj->id] );
}
unset( $g_cache_bugnotes[(int)$p_bug_id] );
}
}

return true;
}
4 changes: 2 additions & 2 deletions core/classes/Avatar.class.php
Expand Up @@ -45,7 +45,7 @@ class Avatar
* plugins that can integrate with a variety of services like gravatar.com,
* LDAP, Social Identities, etc.
*
* If logged in user doesn't have access to view avatars or not avatar is found,
* If logged in user doesn't have access to view avatars or no avatar is found,
* then a default avatar will be used.
*
* Note that the provided user id may no longer has a corresponding user in the
Expand All @@ -61,7 +61,7 @@ public static function get( $p_user_id, $p_size = 80 ) {
$t_avatar = null;

if ( $t_enabled ) {
$t_user_exists = user_exists( $p_user_id );
$t_user_exists = user_exists( $p_user_id );
if ( $t_user_exists &&
access_has_project_level( config_get( 'show_avatar_threshold' ), null, $p_user_id ) ) {
$t_avatar = event_signal(
Expand Down
4 changes: 2 additions & 2 deletions core/classes/TimelineEvent.class.php
Expand Up @@ -76,8 +76,8 @@ public function html_start( $p_action_icon = 'fa-check' ) {
$t_avatar = Avatar::get( $this->user_id, 40 );
$t_html = '<div class="profile-activity clearfix">';

if( !empty( $t_avatar ) ) {
$t_html .= '<img class="pull-left" src="' . $t_avatar->image . '"/>';
if( !empty( $t_avatar ) ) {
$t_html .= '<img class="pull-left" src="' . htmlspecialchars( $t_avatar->image ) . '"/>';
} else {
$t_html .= '<i class="pull-left thumbicon fa ' . $p_action_icon . ' btn-primary no-hover"></i>';
}
Expand Down
20 changes: 0 additions & 20 deletions core/columns_api.php
Expand Up @@ -204,26 +204,6 @@ function column_is_plugin_column( $p_column ) {
return isset( $t_plugin_columns[$p_column] );
}

/**
* Allow plugin columns to pre-cache data for a set of issues
* rather than requiring repeated queries for each issue.
* If the user columns parameter is provided, only plugin columns that are
* contained in that column set will be cached.
* @param array $p_bugs Array of BugData objects.
* @param array $p_selected_columns Array of columns the user is visualizing
* @return void
*/
function columns_plugin_cache_issue_data( array $p_bugs, array $p_selected_columns = null ) {
$t_columns = columns_get_plugin_columns();
$t_all = ( null === $p_selected_columns );

foreach( $t_columns as $t_name => $t_column_object ) {
if( $t_all || in_array( $t_name, $p_selected_columns ) ) {
$t_column_object->cache( $p_bugs );
}
}
}

/**
* Get all accessible columns for the current project / current user.
* @param integer $p_project_id A project identifier.
Expand Down
7 changes: 1 addition & 6 deletions core/email_api.php
Expand Up @@ -995,11 +995,6 @@ function email_store( $p_recipient, $p_subject, $p_message, array $p_headers = n
$t_email_data->metadata = array();
$t_email_data->metadata['headers'] = $p_headers === null ? array() : $p_headers;

$t_mail_priority = config_get( 'mail_priority' );
if( $t_mail_priority != 0 ) {
$t_email_data->metadata['priority'] = $t_mail_priority;
}

# Urgent = 1, Not Urgent = 5, Disable = 0
$t_email_data->metadata['charset'] = 'utf-8';

Expand Down Expand Up @@ -1183,7 +1178,7 @@ function email_send( EmailData $p_email_data ) {
}

$t_mail->Subject = $t_subject;
$t_mail->Body = make_lf_crlf( "\n" . $t_message );
$t_mail->Body = make_lf_crlf( $t_message );

if( isset( $t_email_data->metadata['headers'] ) && is_array( $t_email_data->metadata['headers'] ) ) {
foreach( $t_email_data->metadata['headers'] as $t_key => $t_value ) {
Expand Down
90 changes: 64 additions & 26 deletions core/file_api.php
Expand Up @@ -98,45 +98,83 @@ function file_get_display_name( $p_filename ) {
}

/**
* Check the number of attachments a bug has (if any)
* @param integer $p_bug_id A bug identifier.
* @return integer
* Fills the cache with the attachement count from a list of bugs
* If the bug doesn't have attachments, cache its value as 0.
* @global array $g_cache_file_count
* @param array $p_bug_ids Array of bug ids
* @return void
*/
function file_bug_attachment_count( $p_bug_id ) {
function file_bug_attachment_count_cache( array $p_bug_ids ) {
global $g_cache_file_count;

# First check if we have a cache hit
if( isset( $g_cache_file_count[$p_bug_id] ) ) {
return $g_cache_file_count[$p_bug_id];
if( empty( $p_bug_ids ) ) {
return;
}

$t_ids_to_search = array();
foreach( $p_bug_ids as $t_id ) {
$c_id = (int)$t_id;
$t_ids_to_search[$c_id] = $c_id;
}

# If there is no cache hit, check if there is anything in
# the cache. If the cache isn't empty and we didn't have
# a hit, then there are not attachments for this bug.
if( count( $g_cache_file_count ) > 0 ) {
return 0;
db_param_push();
$t_params = array();
$t_in_values = array();
foreach( $t_ids_to_search as $t_id ) {
$t_params[] = (int)$t_id;
$t_in_values[] = db_param();
}

# Otherwise build the cache and return the attachment count
# for the given bug (if any).
$t_query = 'SELECT bug_id, COUNT(bug_id) AS attachments FROM {bug_file} GROUP BY bug_id';
$t_result = db_query( $t_query );
$t_query = 'SELECT B.id AS bug_id, COUNT(F.bug_id) AS attachments'
. ' FROM {bug} B JOIN {bug_file} F ON ( B.id = F.bug_id )'
. ' WHERE B.id IN (' . implode( ',', $t_in_values ) . ')'
. ' GROUP BY B.id';

$t_file_count = 0;
$t_result = db_query( $t_query, $t_params );
while( $t_row = db_fetch_array( $t_result ) ) {
$g_cache_file_count[$t_row['bug_id']] = $t_row['attachments'];
if( $p_bug_id == $t_row['bug_id'] ) {
$t_file_count = $t_row['attachments'];
}
$c_bug_id = (int)$t_row['bug_id'];
$g_cache_file_count[$c_bug_id] = (int)$t_row['attachments'];
unset( $t_ids_to_search[$c_bug_id] );
}

# If no attachments are present, mark the cache to avoid
# repeated queries for this.
if( count( $g_cache_file_count ) == 0 ) {
$g_cache_file_count['_no_files_'] = -1;
# set bugs without result to 0
foreach( $t_ids_to_search as $t_id ) {
$g_cache_file_count[$t_id] = 0;
}
}

return $t_file_count;
/**
* Check the number of attachments a bug has (if any)
* @param integer $p_bug_id A bug identifier.
* @return integer
*/
function file_bug_attachment_count( $p_bug_id ) {
global $g_cache_file_count;

# If it's not in cache, load the value
if( !isset( $g_cache_file_count[$p_bug_id] ) ) {
file_bug_attachment_count_cache( array( (int)$p_bug_id ) );
}

return $g_cache_file_count[$p_bug_id];
}

/**
* Clear a bug from the cache or all bugs if no bug id specified.
* @param integer $p_bug_id A bug identifier to clear (optional).
* @return boolean
* @access public
*/
function file_bug_attachment_count_clear_cache( $p_bug_id = null ) {
global $g_cache_file_count;

if( null === $p_bug_id ) {
$g_cache_file_count = array();
} else {
unset( $g_cache_file_count[(int)$p_bug_id] );
}

return true;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/filter_api.php
Expand Up @@ -2226,6 +2226,7 @@ function filter_get_bug_rows_query_clauses( array $p_filter, $p_project_id = nul

/**
* Cache the filter results with bugnote stats for later use
* also fills bug attachment count cache
* @param array $p_rows Results of the filter query.
* @param array $p_id_array_lastmod Array of bug ids.
* @return array
Expand All @@ -2234,7 +2235,6 @@ function filter_cache_result( array $p_rows, array $p_id_array_lastmod ) {
$t_stats = bug_get_bugnote_stats_array( $p_id_array_lastmod );
$t_rows = array();
foreach( $p_rows as $t_row ) {
$b = $t_stats[$t_row['id']];
if( array_key_exists( $t_row['id'], $t_stats ) ) {
$t_rows[] = bug_row_to_object( bug_cache_database_result( $t_row, $t_stats[$t_row['id']] ) );
} else {
Expand Down
4 changes: 3 additions & 1 deletion core/obsolete.php
Expand Up @@ -200,7 +200,9 @@
config_obsolete( 'hr_width' );
config_obsolete( 'db_schema' );

# changes in 1.3.4
config_obsolete( 'mail_priority' );

# changes in 2.0.0dev
config_obsolete( 'icon_path' );
config_obsolete( 'bug_print_page_fields' );

0 comments on commit b5bf07b

Please sign in to comment.