I cannot get Composer Manager to recognize installed packages. I have installed the packages from Drush. The autoloader knows about the classes and files. But the UI says none of them are installed, and I get warned about it in the admin/reports/status page.

The recent change for #2270365: RuntimeException: Error parsing file: installed.json in composer_manager_read_composer_file() (line 263 of composer_manager.admin.inc) introduced this condition in composer_manager_read_composer_file:

    if (($json = @drupal_json_decode($filedata) === NULL)) {
    }
    elseif ($json === FALSE) {
    }

(($json = @drupal_json_decode($filedata) === NULL)) could be rewritten as ($json = @drupal_json_decode($filedata) === NULL) to mean the same thing, but I actually can't tell what it means. It's hard to read code.

I'll submit a patch that says this instead:

    $json = @drupal_json_decode($filedata);
    if ($json === NULL) {
      throw new \RuntimeException(t('Error parsing file: @file', array('@file' => $file_uri)));
    }
    elseif ($json === FALSE) {
      $json = array();
    }

It works and it's much easier to read.

CommentFileSizeAuthor
#2 remove_set_in_condition-2274689-1.patch672 bytesAnonymous (not verified)

Comments

Anonymous’s picture

Issue summary: View changes
Anonymous’s picture

Status: Active » Needs review
StatusFileSize
new672 bytes
cpliakas’s picture

Good catch, change looks good. Testing it out.

cpliakas’s picture

Status: Needs review » Reviewed & tested by the community

Works great! Will commit to all relevant branches.

cpliakas’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.