Replace Deprecated Class references with their main class name - #68
Replace Deprecated Class references with their main class name#68seamuslee001 wants to merge 1 commit into
Conversation
|
@seamuslee001 what inspired this PR? I'm actually auto-opening these on every extension throughout |
|
@colemanw partially seeing you doing things and also partially because I have been working on improving the code on a client site where this one is installed and figured better to do this upstream |
|
Cool. FYI there were thousands of references to these deprecated classes throughout |
Does this mean I might have duplicate PRs on dozens of my projects? I'm sure that's better than none at all, but it would make some degree of double work for developers to process the PRs. @seamuslee001 @colemanw |
AFAIK @seamuslee001 only opened this one PR. I'm the one with the machine gun 🔫🤓 |
|
Great. We should totally hang out, then. 👍 |
|
Holding on this PR (and any similar ones in other projects), pending an answer to https://civicrm.stackexchange.com/questions/49930/does-crm-core-exception-support-detecting-api-specific-errors-api-exception-is |
|
Did my best to answer @twomice although I'm afraid the answer's not great. |
|
+1 for the effort. ❤️ |
|
I'll take it. 🤣 I mean, aside from causing you an existential crisis, it doesn't actually block this PR. Like it or not, the classes were merged upstream (don't blame me, @totten did it 😅) so referencing the alias instead of the canonical class name doesn't help you any. |
Wait, do you mean that |
|
@twomice No, I mean that the classes are completely interchangeable. As far as php is concerned it doesn't matter what you call them, they are the same class, so CRM_Core_Exception === API_Exception === CiviCRM_API3_ExceptionWhich means you can do something like: try {
throw new CRM_Core_Exception('Who cares?');
}
catch (API_Exception $e) {
print $e->getMessage();
}This will print |
|
Got it, thanks! |
As per the code docs here https://github.com/civicrm/civicrm-core/blob/master/api/Exception.php#L16 this replaces deprecated class references with their main class name
cc @colemanw @twomice