From 3bb2646b5e1b1fb570fa177bb4febca5293177c1 Mon Sep 17 00:00:00 2001 From: Nigel Banks Date: Tue, 30 Apr 2013 16:51:17 +0200 Subject: [PATCH 1/2] Added a convience function for generated depreciated function messages. The message will only be displayed to the user if Drupal is configured to show these warnings, regardless of the setting though it will be logged to the watchdog. --- includes/utilities.inc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/includes/utilities.inc b/includes/utilities.inc index fbc4585a..aac770e2 100644 --- a/includes/utilities.inc +++ b/includes/utilities.inc @@ -817,3 +817,36 @@ function islandora_content_model_select_table_form_element($drupal_variable, $de return $element; } + +/** + * Convience function for generating a E_USER_DEPRECATED message. + * + * To utilitize this function pass the results to trigger_error() like so: + * + * @code + * $message = islandora_deprecated('7.x-1.1', t('Use more cowbell.')); + * trigger_error($message, E_USER_DEPRECATED); + * @endcode + * + * @param string $release + * The release the calling function was depreciated in. + * @param string $solution + * A message describing an alternative solution to the deprecated function. + * It's assumed to be already passed though the t() function. + * + * @return string + * The deprecated message. + */ +function islandora_deprecated($release, $solution = NULL) { + $bt = debug_backtrace(); + assert($bt[0]['function'] == __FUNCTION__); + $function = $bt[1]['function']; + $message = t('@function() has been deprecated. As of @release, please update your code before the next release.', array( + '@function' => $function, + '@release' => $release, + )); + if (isset($solution)) { + $message .= "
\n" . $solution; + } + return $message; +} From 5fac157cfcb08b9a647c6c70c8ec5ae75baa009c Mon Sep 17 00:00:00 2001 From: Nigel Banks Date: Tue, 30 Apr 2013 18:37:34 +0200 Subject: [PATCH 2/2] Appease the Travis God! The one true build master! May my code be clean, and follow the law's of "standard". May it support internationalization for Travis includes all! May it not contain copy pasta for it is soggy. Travis be praised! --- includes/utilities.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/utilities.inc b/includes/utilities.inc index aac770e2..57bf03ba 100644 --- a/includes/utilities.inc +++ b/includes/utilities.inc @@ -825,7 +825,7 @@ function islandora_content_model_select_table_form_element($drupal_variable, $de * * @code * $message = islandora_deprecated('7.x-1.1', t('Use more cowbell.')); - * trigger_error($message, E_USER_DEPRECATED); + * trigger_error(check_plain($message), E_USER_DEPRECATED); * @endcode * * @param string $release