Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix return type error #205

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions includes/class-wporg-notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ private static function get_pte_clpte_email_addresses_by_project_and_locale( int
}

$project = self::get_project_from_original_id( $original_id );
if ( ! $project ) {
return array();
}
// todo: remove the deleted users in the SQL query.
$translation_editors = $wpdb->get_results(
$wpdb->prepare(
Expand Down Expand Up @@ -377,6 +380,9 @@ public static function get_author_email_address( int $original_id ): array {

$email_addresses = array();
$project = GP_Notifications::get_project_from_original_id( $original_id );
if ( ! $project ) {
return array();
}
if ( 'wp-themes' === substr( $project->path, 0, 9 ) ) {
$author = $wpdb->get_row(
$wpdb->prepare(
Expand Down Expand Up @@ -509,12 +515,19 @@ private static function get_project_from_post_id( int $post_id ) {
*
* @param int $original_id The id of the original string used for the discussion.
*
* @return GP_Project The project the original_id belongs to.
* @return false|GP_Project The project the original_id belongs to.
*/
public static function get_project_from_original_id( int $original_id ): GP_Project {
public static function get_project_from_original_id( int $original_id ) {
$original = GP::$original->get( $original_id );
if ( ! $original ) {
return false;
}
$project_id = $original->project_id;
$project = GP::$project->get( $project_id );

if ( ! $project ) {
return false;
}
$main_projects = self::get_main_projects();

// If the parent project is not a main project, get the parent project. We need to do this
Expand Down Expand Up @@ -693,6 +706,9 @@ public static function is_user_an_author_of_the_project( int $original_id, WP_Us
*/
public static function is_an_special_user_in_a_special_project( int $original_id, WP_User $user ):bool {
$project = self::get_project_from_original_id( $original_id );
if ( ! $project ) {
return false;
}
if ( 'wp-themes' !== substr( $project->path, 0, 9 ) && ( 'wp-plugins' !== substr( $project->path, 0, 10 ) ) ) {
if ( empty( self::$i18n_email ) || empty( array_intersect( array( $user->user_email ), self::$i18n_email ) ) ) {
return false;
Expand Down