Skip to content

Commit

Permalink
Merge pull request #7 from ulsdevteam/php8
Browse files Browse the repository at this point in the history
Fix Php8 notices and related bug
  • Loading branch information
wopsononock authored Jul 9, 2024
2 parents a463d0b + a1adff5 commit d224546
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions AkismetPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/

import('lib.pkp.classes.plugins.GenericPlugin');

class AkismetPlugin extends GenericPlugin {

/**
Expand Down Expand Up @@ -69,7 +68,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;
}
Expand Down Expand Up @@ -120,7 +119,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');
Expand All @@ -144,7 +143,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) {
Expand Down Expand Up @@ -177,7 +176,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));
// Store the first part of the locale
$iso639_1[] = PKPLocale::getIso1FromLocale($locale);
}
$data = array_merge(
$data,
Expand All @@ -200,8 +200,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
Expand Down Expand Up @@ -246,8 +246,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];
Expand All @@ -257,7 +257,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);
Expand Down Expand Up @@ -415,8 +415,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(
Expand Down
4 changes: 2 additions & 2 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<version>
<application>akismet</application>
<type>plugins.generic</type>
<release>1.2.3.1</release>
<date>2023-08-24</date>
<release>1.2.3.2</release>
<date>2024-07-09</date>
<lazy-load>1</lazy-load>
<class>AkismetPlugin</class>
</version>

0 comments on commit d224546

Please sign in to comment.