createdb not auto-prefixing after update

mainescott

Registered
Oct 14, 2015
2
0
1
Maine, USA
cPanel Access Level
Website Owner
My host updated CPanel this morning, supposedly from 11.50.2.2 to 11.52.0.14. I have been using the api2 API for some time to auto-provision databases and users and this morning after the update those calls started failing with an error that the specified database name does not start with the appropriate prefix. Which is true, but in the past I never had to specify the prefix, it was just added automatically by CPanel.

I can obviously change my code to add the prefix to the database name, but it just seems odd to me that the behavior changed. I looked through the 11.52 change log and I didn't see any topics that looked like they obviously applied to this situation, so I'm concerned that I'll modify my code and later the behavior will change again and I'll start getting double-prefixed database names or something.

Does anyone have any insight on whether I should have expected this change or if there's something else I should take a look at before I modify my code?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,205
363
Hello :)

I suggest updating your script to utilize UAPI instead of cPanel API2:

UAPI Functions - Mysql::create_database - Software Development Kit - cPanel Documentation
UAPI Functions - Mysql::create_user - Software Development Kit - cPanel Documentation

Per the documentation for these functions:

If database prefixing is enabled, you must prefix this value with the account prefix and an underscore (_).

For example, to create the newdb database on the user cPanel account, pass a value of user_newdb.
That being said, should you continue to use cPanel API2, no additional changes are expected because if the desired function is available, users are recommend to use our newer UAPI functions.

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,205
363
Faced with identical situation, so I completely agree with mainescott and I have to contribute to its question.
Hello :)

This question is answered in my earlier response. Per the document:

If database prefixing is enabled, you must prefix this value with the account prefix and an underscore (_).
Thank you.