Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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).
Comment | File | Size | Author |
---|---|---|---|
#1 | 1418084.patch | 664 bytes | jhodgdon |
Comments
Comment #1
jhodgdonAh. The problem is here in api_enable():
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).
Comment #2
jhodgdonThis is committed:
http://drupalcode.org/project/api.git/commit/b710908