original_string: public static function resolve_category_by_idnumber($idnumber) {
          global $DB;
          $cache = cache::make('tool_uploadcourse', 'helper');
          $cachekey = 'cat_idn_' . $idnumber;
          if (($id = $cache->get($cachekey)) === false) {
              $params = array('idnumber' => $idnumber);
              $id = $DB->get_field_select('course_categories', 'id', 'idnumber = :idnumber', $params, IGNORE_MISSING);
  
              // Little hack to be able to differenciate between the cache not set and a category not found.
              if ($id === false) {
                  $id = -1;
              }
  
              $cache->set($cachekey, $id);
          }
  
          // Little hack to be able to differenciate between the cache not set and a category not found.
          if ($id == -1) {
              $id = false;
          }
  
          return $id;
      }
code: public static function resolve_category_by_idnumber($idnumber) {
          global $DB;
          $cache = cache::make('tool_uploadcourse', 'helper');
          $cachekey = 'cat_idn_' . $idnumber;
          if (($id = $cache->get($cachekey)) === false) {
              $params = array('idnumber' => $idnumber);
              $id = $DB->get_field_select('course_categories', 'id', 'idnumber = :idnumber', $params, IGNORE_MISSING);
  
              // Little hack to be able to differenciate between the cache not set and a category not found.
              if ($id === false) {
                  $id = -1;
              }
  
              $cache->set($cachekey, $id);
          }
  
          // Little hack to be able to differenciate between the cache not set and a category not found.
          if ($id == -1) {
              $id = false;
          }
  
          return $id;
      }
code_tokens: public static function resolve_category_by_idnumber ( $ idnumber ) { global $ DB ; $ cache = cache :: make ( 'tool_uploadcourse' , 'helper' ) ; $ cachekey = 'cat_idn_' . $ idnumber ; if ( ( $ id = $ cache -> get ( $ cachekey ) ) === false ) { $ params = array ( 'idnumber' => $ idnumber ) ; $ id = $ DB -> get_field_select ( 'course_categories' , 'id' , 'idnumber = :idnumber' , $ params , IGNORE_MISSING ) ; // Little hack to be able to differenciate between the cache not set and a category not found. if ( $ id === false ) { $ id = - 1 ; } $ cache -> set ( $ cachekey , $ id ) ; } // Little hack to be able to differenciate between the cache not set and a category not found. if ( $ id == - 1 ) { $ id = false ; } return $ id ; }
docstring: Resolve a category by ID number.
  
  @param string $idnumber category ID number.
  @return int category ID.
docstring_tokens: Resolve a category by ID number .