Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
BRIC
dokuwiki
Commits
8458d4b0
Unverified
Commit
8458d4b0
authored
6 years ago
by
Andreas Gohr
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #2409 from splitbrain/deprecationevent
introduce INFO_DEPRECATION_LOG event
parents
724970e6
85331086
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inc/events.php
+18
-0
18 additions, 0 deletions
inc/events.php
inc/infoutils.php
+27
-13
27 additions, 13 deletions
inc/infoutils.php
with
45 additions
and
13 deletions
inc/events.php
+
18
−
0
View file @
8458d4b0
...
...
@@ -234,6 +234,24 @@ class Doku_Event_Handler {
}
}
}
/**
* Check if an event has any registered handlers
*
* When $advise is empty, both BEFORE and AFTER events will be considered,
* otherwise only the given advisory is checked
*
* @param string $name Name of the event
* @param string $advise BEFORE, AFTER or empty
* @return bool
*/
public
function
hasHandlerForEvent
(
$name
,
$advise
=
''
)
{
if
(
$advise
)
{
return
isset
(
$this
->
_hooks
[
$name
.
'_'
.
$advise
]);
}
else
{
return
isset
(
$this
->
_hooks
[
$name
.
'_BEFORE'
])
||
isset
(
$this
->
_hooks
[
$name
.
'_AFTER'
]);
}
}
}
/**
...
...
This diff is collapsed.
Click to expand it.
inc/infoutils.php
+
27
−
13
View file @
8458d4b0
...
...
@@ -441,26 +441,40 @@ function dbglog($msg,$header=''){
* Log accesses to deprecated fucntions to the debug log
*
* @param string $alternative The function or method that should be used instead
* @triggers INFO_DEPRECATION_LOG
*/
function
dbg_deprecated
(
$alternative
=
''
)
{
global
$conf
;
if
(
!
$conf
[
'allowdebug'
])
return
;
global
$EVENT_HANDLER
;
if
(
!
$conf
[
'allowdebug'
]
&&
!
$EVENT_HANDLER
->
hasHandlerForEvent
(
'INFO_DEPRECATION_LOG'
))
{
// avoid any work if no one cares
return
;
}
$backtrace
=
debug_backtrace
();
array_shift
(
$backtrace
);
$self
=
array_shift
(
$backtrace
);
$call
=
array_shift
(
$backtrace
);
$called
=
trim
(
$self
[
'class'
]
.
'::'
.
$self
[
'function'
]
.
'()'
,
':'
);
$caller
=
trim
(
$call
[
'class'
]
.
'::'
.
$call
[
'function'
]
.
'()'
,
':'
);
$msg
=
$called
.
' is deprecated. It was called from '
;
$msg
.
=
$caller
.
' in '
.
$call
[
'file'
]
.
':'
.
$call
[
'line'
];
if
(
$alternative
)
{
$msg
.
=
' '
.
$alternative
.
' should be used instead!'
;
$self
=
$backtrace
[
0
];
$call
=
$backtrace
[
1
];
$data
=
[
'trace'
=>
$backtrace
,
'alternative'
=>
$alternative
,
'called'
=>
trim
(
$self
[
'class'
]
.
'::'
.
$self
[
'function'
]
.
'()'
,
':'
),
'caller'
=>
trim
(
$call
[
'class'
]
.
'::'
.
$call
[
'function'
]
.
'()'
,
':'
),
'file'
=>
$call
[
'file'
],
'line'
=>
$call
[
'line'
],
];
$event
=
new
Doku_Event
(
'INFO_DEPRECATION_LOG'
,
$data
);
if
(
$event
->
advise_before
())
{
$msg
=
$event
->
data
[
'called'
]
.
' is deprecated. It was called from '
;
$msg
.
=
$event
->
data
[
'caller'
]
.
' in '
.
$event
->
data
[
'file'
]
.
':'
.
$event
->
data
[
'line'
];
if
(
$event
->
data
[
'alternative'
])
{
$msg
.
=
' '
.
$event
->
data
[
'alternative'
]
.
' should be used instead!'
;
}
dbglog
(
$msg
);
}
dbglog
(
$msg
);
$event
->
advise_after
();
}
/**
...
...
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