From f31f94b22849226e49f08af003c7ab59e3de3ca9 Mon Sep 17 00:00:00 2001
From: eileen <emcnaughton@wikimedia.org>
Date: Thu, 1 Feb 2024 09:51:33 +1300
Subject: [PATCH] Add some deprecation warnings, annotations

---
 CRM/Contact/BAO/Query.php   |  2 ++
 CRM/Mailing/BAO/Mailing.php | 16 ++++++++++++----
 CRM/Utils/Hook.php          |  2 ++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php
index b4b6ff3d366..9249c65c5bc 100644
--- a/CRM/Contact/BAO/Query.php
+++ b/CRM/Contact/BAO/Query.php
@@ -4580,6 +4580,8 @@ civicrm_relationship.start_date > {$today}
    *
    * @return array
    * @throws \CRM_Core_Exception
+   *
+   * @deprecated since 5.71 - will be removed after all core usages are fully removed.
    */
   public static function apiQuery(
     $params = NULL,
diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php
index f6b624f4aad..74c894a22bc 100644
--- a/CRM/Mailing/BAO/Mailing.php
+++ b/CRM/Mailing/BAO/Mailing.php
@@ -1067,6 +1067,11 @@ ORDER BY   civicrm_email.is_bulkmail DESC
    * @param string $fromEmail
    *   Email address of who is forwarding it.
    *
+   * @deprecated since 5.17 will be removed around 5.74
+   *
+   * Note this REALLY should not be called anymore. I considered just removing
+   * but opted for noisy deprecation with short turn around.
+   *
    * @return Mail_mime               The mail object
    */
   public function compose(
@@ -1076,7 +1081,7 @@ ORDER BY   civicrm_email.is_bulkmail DESC
     $fromEmail = NULL
   ) {
     $this->getTokens();
-
+    CRM_Core_Error::deprecatedWarning('unused function - use flexmailer');
     if ($this->_domain == NULL) {
       $this->_domain = CRM_Core_BAO_Domain::getDomain();
     }
@@ -1300,7 +1305,7 @@ ORDER BY   civicrm_email.is_bulkmail DESC
    *
    * Get mailing object and replaces subscribeInvite, domain and mailing tokens.
    *
-   * @deprecated
+   * @deprecated since 2017 will be removed around 5.74
    *   This is used by CiviMail but will be made redundant by FlexMailer/TokenProcessor.
    * @param CRM_Mailing_BAO_Mailing $mailing
    */
@@ -1326,7 +1331,7 @@ ORDER BY   civicrm_email.is_bulkmail DESC
   /**
    * Get data to resolve tokens.
    *
-   * @deprecated
+   * @deprecated since 2017 will be removed around 5.74
    *   This is used by CiviMail but will be made redundant by FlexMailer/TokenProcessor.
    *
    * @param array $token_a
@@ -1343,7 +1348,7 @@ ORDER BY   civicrm_email.is_bulkmail DESC
     $type = $token_a['type'];
     $token = $token_a['token'];
     $data = $token;
-
+    CRM_Core_Error::deprecatedWarning('called only by deprecated function');
     $useSmarty = defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY;
 
     if ($type === 'embedded_url') {
@@ -1420,10 +1425,13 @@ ORDER BY   civicrm_email.is_bulkmail DESC
    * Return a list of group names for this mailing.  Does not work with
    * prior-mailing targets.
    *
+   * @deprecated since 5.71 will be removed around 5.77
+   *
    * @return array
    *   Names of groups receiving this mailing
    */
   public function &getGroupNames() {
+    CRM_Core_Error::deprecatedWarning('unused function');
     if (!isset($this->id)) {
       return [];
     }
diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php
index 7a9e2aa791e..0db56c1da7e 100644
--- a/CRM/Utils/Hook.php
+++ b/CRM/Utils/Hook.php
@@ -975,6 +975,8 @@ abstract class CRM_Utils_Hook {
    * @param string $className
    *   The top level className from where the hook is invoked.
    *
+   * @deprecated since 5.71 will be removed sometime after all core uses are fully removed.
+   *
    * @return null
    */
   public static function tokenValues(
-- 
GitLab