From b7e5f33894f91e74eb59eed110d9e056fa6f6e01 Mon Sep 17 00:00:00 2001 From: Rick Hoover <16406238+wopsononock@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:37:34 -0400 Subject: [PATCH 1/5] Fix notices only variables can be assigned or passed by reference --- AkismetPlugin.inc.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/AkismetPlugin.inc.php b/AkismetPlugin.inc.php index eea1655..b5d6cfc 100644 --- a/AkismetPlugin.inc.php +++ b/AkismetPlugin.inc.php @@ -69,7 +69,7 @@ function getEnabled($contextId = NULL) { * @see DAO::getAddtionalFieldNames */ function addAkismetSetting($hookname, $args) { - $fields =& $args[1]; + $fields = $args[1]; $fields = array_merge($fields, array($this->getName()."::".$this->dataUserSetting)); return false; } @@ -120,7 +120,7 @@ function manage($args, $request) { if (!Validation::isSiteAdmin()) { return new JSONMessage(false); } - $templateMgr =& TemplateManager::getManager(); + $templateMgr = TemplateManager::getManager(); $templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl')); $this->import('AkismetSettingsForm'); @@ -144,7 +144,7 @@ function manage($args, $request) { * @see Form::validate() */ function checkAkismet($hookName, $args) { - $request = Application::getRequest(); + $request = Application::get()->getRequest(); $context = $request->getContext(); $locales = array(); if (!$context) { @@ -177,7 +177,8 @@ function checkAkismet($hookName, $args) { $iso639_1 = array(); foreach (array_keys($locales) as $locale) { // Our locale names are of the form ISO639-1 + "_" + ISO3166-1 - $iso639_1[] = array_pop(explode('_', $locale, 1)); + $localeList=explode('_', $locale); + $iso639_1[] = array_pop($localeList); } $data = array_merge( $data, @@ -200,8 +201,8 @@ function checkAkismet($hookName, $args) { } else if ($hookName === 'registrationform::validate') { // remember this successful check in the session // we'll store it as a user setting on form execution - $sessionManager =& SessionManager::getManager(); - $session =& $sessionManager->getUserSession(); + $sessionManager = SessionManager::getManager(); + $session = $sessionManager->getUserSession(); $session->setSessionVar($this->getName()."::".$this->dataUserSetting, $data); } // returning false allows processing to continue @@ -246,8 +247,8 @@ function storeAkismetData($hookName, $args) { switch ($hookName) { case 'registrationform::execute': // The original data can be found in the user session, per checkAkismet() - $sessionManager =& SessionManager::getManager(); - $session =& $sessionManager->getUserSession(); + $sessionManager = SessionManager::getManager(); + $session = $sessionManager->getUserSession(); $data = $session->getSessionVar($this->getName()."::".$this->dataUserSetting); // Prior to 3.1.2 the user was passed as an argument $user = $args[1]; @@ -257,7 +258,7 @@ function storeAkismetData($hookName, $args) { $username = $form->getData('username'); $userDao = DAORegistry::getDAO('UserDAO'); $settingName = $this->getName()."::".$this->dataUserSetting; - $session->unsetSessionVar($this->getName()."::".settingName); + $session->unsetSessionVar($this->getName()."::".$settingName); // On shutdown, persist the Akismet setting to the new user account. (https://github.com/pkp/pkp-lib/issues/4601) register_shutdown_function(function() use ($username, $userDao, $settingName, $data) { $user = $userDao->getByUsername($username); @@ -415,8 +416,8 @@ function _sendPayload($data, $flag = false) { // build the Akismet HTTP request $host = $akismetKey.'.rest.akismet.com'; $path = '/1.1/' . ($flag ? 'submit-spam' : 'comment-check'); - $versionDao =& DAORegistry::getDAO('VersionDAO'); - $dbVersion =& $versionDao->getCurrentVersion(); + $versionDao = DAORegistry::getDAO('VersionDAO'); + $dbVersion = $versionDao->getCurrentVersion(); $ua = $dbVersion->getProduct().' '.$dbVersion->getVersionString().' | Akismet/3.1.7'; $httpClient = Application::get()->getHttpClient(); try {$response = $httpClient->request( From 2a5acdad50602d7e888da4bb6cbc02932ec2eed4 Mon Sep 17 00:00:00 2001 From: Rick Hoover <16406238+wopsononock@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:55:23 -0400 Subject: [PATCH 2/5] add first part of locale to array as specified --- AkismetPlugin.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AkismetPlugin.inc.php b/AkismetPlugin.inc.php index b5d6cfc..941c252 100644 --- a/AkismetPlugin.inc.php +++ b/AkismetPlugin.inc.php @@ -178,7 +178,7 @@ function checkAkismet($hookName, $args) { foreach (array_keys($locales) as $locale) { // Our locale names are of the form ISO639-1 + "_" + ISO3166-1 $localeList=explode('_', $locale); - $iso639_1[] = array_pop($localeList); + $iso639_1[] = $localeList[0]; } $data = array_merge( $data, From 3faac9def11c5088f1d18e8a4ec055cb26e27245 Mon Sep 17 00:00:00 2001 From: wopsononock <16406238+wopsononock@users.noreply.github.com> Date: Sat, 22 Jun 2024 09:26:00 -0400 Subject: [PATCH 3/5] Use PKP library to harvest locale component --- AkismetPlugin.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AkismetPlugin.inc.php b/AkismetPlugin.inc.php index 941c252..eb69ef8 100644 --- a/AkismetPlugin.inc.php +++ b/AkismetPlugin.inc.php @@ -13,7 +13,7 @@ */ import('lib.pkp.classes.plugins.GenericPlugin'); - +use PKP\i18n; class AkismetPlugin extends GenericPlugin { /** @@ -177,8 +177,8 @@ function checkAkismet($hookName, $args) { $iso639_1 = array(); foreach (array_keys($locales) as $locale) { // Our locale names are of the form ISO639-1 + "_" + ISO3166-1 - $localeList=explode('_', $locale); - $iso639_1[] = $localeList[0]; + // Store the first part of the locale + $iso639_1[] = PKPLocale::getIso1FromLocale($locale); } $data = array_merge( $data, From 8ddf4b65ff6936809091f8f3e3abeb555a7d3561 Mon Sep 17 00:00:00 2001 From: wopsononock <16406238+wopsononock@users.noreply.github.com> Date: Mon, 24 Jun 2024 15:06:41 -0400 Subject: [PATCH 4/5] Remove wrong/unneeded namespace --- AkismetPlugin.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/AkismetPlugin.inc.php b/AkismetPlugin.inc.php index eb69ef8..1eea8fc 100644 --- a/AkismetPlugin.inc.php +++ b/AkismetPlugin.inc.php @@ -13,7 +13,6 @@ */ import('lib.pkp.classes.plugins.GenericPlugin'); -use PKP\i18n; class AkismetPlugin extends GenericPlugin { /** From a1adff5046fb62067f48455674b3a343de802b88 Mon Sep 17 00:00:00 2001 From: wopsononock <16406238+wopsononock@users.noreply.github.com> Date: Tue, 9 Jul 2024 09:11:30 -0400 Subject: [PATCH 5/5] Update version number and date --- version.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.xml b/version.xml index 2a0737c..efc6a24 100644 --- a/version.xml +++ b/version.xml @@ -12,8 +12,8 @@ akismet plugins.generic - 1.2.3.1 - 2023-08-24 + 1.2.3.2 + 2024-07-09 1 AkismetPlugin