Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-6887

civicrm_tag_create() - missing sanity check on $tagBAO

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.1
    • Fix Version/s: 3.2.4
    • Component/s: CiviCRM API
    • Labels:
      None

      Description

      In civicrm_tag_create():

      $tagBAO = CRM_Core_BAO_Tag::add($params, $ids);

      if ( is_a( $tagBAO, 'CRM_Core_Error' ) )

      { return civicrm_create_error( "Tag is not created" ); }

      else {
      $values = array( );
      _civicrm_object_to_array($tagBAO, $values);

      This code does not consider the possibility of $tagBAO being NULL / not an object,
      although NULL is clearly a possible return value, as can be seen in CRM_Core_BAO_Tag::add().

      Should be easy to fix, unless we want to do bikeshedding...

      This happens if $params['name'] is missing. It would make sense to show a useful error message, like this:

      if ( !is_object($tagBAO) )

      { return civicrm_create_error( "civicrm_tag_create() - one parameter was missing, probably 'name'." ); }

      else if ( is_a( $tagBAO, 'CRM_Core_Error' ) ) {
      ...

        Attachments

          Activity

            People

            • Assignee:
              ashwini Ashwini Poharkar
              Reporter:
              donquixote Andreas Hennings
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1 hour
                1h
                Remaining:
                Remaining Estimate - 1 hour
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified