Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WP Plugins
Cron-Control
Commits
2f22edc2
Commit
2f22edc2
authored
Mar 17, 2017
by
Erick Hitter
Browse files
Review feedback: remove outdated function
parent
5f2942d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
includes/class-events-store.php
View file @
2f22edc2
...
...
@@ -273,81 +273,6 @@ class Events_Store extends Singleton {
return
$jobs
;
}
/**
* Retrieve a single event by ID, or by a combination of its timestamp, instance identifier, and either action or the action's hashed representation
*
* @param array $attrs Array of event attributes to query by
* @return object|false
*/
public
function
get_job
(
$attrs
)
{
global
$wpdb
;
// Validate basic inputs
if
(
!
is_array
(
$attrs
)
||
empty
(
$attrs
)
)
{
return
false
;
}
// Validate requested status
$allowed_status
=
self
::
ALLOWED_STATUSES
;
$allowed_status
[]
=
'any'
;
if
(
!
isset
(
$attrs
[
'status'
]
)
||
!
in_array
(
$attrs
[
'status'
],
$allowed_status
,
true
)
)
{
$attrs
[
'status'
]
=
self
::
STATUS_PENDING
;
}
// Validate attributes provided to query for a post
$query
=
null
;
$query_replacements
=
array
();
if
(
isset
(
$attrs
[
'ID'
]
)
)
{
$query
=
"SELECT * FROM
{
$this
->
get_table_name
()
}
WHERE ID = %d"
;
$query_replacements
[]
=
$attrs
[
'ID'
];
}
else
{
// Need a timestamp, an instance, and either an action or its hashed representation
if
(
!
isset
(
$attrs
[
'timestamp'
]
)
||
!
isset
(
$attrs
[
'instance'
]
)
)
{
return
false
;
}
elseif
(
!
isset
(
$attrs
[
'action'
]
)
&&
!
isset
(
$attrs
[
'action_hashed'
]
)
)
{
return
false
;
}
// Build query
if
(
isset
(
$attrs
[
'action'
]
)
)
{
$action_column
=
'action'
;
$action_value
=
$attrs
[
'action'
];
}
else
{
$action_column
=
'action_hashed'
;
$action_value
=
$attrs
[
'action_hashed'
];
}
// Do not sort, otherwise index isn't used
$query
=
"SELECT * FROM
{
$this
->
get_table_name
()
}
WHERE timestamp = %d AND
{
$action_column
}
= %s AND instance = %s"
;
$query_replacements
[]
=
$attrs
[
'timestamp'
];
$query_replacements
[]
=
$action_value
;
$query_replacements
[]
=
$attrs
[
'instance'
];
}
// Final query preparations
if
(
'any'
!==
$attrs
[
'status'
]
)
{
$query
.
=
' AND status = %s'
;
$query_replacements
[]
=
$attrs
[
'status'
];
}
$query
.
=
' LIMIT 1'
;
$query
=
$wpdb
->
prepare
(
$query
,
$query_replacements
);
// Query and format results
$job
=
$wpdb
->
get_row
(
$query
);
if
(
is_object
(
$job
)
&&
!
is_wp_error
(
$job
)
)
{
$job
=
$this
->
format_job
(
$job
);
}
else
{
$job
=
false
;
}
return
$job
;
}
/**
* Retrieve a single event by its ID
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment