Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
36230955
Unverified
Commit
36230955
authored
2 years ago
by
DaveD
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #24064 from eileenmcnaughton/dep_err
Log a bit more deprecation info
parents
4b4b8a02
c0a09cdc
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CRM/Core/Error.php
+15
-7
15 additions, 7 deletions
CRM/Core/Error.php
with
15 additions
and
7 deletions
CRM/Core/Error.php
+
15
−
7
View file @
36230955
...
...
@@ -1068,22 +1068,30 @@ class CRM_Core_Error extends PEAR_ErrorStack {
}
/**
* Output a deprecated function warning to log file. Deprecated class:function is automatically generated from calling function.
* Output a deprecated function warning to log file.
*
* Deprecated class:function is automatically generated from calling function.
*
* @param string $newMethod
* description of new method (eg. "buildOptions() method in the appropriate BAO object").
* @param string $oldMethod
* @param string
|null
$oldMethod
* optional description of old method (if not the calling method). eg. CRM_MyClass::myOldMethodToGetTheOptions()
*/
public
static
function
deprecatedFunctionWarning
(
$newMethod
,
$oldMethod
=
NULL
)
{
public
static
function
deprecatedFunctionWarning
(
string
$newMethod
,
?string
$oldMethod
=
NULL
):
void
{
$backtrace
=
debug_backtrace
(
DEBUG_BACKTRACE_IGNORE_ARGS
,
4
);
if
(
!
$oldMethod
)
{
$dbt
=
debug_backtrace
(
DEBUG_BACKTRACE_IGNORE_ARGS
,
2
);
$callerFunction
=
$dbt
[
1
][
'function'
]
??
NULL
;
$callerClass
=
$dbt
[
1
][
'class'
]
??
NULL
;
$callerFunction
=
$backtrace
[
1
][
'function'
]
??
NULL
;
$callerClass
=
$backtrace
[
1
][
'class'
]
??
NULL
;
$oldMethod
=
"
{
$callerClass
}
::
{
$callerFunction
}
"
;
}
$message
=
"Deprecated function
$oldMethod
, use
$newMethod
."
;
Civi
::
log
()
->
warning
(
$message
,
[
'civi.tag'
=>
'deprecated'
]);
// Add a mini backtrace. Just the function is too little to be meaningful but people are
// saying they can't track down where the deprecated calls are coming from.
$miniBacktrace
=
[];
foreach
(
$backtrace
as
$backtraceLine
)
{
$miniBacktrace
[]
=
(
$backtraceLine
[
'class'
]
??
''
)
.
'::'
.
(
$backtraceLine
[
'function'
]
??
''
);
}
Civi
::
log
()
->
warning
(
$message
.
"
\n
"
.
implode
(
"
\n
"
,
$miniBacktrace
),
[
'civi.tag'
=>
'deprecated'
]);
trigger_error
(
$message
,
E_USER_DEPRECATED
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment