Skip to content

Commit b9945e0

Browse files
committed
Avoid throwing exceptions in Babble_Taxonomies::get_transid() and Babble_Taxonomies::set_transid(). See #218.
1 parent 995c394 commit b9945e0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

class-taxonomy.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -911,15 +911,15 @@ function update_post_term_count( $terms, $taxonomy ) {
911911
* belongs to.
912912
*
913913
* @param int $target_term_id The term ID to find the translation group for
914-
* @return int The transID the target term belongs to
914+
* @return int|false The transID the target term belongs to, boolean false on failure
915915
**/
916916
public function get_transid( $target_term_id ) {
917-
if ( $transid = wp_cache_get( $target_term_id, 'bbl_term_transids' ) ) {
918-
return $transid;
917+
if ( ! $target_term_id ) {
918+
return false;
919919
}
920920

921-
if ( ! $target_term_id ) {
922-
throw new exception( "Please specify a target term_id" );
921+
if ( $transid = wp_cache_get( $target_term_id, 'bbl_term_transids' ) ) {
922+
return $transid;
923923
}
924924

925925
$transids = wp_get_object_terms( $target_term_id, 'term_translation', array( 'fields' => 'ids' ) );
@@ -941,11 +941,11 @@ public function get_transid( $target_term_id ) {
941941
*
942942
* @param int $target_term_id The term ID to set the translation group for
943943
* @param int $translation_group_id The ID of the translation group to add this
944-
* @return int The transID the target term belongs to
944+
* @return int|false The transID the target term belongs to, false on failure
945945
**/
946946
public function set_transid( $target_term_id, $transid = null ) {
947947
if ( ! $target_term_id ) {
948-
throw new exception( "Please specify a target term_id" );
948+
return false;
949949
}
950950

951951
if ( ! $transid ) {

0 commit comments

Comments
 (0)