From 4a89e83b80a0e300c12031b4db75fcd031655a7b Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Fri, 27 Nov 2015 09:01:25 +0800 Subject: [PATCH] MDL-52285 auth: use __construct() for constructors --- auth/cas/auth.php | 12 +++++++++++- auth/email/auth.php | 12 +++++++++++- auth/fc/auth.php | 12 +++++++++++- auth/fc/fcFPP.php | 2 +- auth/imap/auth.php | 12 +++++++++++- auth/ldap/auth.php | 12 +++++++++++- auth/manual/auth.php | 12 +++++++++++- auth/mnet/auth.php | 12 +++++++++++- auth/nntp/auth.php | 12 +++++++++++- auth/nologin/auth.php | 12 +++++++++++- auth/none/auth.php | 12 +++++++++++- auth/pam/auth.php | 12 +++++++++++- auth/pop3/auth.php | 12 +++++++++++- auth/radius/auth.php | 12 +++++++++++- auth/shibboleth/auth.php | 12 +++++++++++- auth/webservice/auth.php | 12 +++++++++++- lib/pear/Crypt/CHAP.php | 12 ++++++------ lib/pear/README_MOODLE.txt | 7 ++++++- mnet/environment.php | 4 ---- mnet/peer.php | 4 ---- mnet/xmlrpc/client.php | 5 ++--- mnet/xmlrpc/xmlparser.php | 2 +- 22 files changed, 181 insertions(+), 35 deletions(-) diff --git a/auth/cas/auth.php b/auth/cas/auth.php index afa87dd2f8ded..4439bcb6bdaf2 100644 --- a/auth/cas/auth.php +++ b/auth/cas/auth.php @@ -39,13 +39,23 @@ class auth_plugin_cas extends auth_plugin_ldap { /** * Constructor. */ - function auth_plugin_cas() { + public function __construct() { $this->authtype = 'cas'; $this->roleauth = 'auth_cas'; $this->errorlogtag = '[AUTH CAS] '; $this->init_plugin($this->authtype); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function auth_plugin_cas() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); + } + function prevent_local_passwords() { return true; } diff --git a/auth/email/auth.php b/auth/email/auth.php index 0a0827d914959..ffa0e9126d333 100644 --- a/auth/email/auth.php +++ b/auth/email/auth.php @@ -34,11 +34,21 @@ class auth_plugin_email extends auth_plugin_base { /** * Constructor. */ - function auth_plugin_email() { + public function __construct() { $this->authtype = 'email'; $this->config = get_config('auth/email'); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function auth_plugin_email() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); + } + /** * Returns true if the username and password work and false if they are * wrong or don't exist. diff --git a/auth/fc/auth.php b/auth/fc/auth.php index 75c8bd073b549..b9879923c7b99 100644 --- a/auth/fc/auth.php +++ b/auth/fc/auth.php @@ -37,11 +37,21 @@ class auth_plugin_fc extends auth_plugin_base { /** * Constructor. */ - function auth_plugin_fc() { + public function __construct() { $this->authtype = 'fc'; $this->config = get_config('auth/fc'); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function auth_plugin_fc() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); + } + /** * Returns true if the username and password work and false if they are * wrong or don't exist. diff --git a/auth/fc/fcFPP.php b/auth/fc/fcFPP.php index c08220215d523..36c589e4e3fa8 100644 --- a/auth/fc/fcFPP.php +++ b/auth/fc/fcFPP.php @@ -30,7 +30,7 @@ class fcFPP var $_debug = FALSE; // set to true to see some debug info // class constructor - function fcFPP($host="localhost", $port="3333") + public function __construct($host="localhost", $port="3333") { $this->_hostname = $host; $this->_port = $port; diff --git a/auth/imap/auth.php b/auth/imap/auth.php index b0d7f9fb0168b..3e3e2da93964e 100644 --- a/auth/imap/auth.php +++ b/auth/imap/auth.php @@ -35,11 +35,21 @@ class auth_plugin_imap extends auth_plugin_base { /** * Constructor. */ - function auth_plugin_imap() { + public function __construct() { $this->authtype = 'imap'; $this->config = get_config('auth/imap'); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function auth_plugin_imap() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); + } + /** * Returns true if the username and password work and false if they are * wrong or don't exist. diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php index 96d9bbaf23d55..9d3a4ad97021d 100644 --- a/auth/ldap/auth.php +++ b/auth/ldap/auth.php @@ -143,13 +143,23 @@ function init_plugin($authtype) { /** * Constructor with initialisation. */ - function auth_plugin_ldap() { + public function __construct() { $this->authtype = 'ldap'; $this->roleauth = 'auth_ldap'; $this->errorlogtag = '[AUTH LDAP] '; $this->init_plugin($this->authtype); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function auth_plugin_ldap() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); + } + /** * Returns true if the username and password work and false if they are * wrong or don't exist. diff --git a/auth/manual/auth.php b/auth/manual/auth.php index 938aae8f6fbc5..c6df146b90351 100644 --- a/auth/manual/auth.php +++ b/auth/manual/auth.php @@ -46,13 +46,23 @@ class auth_plugin_manual extends auth_plugin_base { /** * Constructor. */ - function auth_plugin_manual() { + public function __construct() { $this->authtype = 'manual'; $config = get_config(self::COMPONENT_NAME); $legacyconfig = get_config(self::LEGACY_COMPONENT_NAME); $this->config = (object)array_merge((array)$legacyconfig, (array)$config); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function auth_plugin_manual() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); + } + /** * Returns true if the username and password work and false if they are * wrong or don't exist. (Non-mnet accounts only!) diff --git a/auth/mnet/auth.php b/auth/mnet/auth.php index f061539863059..8bd7768b5c7b8 100644 --- a/auth/mnet/auth.php +++ b/auth/mnet/auth.php @@ -35,12 +35,22 @@ class auth_plugin_mnet extends auth_plugin_base { /** * Constructor. */ - function auth_plugin_mnet() { + public function __construct() { $this->authtype = 'mnet'; $this->config = get_config('auth_mnet'); $this->mnet = get_mnet_environment(); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function auth_plugin_mnet() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); + } + /** * This function is normally used to determine if the username and password * are correct for local logins. Always returns false, as local users do not diff --git a/auth/nntp/auth.php b/auth/nntp/auth.php index c2ad28319db44..9e8b24c5fe405 100644 --- a/auth/nntp/auth.php +++ b/auth/nntp/auth.php @@ -35,11 +35,21 @@ class auth_plugin_nntp extends auth_plugin_base { /** * Constructor. */ - function auth_plugin_nntp() { + public function __construct() { $this->authtype = 'nntp'; $this->config = get_config('auth/nntp'); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function auth_plugin_nntp() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); + } + /** * Returns true if the username and password work and false if they are * wrong or don't exist. diff --git a/auth/nologin/auth.php b/auth/nologin/auth.php index c3ed391c07c68..9a1ec28e591e6 100644 --- a/auth/nologin/auth.php +++ b/auth/nologin/auth.php @@ -35,10 +35,20 @@ class auth_plugin_nologin extends auth_plugin_base { /** * Constructor. */ - function auth_plugin_nologin() { + public function __construct() { $this->authtype = 'nologin'; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function auth_plugin_nologin() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); + } + /** * Do not allow any login. * diff --git a/auth/none/auth.php b/auth/none/auth.php index fcfce4cfd2ddb..c002930820283 100644 --- a/auth/none/auth.php +++ b/auth/none/auth.php @@ -34,11 +34,21 @@ class auth_plugin_none extends auth_plugin_base { /** * Constructor. */ - function auth_plugin_none() { + public function __construct() { $this->authtype = 'none'; $this->config = get_config('auth/none'); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function auth_plugin_none() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); + } + /** * Returns true if the username and password work or don't exist and false * if the user exists and the password is wrong. diff --git a/auth/pam/auth.php b/auth/pam/auth.php index fd76a09ef8486..b1e2053f72a58 100644 --- a/auth/pam/auth.php +++ b/auth/pam/auth.php @@ -53,12 +53,22 @@ class auth_plugin_pam extends auth_plugin_base { /** * Constructor. */ - function auth_plugin_pam() { + public function __construct() { $this->authtype = 'pam'; $this->config = get_config('auth/pam'); $this->errormessage = ''; } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function auth_plugin_pam() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); + } + /** * Returns true if the username and password work and false if they are * wrong or don't exist. diff --git a/auth/pop3/auth.php b/auth/pop3/auth.php index 5e25aa95bcf5f..4bfaa0bd92d03 100644 --- a/auth/pop3/auth.php +++ b/auth/pop3/auth.php @@ -35,11 +35,21 @@ class auth_plugin_pop3 extends auth_plugin_base { /** * Constructor. */ - function auth_plugin_pop3() { + public function __construct() { $this->authtype = 'pop3'; $this->config = get_config('auth/pop3'); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function auth_plugin_pop3() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); + } + /** * Returns true if the username and password work and false if they are * wrong or don't exist. diff --git a/auth/radius/auth.php b/auth/radius/auth.php index a74369e6afb4c..24ae5d39005fb 100644 --- a/auth/radius/auth.php +++ b/auth/radius/auth.php @@ -38,11 +38,21 @@ class auth_plugin_radius extends auth_plugin_base { /** * Constructor. */ - function auth_plugin_radius() { + public function __construct() { $this->authtype = 'radius'; $this->config = get_config('auth/radius'); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function auth_plugin_radius() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); + } + /** * Returns true if the username and password work and false if they are * wrong or don't exist. diff --git a/auth/shibboleth/auth.php b/auth/shibboleth/auth.php index a4cebd840439a..be7c25b1f98d1 100644 --- a/auth/shibboleth/auth.php +++ b/auth/shibboleth/auth.php @@ -38,11 +38,21 @@ class auth_plugin_shibboleth extends auth_plugin_base { /** * Constructor. */ - function auth_plugin_shibboleth() { + public function __construct() { $this->authtype = 'shibboleth'; $this->config = get_config('auth/shibboleth'); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function auth_plugin_shibboleth() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); + } + /** * Returns true if the username and password work and false if they are * wrong or don't exist. diff --git a/auth/webservice/auth.php b/auth/webservice/auth.php index 1fc5694262360..f027f1cf0ea16 100644 --- a/auth/webservice/auth.php +++ b/auth/webservice/auth.php @@ -35,11 +35,21 @@ class auth_plugin_webservice extends auth_plugin_base { /** * Constructor. */ - function auth_plugin_webservice() { + public function __construct() { $this->authtype = 'webservice'; $this->config = get_config('auth/webservice'); } + /** + * Old syntax of class constructor. Deprecated in PHP7. + * + * @deprecated since Moodle 3.1 + */ + public function auth_plugin_webservice() { + debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); + self::__construct(); + } + /** * Returns true if the username and password work and false if they are * wrong or don't exist. diff --git a/lib/pear/Crypt/CHAP.php b/lib/pear/Crypt/CHAP.php index 561ec9fdac00a..333db9bf07122 100644 --- a/lib/pear/Crypt/CHAP.php +++ b/lib/pear/Crypt/CHAP.php @@ -85,9 +85,9 @@ class Crypt_CHAP extends PEAR * Generates a random challenge * @return void */ - function Crypt_CHAP() + public function __construct() { - $this->PEAR(); + parent::__construct(); $this->generateChallenge(); } @@ -167,9 +167,9 @@ class Crypt_CHAP_MSv1 extends Crypt_CHAP * Loads the hash extension * @return void */ - function Crypt_CHAP_MSv1() + public function __construct() { - $this->Crypt_CHAP(); + parent::__construct(); $this->loadExtension('hash'); } @@ -415,9 +415,9 @@ class Crypt_CHAP_MSv2 extends Crypt_CHAP_MSv1 * Generates the 16 Bytes peer and authentication challenge * @return void */ - function Crypt_CHAP_MSv2() + public function __construct() { - $this->Crypt_CHAP_MSv1(); + parent::__construct(); $this->generateChallenge('peerChallenge', 16); $this->generateChallenge('authChallenge', 16); } diff --git a/lib/pear/README_MOODLE.txt b/lib/pear/README_MOODLE.txt index 4dc1fb4d0c9ec..a4274404f5f0e 100644 --- a/lib/pear/README_MOODLE.txt +++ b/lib/pear/README_MOODLE.txt @@ -33,4 +33,9 @@ MDL-52081 - made all constructors PHP7 compatible Pear ==== Changed constructors in classes PEAR and PEAR_ERROR to be __construct(). This has -been already changed upstream in 1.10.0, remove this line after upgrade. \ No newline at end of file +been already changed upstream in 1.10.0, remove this line after upgrade. + + +Crypt/CHAP +========== +MDL-52285 - made all constructors PHP7 compatible diff --git a/mnet/environment.php b/mnet/environment.php index 5cc649b2e9138..236e4b65ef795 100644 --- a/mnet/environment.php +++ b/mnet/environment.php @@ -17,10 +17,6 @@ class mnet_environment { var $keypair = array(); var $deleted = 0; - function mnet_environment() { - return true; - } - function init() { global $CFG, $DB; diff --git a/mnet/peer.php b/mnet/peer.php index 9f72e179853c4..804b7d2dfd841 100644 --- a/mnet/peer.php +++ b/mnet/peer.php @@ -39,10 +39,6 @@ class mnet_peer { /** @var int $sslverification The level of SSL verification to apply. */ public $sslverification = self::SSL_HOST_AND_PEER; - function mnet_peer() { - return true; - } - /* * Fetch information about a peer identified by wwwroot * If information does not preexist in db, collect it together based on diff --git a/mnet/xmlrpc/client.php b/mnet/xmlrpc/client.php index 08414cf3153f2..3597cd58e353b 100644 --- a/mnet/xmlrpc/client.php +++ b/mnet/xmlrpc/client.php @@ -23,12 +23,11 @@ class mnet_xmlrpc_client { var $mnet = null; /** - * Constructor returns true + * Constructor */ - function mnet_xmlrpc_client() { + public function __construct() { // make sure we've got this set up before we try and do anything else $this->mnet = get_mnet_environment(); - return true; } /** diff --git a/mnet/xmlrpc/xmlparser.php b/mnet/xmlrpc/xmlparser.php index 95ccd2a6547a3..caf52ea158b66 100644 --- a/mnet/xmlrpc/xmlparser.php +++ b/mnet/xmlrpc/xmlparser.php @@ -17,7 +17,7 @@ class mnet_encxml_parser { * * @return bool True */ - function mnet_encxml_parser() { + public function __construct() { return $this->initialise(); }