aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt1
-rw-r--r--engine/lib/elgglib.php43
-rw-r--r--views/default/output/confirmlink.php2
-rw-r--r--views/default/output/url.php2
-rw-r--r--views/default/page_elements/spotlight.php4
5 files changed, 35 insertions, 17 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 4fcd086e3..9d81e9250 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -46,6 +46,7 @@ http://code.elgg.org/elgg/.....
* Added elgg_http_add_url_query_elements().
* Added elgg_register_tag_metadata_name() and elgg_get_registered_tag_metadata_names();
* Added ElggEntity::getTags().
+ * Added elgg_add_action_tokens_to_url().
Services API:
* Separated user and api authenticate processing
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 09940082c..5f3bfc9f9 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -2099,7 +2099,7 @@ function run_function_once($functionname, $timelastupdatedcheck = 0) {
/**
* Sends a notice about deprecated use of a function, view, etc.
* Note: This will ALWAYS at least log a warning. Don't use to pre-deprecate things.
- * This assume we are releasing in order and deprecating according to policy.
+ * This assumes we are releasing in order and deprecating according to policy.
*
* @param str $msg Message to log / display.
* @param str $version human-readable *release* version the function was deprecated. No bloody A, B, (R)C, or D.
@@ -2110,7 +2110,7 @@ function elgg_deprecated_notice($msg, $dep_version) {
// if it's a major release behind, visual and logged
// if it's a 2 minor releases behind, visual and logged
// if it's 1 minor release behind, logged.
- // bugfixes don't matter because you're not deprecating between the, RIGHT?
+ // bugfixes don't matter because you're not deprecating between them, RIGHT?
if (!$dep_version) {
return FALSE;
@@ -2137,12 +2137,19 @@ function elgg_deprecated_notice($msg, $dep_version) {
$msg = "Deprecated in $dep_version: $msg";
- elgg_log($msg, 'WARNING');
-
if ($visual) {
register_error($msg);
}
+ // Get a file and line number for the log. Never show this in the UI.
+ // Skip over the function that sent this notice and see who called the deprecated
+ // function itself.
+ $backtrace = debug_backtrace();
+ $caller = $backtrace[1];
+ $msg .= " (Called from {$caller['file']}:{$caller['line']})";
+
+ elgg_log($msg, 'WARNING');
+
return TRUE;
}
@@ -2553,33 +2560,43 @@ function elgg_http_build_url(array $parts) {
return $string;
}
+
/**
- * Ensures action tokens are present in the given link
+ * Adds action tokens to URL
*
* @param str $link Full action URL
- * @return str Validated URL
+ * @return str URL with action tokens
* @since 1.7
*/
-function elgg_validate_action_url($link) {
- $url = parse_url($link);
+function elgg_add_action_tokens_to_url($url) {
+ $components = parse_url($url);
- if (isset($url['query'])) {
- $query = elgg_parse_str($url['query']);
+ if (isset($components['query'])) {
+ $query = elgg_parse_str($components['query']);
} else {
$query = array();
}
if (isset($query['__elgg_ts']) && isset($query['__elgg_token'])) {
- return $link;
+ return $url;
}
// append action tokens to the existing query
$query['__elgg_ts'] = time();
$query['__elgg_token'] = generate_action_token($query['__elgg_ts']);
- $url['query'] = http_build_query($query);
+ $components['query'] = http_build_query($query);
// rebuild the full url
- return elgg_http_build_url($url);
+ return elgg_http_build_url($components);
+}
+
+/**
+ * @deprecated 1.7 final
+ */
+function elgg_validate_action_url($url) {
+ elgg_deprecated_notice('elgg_validate_action_url had a short life. Use elgg_add_action_tokens_to_url() instead.', '1.7b');
+
+ return elgg_add_action_tokens_to_url($url);
}
/**
diff --git a/views/default/output/confirmlink.php b/views/default/output/confirmlink.php
index 9377426ad..3370320ed 100644
--- a/views/default/output/confirmlink.php
+++ b/views/default/output/confirmlink.php
@@ -20,7 +20,7 @@ if (!$confirm) {
}
// always generate missing action tokens
-$link = elgg_validate_action_url($vars['href']);
+$link = elgg_add_action_tokens_to_url($vars['href']);
if (isset($vars['class']) && $vars['class']) {
$class = 'class="' . $vars['class'] . '"';
diff --git a/views/default/output/url.php b/views/default/output/url.php
index a2e659854..7d993c49e 100644
--- a/views/default/output/url.php
+++ b/views/default/output/url.php
@@ -25,7 +25,7 @@ $url = trim($vars['href']);
if (!empty($url)) {
if (array_key_exists('is_action', $vars) && $vars['is_action']) {
- $url = elgg_validate_action_url($url);
+ $url = elgg_add_action_tokens_to_url($url);
}
if (array_key_exists('target', $vars) && $vars['target']) {
diff --git a/views/default/page_elements/spotlight.php b/views/default/page_elements/spotlight.php
index 1c32f9b1d..0c7e49c0f 100644
--- a/views/default/page_elements/spotlight.php
+++ b/views/default/page_elements/spotlight.php
@@ -28,11 +28,11 @@
}
if ($closed) {
?>
- <a href="javascript:void(0);" class="toggle_box_contents" onClick="$.post('<?php echo elgg_validate_action_url("{$vars['url']}action/user/spotlight?closed=false"); ?>')">+</a>
+ <a href="javascript:void(0);" class="toggle_box_contents" onClick="$.post('<?php echo elgg_add_action_tokens_to_url("{$vars['url']}action/user/spotlight?closed=false"); ?>')">+</a>
<?php
} else {
?>
- <a href="javascript:void(0);" class="toggle_box_contents" onClick="$.post('<?php echo elgg_validate_action_url("{$vars['url']}action/user/spotlight?closed=true"); ?>')">-</a>
+ <a href="javascript:void(0);" class="toggle_box_contents" onClick="$.post('<?php echo elgg_add_action_tokens_to_url("{$vars['url']}action/user/spotlight?closed=true"); ?>')">-</a>
<?php
}