Call to undefined function api_tree_branch_exists()

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Moderators, Developers

Post Reply
Author
Message
User avatar
okeozkilic
Posts: 9
Joined: Thu Mar 24, 2011 2:54 pm
Location: Ankara / Turkey

Call to undefined function api_tree_branch_exists()

#1 Post by okeozkilic » Mon Feb 11, 2019 2:03 pm

From the log file:
- CMDPHP PHP ERROR Backtrace: (CactiShutdownHandler())
- ERROR PHP ERROR: Call to undefined function api_tree_branch_exists() in file: /usr/local/share/cacti/lib/api_automation.php on line: 2611

I recently upgraded Cacti from 1.1.37 to 1.2.1 and I started to get this error when I wanted to create graphs manually. The problem is solved (in a rough way) and I just wanted to share just in case anybody else experiences the same problem.

The 2611th line in the file api_automation.php is:

Code: Select all

        if (api_tree_branch_exists($rule['tree_id'], $parent_tree_item_id, $title)) {
                $new_item = api_tree_get_branch_id($rule['tree_id'], $parent_tree_item_id, $title);
I added

Code: Select all

        include_once($config['base_path'] . '/lib/api_tree.php');
to the function (right before the local variable declarations)

My Cacti runs in a jail on FreeBSD 12.0-p3 (custom kernel, stripped off some extras)
Dependencies were installed using "pkg, pkg-static" and Cacti code was downloaded from the Cacti home site. I have no other warnings on tech support (php, mysql are all good). The only thing that I can say is I use an older version of spine (v1.1.35) but I believe this is unrelated with this issue.

Once again thank you guys for this amazing program. Keep up the good work.
There are 10 kinds of people in the world. Those who understand binary, and those who don't...

netniV
Cacti Guru User
Posts: 2686
Joined: Sun Aug 27, 2017 12:05 am

Re: Call to undefined function api_tree_branch_exists()

#2 Post by netniV » Tue Feb 12, 2019 5:20 am

If you haven't already, could you either raise this as an issue on the GitHub site, or even better, create a pull request with the proposed fix (your name will forever be in the code history as the person who resolved it).

User avatar
okeozkilic
Posts: 9
Joined: Thu Mar 24, 2011 2:54 pm
Location: Ankara / Turkey

Re: Call to undefined function api_tree_branch_exists()

#3 Post by okeozkilic » Wed Feb 13, 2019 10:47 am

I did not do that and that actually sounds amazing.

To be honest, my solution does not look like a proper one, it is more like a workaround. I believe that the file I included in the code should be included in a more global location (not in a function). Additionally, I think I am the only one having this problem and it was a very obvious one (cannot create graphs). So may be it is because of my setup and not because of the code.
There are 10 kinds of people in the world. Those who understand binary, and those who don't...


Post Reply