Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate:api generates incorrect case for filename / function name #84

Open
davejenx opened this issue Nov 8, 2016 · 0 comments
Open

Comments

@davejenx
Copy link

davejenx commented Nov 8, 2016

I used civix to generate boilerplate code for an API action in a module extension as follows:

civix generate:api --schedule=Daily Job PruneActionLog

This generated these files (paths redacted):

Write .../api/v3/Job/PruneActionLog.php
Write .../api/v3/Job/PruneActionLog.mgd.php

The former had this function to implement the action:

function civicrm_api3_job_PruneActionLog($params)

I then filled in the implementation.

On installing the module, the API explorer listed the new action pruneactionlog for entity Job. However on trying to run this, I got:

[error_code] => not-found
[entity] => Job
[action] => pruneactionlog
[is_error] => 1
[error_message] => API (Job, pruneactionlog) does not exist (join the API team and implement it!)

To get I working, I changed the function name to:

function civicrm_api3_job_prune_action_log($params)

API Explorer then showed action prune_action_log for entity Job and this runs successfully.

All lowercase without underscores, i.e. civicrm_api3_job_pruneactionlog, did not work. This SE answer suggests that the issue occurs on Linux but not Mac OS X and that changing the filename to first letter caps only also works. It suggests a core commit that may have brought about the change in behaviour.

So it looks as though the code that civix generates is not in line with what Civi now expects, at least on Linux.

Civix version: v16.10.1-1-gdaaa8a0
CiviCRM version: 4.6.21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant