Important $w Array Update

Link: https://support.brilliantdirectories.com/support/solutions/articles/12000048956-important-w-array-update

As of November 1st, 2018, several keys found in the $w array will no longer be available in this array and will only be available through the new static method brilliantDirectories::getDatabaseConfiguration() for enhanced security.  


IMPORTANT: If there is any custom code on your website that makes reference to these keys in the $w array, please make sure to update those references following the instructions below before November 1st, 2018 to avoid any issues.


Here is the list of keys that will be impacted:

  • website_user
  • website_pass
  • database_user
  • database_pass
  • database_host
  • database
  • database_directory_user
  • database_directory_pass
  • whmcs_database_host
  • whmcs_database_user
  • whmcs_database_password
  • whmcs_database_name
  • whmcs_api_password
  • whmcs_api_host
  • whmcs_api_username



Updating References to These Keys


The brilliantDirectories::getDatabaseConfiguration() static method is available as of the writing of this article (September 4, 2018), and the keys will remain accessible in both the $w array and the new static method over the next 8 weeks so websites have the opportunity to update any custom widgets, files, member features / Post Types, or other code that are currently referencing these keys in the $w array.


All of the keys will follow the same naming convention, but will be accessed using the static method instead.


To update a piece of code, simply replace the reference to the key in the $w array by sending the key as a parameter in the brilliantDirectories::getDatabaseConfiguration() method.


For example, a reference to the website_user key in the $w array like this:

$w['website_user']


or like this:

$w[website_user]


would be updated by sending this same key as a parameter to the static method brilliantDirectories::getDatabaseConfiguration():


brilliantDirectories::getDatabaseConfiguration('website_user')



As another example, let's take this piece of code referencing the 'database' key in the $w array:

$membersQuery = mysql($w['database'],"SELECT 
        * 
    FROM 
        `users_data`");


Using the new static method, it would be updated to the following:


$membersQuery = mysql(brilliantDirectories::getDatabaseConfiguration('database'),"SELECT 
        * 
    FROM 
        `users_data`");