If you disable and then immediately re-enable the API module, the hook_enable() code gives you this error:

User warning: Duplicate entry 'php-php' for key 'project_name' query: INSERT INTO api_branch (branch_name, project, type, data, status, title, project_title, weight) VALUES ('php', 'php', 'php', 'a:2:{s:7:\"summary\";s:67:\"http://svn.php.net/repository/phpdoc/doc-base/trunk/funcsummary.txt\";s:4:\"path\";s:24:\"http://php.net/!function\";}', 0, 'PHP functions', 'php', 0) in _db_query() (line 134 of /opt/www/apisite/includes/database.mysqli.inc).

CommentFileSizeAuthor
#1 1418084.patch664 bytesjhodgdon
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Priority: Normal » Minor
Status: Active » Reviewed & tested by the community
FileSize
664 bytes

Ah. The problem is here in api_enable():

  $names = api_get_branch_names();
  if (!isset($names['php'])) {
    // Save PHP branch
...

api_get_branch_names() only returns the names of branches whose status is 1. But the PHP branches have status=0, so this isset() is always returning FALSE, even though the branch exists.

So I think we just need to do our own query here for a branch with name 'php' instead of calling api_get_branch_names().

Here's a patch... it appears to work both for disable/enable on an existing API site, and for enabling the API module for the first time.

I plan to commit it after the next release (in a week or two).

jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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