Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BackwardCompatibility Refactor #7931

Merged
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
8c5d974
Initital commit
tyrsson Dec 3, 2023
38178a8
Removes test call in Forum
tyrsson Dec 3, 2023
fb6a918
Moves Backward compat functions to Subs-Compat
tyrsson Dec 4, 2023
2a30d9a
Restores BackwardCompatibility for class props to
tyrsson Dec 4, 2023
3c6fed9
Signed-off-by: Joey Smith <[email protected]>
tyrsson Dec 4, 2023
5fe7a54
Merge branch 'release-3.0' into remove-backwards-compatibility
tyrsson Dec 4, 2023
4c918ea
Finishes all Actions\Admin\* classes for backward
tyrsson Dec 4, 2023
c428468
Corrects invalid return
tyrsson Dec 4, 2023
e2c39ee
Completes Sources/Actions/Profile/*
tyrsson Dec 5, 2023
ebb867d
Merge branch 'release-3.0' into remove-backwards-compatibility
tyrsson Dec 5, 2023
d74850a
Signed-off-by: Joey Smith <[email protected]>
tyrsson Dec 5, 2023
0115dbd
Merge branch 'release-3.0' into remove-backwards-compatibility
tyrsson Dec 5, 2023
cabdf73
Finishes Actions\* classes up to MsgDelete
tyrsson Dec 7, 2023
29d2d83
Merge branch 'release-3.0' into remove-backwards-compatibility
tyrsson Dec 7, 2023
8a01d6b
Finishes Sources/Actions/*
tyrsson Dec 9, 2023
b10b9ff
Merge branch 'release-3.0' into remove-backwards-compatibility
tyrsson Dec 9, 2023
a75ce7b
Introduces provider and factory method in Backcompat Trait
tyrsson Dec 12, 2023
56ec028
Merge branch 'release-3.0' into remove-backwards-compatibility
tyrsson Dec 12, 2023
9fb3118
Fixed oversights
tyrsson Dec 12, 2023
8a1de63
Signed-off-by: Joey Smith <[email protected]>
tyrsson Dec 12, 2023
1b6bf1a
Complete Backward Compat refactor up to removal of deprecated methods.
tyrsson Dec 17, 2023
fead521
Removes the no longer needed class_exist calls in the back compat stu…
tyrsson Dec 17, 2023
a0f53df
Fixed types and replaced the copy/paste errors with the Class referen…
tyrsson Dec 20, 2023
ac1e085
Merge branch 'release-3.0' into remove-backwards-compatibility
tyrsson Dec 23, 2023
6edbcb1
Introduces two additional Backcompat traits for Actions and Profile
tyrsson Jan 2, 2024
72d6325
Merge branch 'release-3.0' into remove-backwards-compatibility
tyrsson Jan 2, 2024
aae267b
Provides nullable return type for Theme::loadTemplate()
tyrsson Jan 2, 2024
c4d2799
Adds blank lines and closing tags to new traits
tyrsson Jan 2, 2024
fcd682a
Signed-off-by: Joey Smith <[email protected]>
tyrsson Jan 2, 2024
d7e4f5e
License block...
tyrsson Jan 2, 2024
114e6cc
Merge branch 'copyright-update' into remove-backwards-compatibility
tyrsson Jan 2, 2024
6cc54c0
Merge branch 'release-3.0' into remove-backwards-compatibility
tyrsson Jan 8, 2024
1a55abf
Conflict resolution
tyrsson Jan 8, 2024
3a5f172
php-cs-fixer tidy up
tyrsson Jan 12, 2024
5cba03f
Merge branch 'release-3.0' into remove-backwards-compatibility
tyrsson Jan 12, 2024
eec0354
Missing \
tyrsson Jan 12, 2024
e5a5b32
Removes not needed const import.
tyrsson Jan 12, 2024
2a9e42b
Merge branch 'release-3.0' into remove-backwards-compatibility
tyrsson Jan 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions Sources/Actions/Activate.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace SMF\Actions;

use SMF\BackwardCompatibility;
use SMF\Config;
use SMF\Db\DatabaseApi as Db;
use SMF\ErrorHandler;
Expand All @@ -31,19 +30,6 @@
*/
class Activate implements ActionInterface
{
use BackwardCompatibility;

/**
* @var array
*
* BackwardCompatibility settings for this class.
*/
private static $backcompat = [
'func_names' => [
'call' => 'Activate',
],
];

/*******************
* Public properties
*******************/
Expand Down Expand Up @@ -289,9 +275,4 @@ protected function __construct()
}
}

// Export public static functions and properties to global namespace for backward compatibility.
if (is_callable(__NAMESPACE__ . '\\Activate::exportStatic')) {
Activate::exportStatic();
}

?>
31 changes: 3 additions & 28 deletions Sources/Actions/Admin/ACP.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use SMF\Actions\ActionInterface;
use SMF\Actions\MessageIndex;
use SMF\Actions\Notify;
use SMF\BackwardCompatibility;
use SMF\BBCodeParser;
use SMF\Cache\CacheApi;
use SMF\Config;
Expand All @@ -37,27 +36,6 @@
*/
class ACP implements ActionInterface
{
use BackwardCompatibility;

/**
* @var array
*
* BackwardCompatibility settings for this class.
*/
private static $backcompat = [
'func_names' => [
'call' => 'AdminMain',
'prepareDBSettingContext' => 'prepareDBSettingContext',
'saveSettings' => 'saveSettings',
'saveDBSettings' => 'saveDBSettings',
'getServerVersions' => 'getServerVersions',
'getFileVersions' => 'getFileVersions',
'updateAdminPreferences' => 'updateAdminPreferences',
'emailAdmins' => 'emailAdmins',
'adminLogin' => 'adminLogin',
],
];

/*******************
* Public properties
*******************/
Expand Down Expand Up @@ -1434,7 +1412,7 @@ public static function saveDBSettings(&$config_vars)
* @param array $checkFor An array of what to check versions for - can contain one or more of 'gd', 'imagemagick', 'db_server', 'phpa', 'memcache', 'php' or 'server'
* @return array An array of versions (keys are same as what was in $checkFor, values are the versions)
*/
public static function getServerVersions($checkFor)
public static function getServerVersions(array $checkFor)
{
Lang::load('Admin');
Lang::load('ManageSettings');
Expand Down Expand Up @@ -2006,6 +1984,8 @@ protected static function adminLogin_outputPostVars($k, $v)
/**
* Properly urlencodes a string to be used in a query.
*
* todo: fix typing
*
* @param string $get A copy of $_GET.
* @return string Our query string.
*/
Expand Down Expand Up @@ -2042,9 +2022,4 @@ protected static function construct_query_string($get)
}
}

// Export public static functions and properties to global namespace for backward compatibility.
if (is_callable(__NAMESPACE__ . '\\ACP::exportStatic')) {
ACP::exportStatic();
}

?>
19 changes: 2 additions & 17 deletions Sources/Actions/Admin/AntiSpam.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace SMF\Actions\Admin;

use SMF\Actions\ActionInterface;
use SMF\BackwardCompatibility;
use SMF\Actions\BackwardCompatibility;
use SMF\Cache\CacheApi;
use SMF\Config;
use SMF\Db\DatabaseApi as Db;
Expand All @@ -32,17 +32,6 @@ class AntiSpam implements ActionInterface
{
use BackwardCompatibility;

/**
* @var array
*
* BackwardCompatibility settings for this class.
*/
private static $backcompat = [
'func_names' => [
'modifyAntispamSettings' => 'ModifyAntispamSettings',
],
];

/****************************
* Internal static properties
****************************/
Expand Down Expand Up @@ -466,6 +455,7 @@ public static function getConfigVars(): array
*
* @param bool $return_config Whether to return the config_vars array.
* @return void|array Returns nothing or returns the config_vars array.
* @deprecated since 3.0
*/
public static function modifyAntispamSettings($return_config = false)
{
Expand All @@ -489,9 +479,4 @@ protected function __construct()
}
}

// Export public static functions and properties to global namespace for backward compatibility.
if (is_callable(__NAMESPACE__ . '\\AntiSpam::exportStatic')) {
AntiSpam::exportStatic();
}

?>
54 changes: 15 additions & 39 deletions Sources/Actions/Admin/Attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

use SMF\Actions\ActionInterface;
use SMF\Attachment;
use SMF\BackwardCompatibility;
use SMF\Actions\BackwardCompatibility;
use SMF\Config;
use SMF\Db\DatabaseApi as Db;
use SMF\IntegrationHook;
Expand All @@ -32,40 +32,15 @@
use SMF\User;
use SMF\Utils;

use const DIRECTORY_SEPARATOR;

/**
* Maintains and manages attachments and avatars.
*/
class Attachments implements ActionInterface
{
use BackwardCompatibility;

/**
* @var array
*
* BackwardCompatibility settings for this class.
*/
private static $backcompat = [
'func_names' => [
'call' => 'ManageAttachments',
'list_getFiles' => 'list_getFiles',
'list_getNumFiles' => 'list_getNumFiles',
'list_getAttachDirs' => 'list_getAttachDirs',
'list_getBaseDirs' => 'list_getBaseDirs',
'attachDirStatus' => 'attachDirStatus',
'manageAttachmentSettings' => 'ManageAttachmentSettings',
'manageAvatarSettings' => 'ManageAvatarSettings',
'browseFiles' => 'BrowseFiles',
'maintainFiles' => 'MaintainFiles',
'removeAttachment' => 'RemoveAttachment',
'removeAttachmentByAge' => 'RemoveAttachmentByAge',
'removeAttachmentBySize' => 'RemoveAttachmentBySize',
'removeAllAttachments' => 'RemoveAllAttachments',
'repairAttachments' => 'RepairAttachments',
'manageAttachmentPaths' => 'ManageAttachmentPaths',
'transferAttachments' => 'TransferAttachments',
],
];

/*******************
* Public properties
*******************/
Expand Down Expand Up @@ -2469,7 +2444,7 @@ public static function list_getAttachDirs(): array
}

// Check if the directory is doing okay.
list($status, $error, $files) = attachDirStatus($dir, $expected_files[$id]);
list($status, $error, $files) = self::attachDirStatus($dir, $expected_files[$id]);

// If it is one, let's show that it's a base directory.
$sub_dirs = 0;
Expand Down Expand Up @@ -2577,7 +2552,7 @@ public static function list_getBaseDirs(): array
* @param int $expected_files How many files should be in that directory
* @return array An array containing the status of the directory, whether the number of files was what we expected and how many were in the directory
*/
public static function attachDirStatus($dir, $expected_files): array
public static function attachDirStatus(string $dir, int $expected_files): array
{
if (!is_dir($dir)) {
return ['does_not_exist', true, ''];
Expand Down Expand Up @@ -2621,7 +2596,7 @@ public static function attachDirStatus($dir, $expected_files): array
* @param bool $return_config Whether to return the config_vars array.
* @return void|array Returns nothing or returns the config_vars array.
*/
public static function manageAttachmentSettings($return_config = false)
public static function manageAttachmentSettings(bool $return_config = false)
{
if (!empty($return_config)) {
return self::attachConfigVars();
Expand Down Expand Up @@ -2651,6 +2626,7 @@ public static function manageAvatarSettings($return_config = false)

/**
* Backward compatibility wrapper for the browse sub-action.
* @deprecated since 3.0
*/
public static function browseFiles(): void
{
Expand All @@ -2661,6 +2637,7 @@ public static function browseFiles(): void

/**
* Backward compatibility wrapper for the maintenance sub-action.
* @deprecated since 3.0
*/
public static function maintainFiles(): void
{
Expand All @@ -2671,6 +2648,7 @@ public static function maintainFiles(): void

/**
* Backward compatibility wrapper for the remove sub-action.
* @deprecated since 3.0
*/
public static function removeAttachment(): void
{
Expand All @@ -2681,6 +2659,7 @@ public static function removeAttachment(): void

/**
* Backward compatibility wrapper for the byage sub-action.
* @deprecated since 3.0
*/
public static function removeAttachmentByAge(): void
{
Expand All @@ -2691,6 +2670,7 @@ public static function removeAttachmentByAge(): void

/**
* Backward compatibility wrapper for the bysize sub-action.
* @deprecated since 3.0
*/
public static function removeAttachmentBySize(): void
{
Expand All @@ -2701,6 +2681,7 @@ public static function removeAttachmentBySize(): void

/**
* Backward compatibility wrapper for the removeall sub-action.
* @deprecated since 3.0
*/
public static function removeAllAttachments(): void
{
Expand All @@ -2711,6 +2692,7 @@ public static function removeAllAttachments(): void

/**
* Backward compatibility wrapper for the repair sub-action.
* @deprecated since 3.0
*/
public static function repairAttachments(): void
{
Expand All @@ -2721,6 +2703,7 @@ public static function repairAttachments(): void

/**
* Backward compatibility wrapper for the attachpaths sub-action.
* @deprecated since 3.0
*/
public static function manageAttachmentPaths(): void
{
Expand All @@ -2731,6 +2714,7 @@ public static function manageAttachmentPaths(): void

/**
* Backward compatibility wrapper for the transfer sub-action.
* @deprecated since 3.0
*/
public static function transferAttachments(): void
{
Expand Down Expand Up @@ -2824,12 +2808,4 @@ protected function pauseAttachmentMaintenance($to_fix, $max_substep = 0): void
}
}

// Some functions have been migrated from here to the Attachment class.
class_exists('SMF\\Attachment');

// Export public static functions and properties to global namespace for backward compatibility.
if (is_callable(__NAMESPACE__ . '\\Attachments::exportStatic')) {
Attachments::exportStatic();
}

?>
Loading
Loading