After enabling a module that contains a composer.json file, and disabling that module, composer removes the package needed by the module.

When accessing the status report or admin/config page, all I get is this exception:

RuntimeException: Error parsing file: installed.json in composer_manager_read_composer_file() (line 263 of composer_manager.admin.inc)

When I look at the installed.json file, it contains "[]" which is valid JSON for an empty array. This error is very annoying as it makes it impossible to administer the drupal site, until i re-enable a module that installs composer packages.

Comments

esbenvb’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new709 bytes

Since the json file contains an empty array, this is interpreted as FALSE in the if-statement.

Also, it appears that json_decode returns FALSE when parsing an empty array, and NULL when a parse error is present.
http://www.php.net/manual/en/function.json-decode.php

This patch should fix it. Tested with PHP 5.5.

cpliakas’s picture

Status: Needs review » Reviewed & tested by the community

Great catch! I was able to replicate the bug and confirm that the patch fixes it.

  • Commit 0efc104 on 7.x-1.x authored by esbenvb, committed by cpliakas:
    Issue #2270365 by esbenvb: RuntimeException: Error parsing file:...

  • Commit 7d274ea on 7.x-2.x authored by esbenvb, committed by cpliakas:
    Issue #2270365 by esbenvb: RuntimeException: Error parsing file:...

  • Commit 45588f6 on 6.x-1.x authored by esbenvb, committed by cpliakas:
    Issue #2270365 by esbenvb: RuntimeException: Error parsing file:...

  • Commit 992f088 on 6.x-2.x authored by esbenvb, committed by cpliakas:
    Issue #2270365 by esbenvb: RuntimeException: Error parsing file:...
cpliakas’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the contribution!

cpliakas’s picture

cpliakas’s picture

Changed introduced a regression as noted at #2274689: Composer Manager does not recognize installed packages..

Status: Fixed » Closed (fixed)

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