From fed41622c289f7cd5c9850b2b59bc18ae2a15c78 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 31 Mar 2021 17:49:43 +0200 Subject: [PATCH] fixing all sorts of PHP 8 errors and PHPStorm errors --- api/src/Accounts/Sql.php | 2 +- api/src/Acl.php | 6 +- api/src/Asyncservice.php | 2 +- api/src/Auth.php | 4 +- api/src/Auth/Saml.php | 3 +- api/src/Cache.php | 3 +- api/src/Cache/Apc.php | 2 +- api/src/Cache/Apcu.php | 4 +- api/src/CalDAV.php | 12 ++-- api/src/CalDAV/Handler.php | 2 +- api/src/CalDAV/Hooks.php | 2 +- api/src/Contacts.php | 4 +- api/src/Contacts/Ldap.php | 12 ++-- api/src/Contacts/Sql.php | 6 +- api/src/Contacts/Storage.php | 6 +- api/src/Contacts/Tracking.php | 6 +- api/src/Db.php | 16 ++++-- api/src/Db/Deprecated.php | 8 +-- api/src/Db/Schema.php | 9 ++- api/src/Egw/Applications.php | 4 +- api/src/Egw/Base.php | 4 +- api/src/Etemplate/KeyManager.php | 2 +- api/src/Etemplate/Request.php | 18 ++++-- api/src/Etemplate/Request/Cache.php | 2 +- api/src/Etemplate/Request/Files.php | 5 +- api/src/Etemplate/Request/Session.php | 5 +- api/src/Etemplate/Widget.php | 19 +++++-- api/src/Etemplate/Widget/AjaxSelect.php | 3 +- api/src/Etemplate/Widget/Countdown.php | 3 +- api/src/Etemplate/Widget/Customfields.php | 12 ++-- api/src/Etemplate/Widget/Date.php | 3 +- api/src/Etemplate/Widget/Entry.php | 25 ++++----- api/src/Etemplate/Widget/File.php | 2 +- api/src/Etemplate/Widget/HtmlArea.php | 10 ++-- api/src/Etemplate/Widget/ItemPicker.php | 2 +- api/src/Etemplate/Widget/Link.php | 5 +- .../Widget/Nextmatch/Accountfilter.php | 2 +- .../Widget/Nextmatch/Customfilter.php | 7 ++- api/src/Etemplate/Widget/Password.php | 1 + api/src/Etemplate/Widget/Select.php | 4 +- api/src/Etemplate/Widget/Taglist.php | 2 +- api/src/Etemplate/Widget/Textbox.php | 5 +- api/src/Etemplate/Widget/Tree.php | 8 +-- api/src/Etemplate/Widget/Vfs.php | 2 +- api/src/Framework.php | 13 +++-- api/src/Framework/Ajax.php | 10 ++-- api/src/Framework/Extra.php | 2 +- api/src/Framework/Minimal.php | 3 +- api/src/Framework/Template.php | 4 +- api/src/Header/Authenticate.php | 5 +- api/src/Hooks.php | 2 +- api/src/Html.php | 2 +- api/src/Html/HtmLawed.php | 14 ++--- api/src/Ldap.php | 6 +- api/src/Ldap/ServerInfo.php | 2 +- api/src/Link.php | 5 +- api/src/Link/Storage.php | 4 +- api/src/Mail.php | 22 ++++---- api/src/Mail/Cache.php | 2 - api/src/Mail/Credentials.php | 8 +-- api/src/Mail/Html.php | 4 +- api/src/Mail/Imap.php | 16 +++--- api/src/Mail/Imap/Cyrus.php | 4 +- api/src/Mail/Imap/Iface.php | 4 +- api/src/Mail/Script.php | 3 +- api/src/Mail/Sieve.php | 8 +-- api/src/Mail/Smime.php | 12 ++-- api/src/Mail/Smtp.php | 2 +- api/src/Session.php | 6 +- api/src/Session/Type.php | 2 +- api/src/Sharing.php | 8 +-- api/src/Storage.php | 1 + api/src/Storage/Base.php | 2 +- api/src/Storage/Base2.php | 4 +- api/src/Storage/Customfields.php | 8 +-- api/src/Storage/Db2DataIterator.php | 2 +- api/src/Storage/History.php | 1 - api/src/Storage/Merge.php | 55 ++++++++++++------- api/src/Storage/Tracking.php | 3 +- api/src/Vfs.php | 9 +-- api/src/Vfs/Filesystem/StreamWrapper.php | 11 ++-- api/src/Vfs/Links/StreamWrapper.php | 4 +- api/src/Vfs/Sharing/StreamWrapper.php | 6 +- api/src/Vfs/StreamWrapper.php | 11 ++-- api/src/Vfs/StreamWrapperIface.php | 4 +- api/src/Vfs/UserContextTrait.php | 2 +- api/src/Vfs/WebDAV.php | 10 ++-- api/src/WebDAV/Server.php | 2 +- api/src/WebDAV/Tools/_parse_proppatch.php | 12 ++-- api/src/loader/deprecated_factory.php | 14 ++--- api/src/loader/security.php | 2 +- 91 files changed, 319 insertions(+), 281 deletions(-) diff --git a/api/src/Accounts/Sql.php b/api/src/Accounts/Sql.php index a73f494a03..46bb03da1a 100644 --- a/api/src/Accounts/Sql.php +++ b/api/src/Accounts/Sql.php @@ -71,7 +71,7 @@ class Sql /** * Reference to our frontend * - * @var accounts + * @var Api\Accounts */ private $frontend; diff --git a/api/src/Acl.php b/api/src/Acl.php index 31fe1af426..a10e80894f 100644 --- a/api/src/Acl.php +++ b/api/src/Acl.php @@ -281,9 +281,9 @@ class Acl /** * check required rights agains the internal repository (included rights of $this->account_id and all it's memberships) * - * @param $location app location - * @param $required required right to check against - * @param $appname optional defaults to currentapp + * @param string $location app location + * @param int $required required right to check against + * @param string|false $appname optional defaults to currentapp * @return boolean */ function check($location, $required, $appname = False) diff --git a/api/src/Asyncservice.php b/api/src/Asyncservice.php index ff766df323..b90725e3c5 100644 --- a/api/src/Asyncservice.php +++ b/api/src/Asyncservice.php @@ -283,7 +283,7 @@ class Asyncservice // now we have the times enumerated, lets find the first not expired one // $found = array(); - $over = null; + $over = $next = null; while (!isset($found['min'])) { $future = False; diff --git a/api/src/Auth.php b/api/src/Auth.php index edf83b9b44..5fdfa1c5a6 100644 --- a/api/src/Auth.php +++ b/api/src/Auth.php @@ -379,8 +379,8 @@ class Auth /** * return a random string of size $size either just alphanumeric or with special chars * - * @param $size int-size of random string to return - * @param $use_specialchars =false false: only letters and numbers, true: incl. special chars + * @param int $size size of random string to return + * @param bool $use_specialchars =false false: only letters and numbers, true: incl. special chars * @return string * @throws \Exception if it was not possible to gather sufficient entropy. */ diff --git a/api/src/Auth/Saml.php b/api/src/Auth/Saml.php index b407efd6c7..cd253bd627 100644 --- a/api/src/Auth/Saml.php +++ b/api/src/Auth/Saml.php @@ -190,7 +190,7 @@ class Saml implements BackendSSO /** * Update joined account, if configured * - * @param $account_lid existing account_lid + * @param string $account_lid existing account_lid * @param array $attrs saml attributes incl. SAML username * @return string username to use */ @@ -546,7 +546,6 @@ class Saml implements BackendSSO * @param array $attrs * @param ?array& $auto_create_acct reference to $GLOBALS['auto_create_acct'] for not existing accounts * @param array|null $config - * @return mixed|string|null */ private function checkAffiliation($username, array $attrs, array &$auto_create_acct=null, array $config=null) { diff --git a/api/src/Cache.php b/api/src/Cache.php index c859e0f6a5..f3a3b36ace 100644 --- a/api/src/Cache.php +++ b/api/src/Cache.php @@ -405,7 +405,8 @@ class Cache if (isset($_SESSION[Session::EGW_SESSION_ENCRYPTED])) { if (Session::ERROR_LOG_DEBUG) error_log(__METHOD__.' called after session was encrypted --> ignored!'); - return null; // can no longer store something in the session, eg. because commit_session() was called + $ret = null; // can no longer store something in the session, eg. because commit_session() was called + return $ret; } // check if entry is expired and clean it up in that case if (isset($_SESSION[Session::EGW_APPSESSION_VAR][self::SESSION_EXPIRATION_PREFIX.$app][$location]) && diff --git a/api/src/Cache/Apc.php b/api/src/Cache/Apc.php index 8971005753..824018d07e 100644 --- a/api/src/Cache/Apc.php +++ b/api/src/Cache/Apc.php @@ -160,7 +160,7 @@ class Apc extends Base implements Provider return false; } //error_log(__METHOD__."(".array2string($keys).")"); - foreach(new \APCIterator('user', $preg='/^'.preg_quote(self::key($keys).'/')) as $item) + foreach(new \APCIterator('user', $preg='/^'.preg_quote(self::key($keys), '/').'/') as $item) { //error_log(__METHOD__."(".array2string($keys).") preg='$preg': calling apc_delete('$item[key]')"); apc_delete($item['key']); diff --git a/api/src/Cache/Apcu.php b/api/src/Cache/Apcu.php index e39ef5acd7..0be1297a46 100644 --- a/api/src/Cache/Apcu.php +++ b/api/src/Cache/Apcu.php @@ -165,12 +165,12 @@ class Apcu extends Base implements Provider // APCu > 5 has APCUIterator if (class_exists('APCUIterator')) { - $iterator = new \APCUIterator($preg='/^'.preg_quote(self::key($keys).'/')); + $iterator = new \APCUIterator($preg='/^'.preg_quote(self::key($keys), '/').'/'); } // APC >= 3.1.1, but also seems to be missing if apc is disabled eg. for cli elseif(class_exists('APCIterator')) { - $iterator = new \APCIterator('user', $preg='/^'.preg_quote(self::key($keys).'/')); + $iterator = new \APCIterator('user', $preg='/^'.preg_quote(self::key($keys), '/'), '/'); } else { diff --git a/api/src/CalDAV.php b/api/src/CalDAV.php index 7d7b001d9e..ccf7885eed 100644 --- a/api/src/CalDAV.php +++ b/api/src/CalDAV.php @@ -215,7 +215,7 @@ class CalDAV extends HTTP_WebDAV_Server /** * Reference to active instance, used by exception handler * - * @var groupdav + * @var self */ protected static $instance; @@ -1046,7 +1046,7 @@ class CalDAV extends HTTP_WebDAV_Server //'DAV:sync-token' => 'sync-token', ); $n = 0; - $collection_props = null; + $collection_props = $class = null; foreach($files['files'] as $file) { if (!isset($collection_props)) @@ -1066,7 +1066,7 @@ class CalDAV extends HTTP_WebDAV_Server } $props = $this->props2array($file['props']); //echo $file['path']; _debug_array($props); - $class = $class == 'row_on' ? 'row_off' : 'row_on'; + $class = $class === 'row_on' ? 'row_off' : 'row_on'; if (substr($file['path'],-1) == '/') { @@ -1193,7 +1193,8 @@ class CalDAV extends HTTP_WebDAV_Server } if (is_array($prop['val'])) { - $prop['val'] = $this->_hierarchical_prop_encode($prop['val'], $prop['ns'], $ns_defs='', $ns_hash); + $ns_defs = ''; + $prop['val'] = $this->_hierarchical_prop_encode($prop['val'], $prop['ns'], $ns_defs, $ns_hash); // hack to show real namespaces instead of not (visibly) defined shortcuts unset($ns_hash['DAV:']); $value = strtr($v=$this->prop_value($prop['val']),array_flip($ns_hash)); @@ -1838,7 +1839,8 @@ class CalDAV extends HTTP_WebDAV_Server // dont know why, but HTTP_WebDAV_Server passes the owner in D:href tags, which get's passed unchanged to checkLock/PROPFIND // that's wrong according to the standard and cadaver does not show it on discover --> strip_tags removes eventual tags - if (($ret = Vfs::lock($path,$options['locktoken'],$options['timeout'],strip_tags($options['owner']), + $owner = strip_tags($options['owner']); + if (($ret = Vfs::lock($path,$options['locktoken'],$options['timeout'],$owner, $options['scope'],$options['type'],isset($options['update']),false)) && !isset($options['update'])) // false = no ACL check { return $ret ? '200 OK' : '409 Conflict'; diff --git a/api/src/CalDAV/Handler.php b/api/src/CalDAV/Handler.php index d5805e96fc..21c23b9ec5 100644 --- a/api/src/CalDAV/Handler.php +++ b/api/src/CalDAV/Handler.php @@ -405,7 +405,7 @@ abstract class Handler * @static * @param string $app 'calendar', 'addressbook' or 'infolog' * @param Api\CalDAV $groupdav calling class - * @return groupdav_handler + * @return self */ static function app_handler($app, Api\CalDAV $groupdav) { diff --git a/api/src/CalDAV/Hooks.php b/api/src/CalDAV/Hooks.php index fe689f3d61..c0b0f290bd 100644 --- a/api/src/CalDAV/Hooks.php +++ b/api/src/CalDAV/Hooks.php @@ -105,7 +105,7 @@ class Hooks if ($GLOBALS['type'] === 'user') { $logs = array(); - $relativ_log_dir .= 'groupdav/'.Api\CalDAV::sanitize_filename(Api\Accounts::id2name($hook_data['account_id'])); + $relativ_log_dir = 'groupdav/'.Api\CalDAV::sanitize_filename(Api\Accounts::id2name($hook_data['account_id'])); $log_dir = $GLOBALS['egw_info']['server']['files_dir'].'/'.$relativ_log_dir; if (file_exists($log_dir) && ($files = scandir($log_dir))) { diff --git a/api/src/Contacts.php b/api/src/Contacts.php index ede6f5cc36..b259a269c8 100755 --- a/api/src/Contacts.php +++ b/api/src/Contacts.php @@ -1830,7 +1830,7 @@ class Contacts extends Contacts\Storage WHERE '.$this->db->expression('egw_addressbook', array($type_field => $uids)); - $contacts =& $this->db->query($sql, __LINE__, __FILE__); + $contacts = $this->db->query($sql, __LINE__, __FILE__); if (!$contacts) return array(); @@ -2951,7 +2951,7 @@ class Contacts extends Contacts\Storage 'contact_id' => (int)$contact['id'], 'crm_list' => $crm_list, 'title' => count($found) > 1 && $contact['org_name'] ? - $contact['org_name'] : $contact['n_fn'].' ('.lang($extras['crm_list']).')', + $contact['org_name'] : $contact['n_fn'].' ('.lang($crm_list).')', 'icon' => $contact['photo'], ]); $arg = json_encode($arg, JSON_UNESCAPED_SLASHES); diff --git a/api/src/Contacts/Ldap.php b/api/src/Contacts/Ldap.php index b62ed9aa70..dadc7bb021 100644 --- a/api/src/Contacts/Ldap.php +++ b/api/src/Contacts/Ldap.php @@ -811,7 +811,11 @@ class Ldap if((int)$filter['owner']) { - if (!($accountName = $GLOBALS['egw']->accounts->id2name($filter['owner']))) return false; + if (!($accountName = $GLOBALS['egw']->accounts->id2name($filter['owner']))) + { + $ret = false; + return $ret; + } $searchDN = 'cn='. Api\Ldap::quote(strtolower($accountName)) .','; @@ -961,11 +965,11 @@ class Ldap } if(is_numeric($start) && is_numeric($offset) && $offset >= 0) { - return array_slice($rows, $start, $offset); + $rows = array_slice($rows, $start, $offset); } elseif(is_numeric($start)) { - return array_slice($rows, $start, $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']); + $rows = array_slice($rows, $start, $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']); } return $rows; } @@ -1062,7 +1066,7 @@ class Ldap } } // filter for letter-search - elseif (preg_match("/^([^ ]+) ".preg_quote($GLOBALS['egw']->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE])." '(.*)%'$/",$value,$matches)) + elseif (preg_match("/^([^ ]+) ".preg_quote($GLOBALS['egw']->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE], '/')." '(.*)%'$/",$value,$matches)) { list(,$name,$value) = $matches; if (strpos($name,'.') !== false) list(,$name) = explode('.',$name); diff --git a/api/src/Contacts/Sql.php b/api/src/Contacts/Sql.php index f008912f8d..65b1eb6982 100644 --- a/api/src/Contacts/Sql.php +++ b/api/src/Contacts/Sql.php @@ -541,7 +541,11 @@ class Sql extends Api\Storage // no grants for selected owner/addressbook if (!array_intersect((array)$filter['owner'],array_keys($this->grants))) { - if (!isset($groupmember_sql)) return false; + if (!isset($groupmember_sql)) + { + $ret = false; + return $ret; + } $filter[] = '('.substr($groupmember_sql,4)." OR $shared_sql)"; unset($filter['owner']); } diff --git a/api/src/Contacts/Storage.php b/api/src/Contacts/Storage.php index 98a28fb315..f91509f84a 100755 --- a/api/src/Contacts/Storage.php +++ b/api/src/Contacts/Storage.php @@ -1297,16 +1297,14 @@ class Storage } /** - * Check if distribution lists are availible for a given addressbook + * Check if distribution lists are available for a given addressbook * * @param int|string $owner ='' addressbook (eg. 0 = accounts), default '' = "all" addressbook (uses the main backend) * @return boolean */ function lists_available($owner='') { - $backend =& $this->get_backend(null,$owner); - - return method_exists($backend,'read_list'); + return method_exists($this->get_backend(null, $owner),'read_list'); } /** diff --git a/api/src/Contacts/Tracking.php b/api/src/Contacts/Tracking.php index 4b36b6ad02..a7435a0b1e 100644 --- a/api/src/Contacts/Tracking.php +++ b/api/src/Contacts/Tracking.php @@ -62,7 +62,7 @@ class Tracking extends Api\Storage\Tracking * Instance of the bocontacts class calling us * * @access private - * @var addressbook_bo + * @var \addressbook_bo */ var $contacts; @@ -70,7 +70,7 @@ class Tracking extends Api\Storage\Tracking * Constructor * * @param Api\Contacts $bocontacts - * @return tracker_tracking + * @return \tracker_tracking */ function __construct(Api\Contacts $bocontacts) { @@ -267,7 +267,7 @@ class Tracking extends Api\Storage\Tracking } $details[$name] = array( 'label' => $label, - 'value' => explode(', ',$cats), + 'value' => implode(', ',$cats), ); } case 'note': diff --git a/api/src/Db.php b/api/src/Db.php index 0183fae247..cb42718df4 100644 --- a/api/src/Db.php +++ b/api/src/Db.php @@ -143,20 +143,26 @@ class Db */ var $query_log; + /** + * @var array with values for keys "version" and "description" + */ + public $ServerInfo; + /** * ADOdb connection * - * @var ADOConnection + * @var \ADOConnection */ var $Link_ID = 0; /** - * ADOdb connection + * ADOdb connection is private / not the global one * * @var boolean */ var $privat_Link_ID = False; // do we use a privat Link_ID or a reference to the global ADOdb object /** * Global ADOdb connection + * @var \ADOConnection */ static public $ADOdb = null; @@ -304,7 +310,7 @@ class Db * @param string $Password password for database user (optional) * @param string $Type type of database (optional) * @throws Db\Exception\Connection - * @return ADOConnection + * @return \ADOConnection */ function connect($Database = NULL, $Host = NULL, $Port = NULL, $User = NULL, $Password = NULL, $Type = NULL) { @@ -379,7 +385,7 @@ class Db * require_once(EGW_INCLUDE_ROOT.'/api/src/Db.php'); * EGroupware\Api\Db::$health_check = array('EGroupware\Api\Db', 'galera_cluster_health'); * - * @param Api\Db $db already connected Api\Db instance to check + * @param Db $db already connected Db instance to check * @throws Db\Exception\Connection if node should NOT be used */ static function galera_cluster_health(Db $db) @@ -429,7 +435,7 @@ class Db * Connect to given host * * @param string $Host host to connect to - * @return ADOConnection + * @return \ADOConnection * @throws Db\Exception\Connection */ protected function _connect($Host) diff --git a/api/src/Db/Deprecated.php b/api/src/Db/Deprecated.php index 95fff586fb..77dfc93d6f 100644 --- a/api/src/Db/Deprecated.php +++ b/api/src/Db/Deprecated.php @@ -36,7 +36,7 @@ class Deprecated extends Api\Db /** * ADOdb record set of the current query * - * @var ADORecordSet + * @var \ADORecordSet */ var $Query_ID = 0; @@ -51,8 +51,8 @@ class Deprecated extends Api\Db * @param array|boolean $inputarr array for binding variables to parameters or false (default) * @param int $fetchmode =self::FETCH_BOTH self::FETCH_BOTH (default), self::FETCH_ASSOC or self::FETCH_NUM * @param boolean $reconnect =true true: try reconnecting if server closes connection, false: dont (mysql only!) - * @return ADORecordSet or false, if the query fails - * @throws EGroupware\Api\Db\Exception\InvalidSql with $this->Link_ID->ErrorNo() as code + * @return \ADORecordSet or false, if the query fails + * @throws Api\Db\Exception\InvalidSql with $this->Link_ID->ErrorNo() as code */ function query($Query_String, $line = '', $file = '', $offset=0, $num_rows=-1, $inputarr=false, $fetchmode=self::FETCH_BOTH, $reconnect=true) { @@ -68,7 +68,7 @@ class Deprecated extends Api\Db * Return the result-object of the last query * * @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone - * @return ADORecordSet + * @return \ADORecordSet */ function query_id() { diff --git a/api/src/Db/Schema.php b/api/src/Db/Schema.php index f29a67df52..ff730a7f77 100644 --- a/api/src/Db/Schema.php +++ b/api/src/Db/Schema.php @@ -30,19 +30,19 @@ class Schema /** * db-object * - * @var EGroupware\Api\Db\Deprecated + * @var Deprecated */ var $m_odb; /** * reference to the global ADOdb object * - * @var ADOConnection + * @var \ADOConnection */ var $adodb; /** * adodb's datadictionary object for the used db-type * - * @var ADODB_DataDict + * @var \ADODB_DataDict */ var $dict; /** @@ -95,8 +95,7 @@ class Schema * Constructor of schema-processor * * @param string $dbms type of the database: 'mysql','pgsql','mssql','maxdb' - * @param Db $db =null database class, if null we use $GLOBALS['egw']->db - * @return schema_proc + * @param Api\Db $db =null database class, if null we use $GLOBALS['egw']->db */ function __construct($dbms=False, Api\Db $db=null) { diff --git a/api/src/Egw/Applications.php b/api/src/Egw/Applications.php index 1ef24b1244..8e3cf96bf4 100755 --- a/api/src/Egw/Applications.php +++ b/api/src/Egw/Applications.php @@ -23,7 +23,7 @@ class Applications /** * Reference to the global db class * - * @var EGroupware\Api\Db + * @var Api\Db */ var $db; var $table_name = 'egw_applications'; @@ -35,7 +35,7 @@ class Applications /** * standard constructor for setting $this->account_id * - * @param $account_id account id + * @param int|string $account_id account-id or -lid */ function __construct($account_id = '') { diff --git a/api/src/Egw/Base.php b/api/src/Egw/Base.php index 9ebef9112a..9becbc6bd6 100644 --- a/api/src/Egw/Base.php +++ b/api/src/Egw/Base.php @@ -18,7 +18,7 @@ namespace EGroupware\Api\Egw; use EGroupware\Api; /** - * Egw\Base object used in setup, does not instanciate anything by default + * Base object used in setup, does not instanciate anything by default * * Extending Egw\Base which uses now a getter method to create the usual subobject on demand, * to allow a quicker header include on sites not using php4-restore. @@ -46,7 +46,7 @@ class Base /** * Global ADOdb object, need to be defined here, to not call magic __get method * - * @var ADOConnection + * @var \ADOConnection */ var $ADOdb; diff --git a/api/src/Etemplate/KeyManager.php b/api/src/Etemplate/KeyManager.php index 9e39527cd0..346c6ad275 100644 --- a/api/src/Etemplate/KeyManager.php +++ b/api/src/Etemplate/KeyManager.php @@ -97,7 +97,7 @@ class KeyManager // Function keys if ($keyCode >= self::F1 && $keyCode <= self::F12) { - return "F".($keyCode - EGW_KEY_F1 + 1); + return "F".($keyCode - self::F1 + 1); } // Special keys diff --git a/api/src/Etemplate/Request.php b/api/src/Etemplate/Request.php index e3c5a781e5..f4823645b9 100644 --- a/api/src/Etemplate/Request.php +++ b/api/src/Etemplate/Request.php @@ -486,7 +486,7 @@ class Request foreach($this->data as $key => $val) { $len = strlen(is_array($val) ? serialize($val) : $val); - $len .= ' ('.sprintf('%2.1lf',($percent = 100.0 * $len / $total)).'%)'; + $len .= ' ('.sprintf('%2.1f',($percent = 100.0 * $len / $total)).'%)'; if ($percent < $min_share) continue; echo "

$key: strlen(\$val)=$len

\n"; if ($percent >= $dump_share) _debug_array($val); @@ -495,7 +495,7 @@ class Request foreach($val as $k => $v) { $l = strlen(is_array($v) ? serialize($v) : $v); - $l .= ' ('.sprintf('%2.1lf',($p = 100.0 * $l / $total)).'%)'; + $l .= ' ('.sprintf('%2.1f',($p = 100.0 * $l / $total)).'%)'; if ($p < $min_share) continue; echo "

 - {$key}[$k]: strlen(\$v)=$l

\n"; } @@ -533,9 +533,17 @@ class Request return false; } $iv_size = mcrypt_enc_get_iv_size(self::$mcrypt); - $iv = !isset($GLOBALS['egw_info']['server']['mcrypt_iv']) || strlen($GLOBALS['egw_info']['server']['mcrypt_iv']) < $iv_size ? - mcrypt_create_iv ($iv_size, MCRYPT_RAND) : substr($GLOBALS['egw_info']['server']['mcrypt_iv'],0,$iv_size); - + if (!isset($GLOBALS['egw_info']['server']['mcrypt_iv']) || strlen($GLOBALS['egw_info']['server']['mcrypt_iv']) < $iv_size) + { + if (!($iv = mcrypt_create_iv ($iv_size, MCRYPT_DEV_RANDOM))) + { + return self::$mcrypt = false; + } + } + else + { + $iv = substr($GLOBALS['egw_info']['server']['mcrypt_iv'],0,$iv_size); + } $key_size = mcrypt_enc_get_key_size(self::$mcrypt); if (bytes($key) > $key_size) $key = cut_bytes($key,0,$key_size-1); diff --git a/api/src/Etemplate/Request/Cache.php b/api/src/Etemplate/Request/Cache.php index d98cdc973b..a431db04bb 100644 --- a/api/src/Etemplate/Request/Cache.php +++ b/api/src/Etemplate/Request/Cache.php @@ -94,7 +94,7 @@ class Cache extends Etemplate\Request * * @param string $id =null * @param bool $handle_not_found =true true: handle not found by trying to redirect, false: just return null - * @return Request|null null if Request not found and $handle_not_found === false + * @return ?Etemplate\Request|false null if Request not found and $handle_not_found === false */ public static function read($id=null, $handle_not_found=true) { diff --git a/api/src/Etemplate/Request/Files.php b/api/src/Etemplate/Request/Files.php index eca570b3cf..b15054d320 100644 --- a/api/src/Etemplate/Request/Files.php +++ b/api/src/Etemplate/Request/Files.php @@ -80,9 +80,6 @@ class Files extends Etemplate\Request if (!$id) $id = self::request_id(); $this->id = $id; - - // hack to quiten IDE Warning for not calling parent::__construct, which we can not! - if (false) parent::__construct(); } /** @@ -100,7 +97,7 @@ class Files extends Etemplate\Request * Factory method to get a new request object or the one for an existing request * * @param string $id =null - * @return etemplate_request|boolean the object or false if $id is not found + * @return ?Etemplate\Request|false the object or false if $id is not found */ static function read($id=null) { diff --git a/api/src/Etemplate/Request/Session.php b/api/src/Etemplate/Request/Session.php index c71f4d7731..7bad1420fe 100644 --- a/api/src/Etemplate/Request/Session.php +++ b/api/src/Etemplate/Request/Session.php @@ -66,9 +66,6 @@ class Session extends Etemplate\Request if (!$id) $id = self::request_id(); $this->id = $id; - - // hack to quiten IDE Warning for not calling parent::__construct, which we can not! - if (false) parent::__construct(); } /** @@ -86,7 +83,7 @@ class Session extends Etemplate\Request * Factory method to get a new request object or the one for an existing request * * @param string $id =null - * @return etemplate_request|boolean the object or false if $id is not found + * @return ?Etemplate\request|false the object or false if $id is not found */ static function read($id=null) { diff --git a/api/src/Etemplate/Widget.php b/api/src/Etemplate/Widget.php index 8d24605b6d..4d7dfdd66d 100644 --- a/api/src/Etemplate/Widget.php +++ b/api/src/Etemplate/Widget.php @@ -75,7 +75,7 @@ class Widget * * It's a static variable as etemplates can contain further etemplates (rendered by a different object) * - * @var etemplate_request + * @var Request */ static protected $request; @@ -100,7 +100,7 @@ class Widget /** * Constructor * - * @param string|XMLReader $xml string with xml or XMLReader positioned on the element to construct + * @param string|\XMLReader $xml string with xml or XMLReader positioned on the element to construct * @throws Api\Exception\WrongParameter */ public function __construct($xml) @@ -862,7 +862,11 @@ class Widget { throw new Api\Exception\AssertionFailed(__METHOD__."(\$arr,'$_idx',$reference_into,$skip_empty) \$arr is no array!"); } - if (is_object($_idx)) return false; // given an error in php5.2 + if (is_object($_idx)) + { + $ret = false; // given an error in php5.2 + return $ret; + } // Make sure none of these are left $idx = str_replace(array('[',']'), array('[',']'), $_idx); @@ -883,9 +887,14 @@ class Widget if (!is_array($pos) && (!$reference_into || $reference_into && isset($pos))) { //if ($reference_into) error_log(__METHOD__."(".(strlen($s=array2string($arr))>512?substr($s,0,512).'...':$s).", '$idx', ".array2string($reference_into).", ".array2string($skip_empty).") ".function_backtrace()); - return null; + $ret = null; + return $ret; + } + if($skip_empty && (!is_array($pos) || !isset($pos[$idx]))) + { + $ret = null; + return $ret; } - if($skip_empty && (!is_array($pos) || !isset($pos[$idx]))) return null; $pos = &$pos[$idx]; } return $pos; diff --git a/api/src/Etemplate/Widget/AjaxSelect.php b/api/src/Etemplate/Widget/AjaxSelect.php index 19ec03cec9..b99fe881aa 100644 --- a/api/src/Etemplate/Widget/AjaxSelect.php +++ b/api/src/Etemplate/Widget/AjaxSelect.php @@ -13,6 +13,7 @@ namespace EGroupware\Api\Etemplate\Widget; use EGroupware\Api\Etemplate; +use EGroupware\Api; /** * eTemplate ajax select widget @@ -22,7 +23,7 @@ class AjaxSelect extends Select /** * Constructor * - * @param string|XMLReader $xml string with xml or XMLReader positioned on the element to construct + * @param string|\XMLReader $xml string with xml or XMLReader positioned on the element to construct * @throws Api\Exception\WrongParameter */ public function __construct($xml = '') diff --git a/api/src/Etemplate/Widget/Countdown.php b/api/src/Etemplate/Widget/Countdown.php index 0481ef34dd..62b06d0fff 100644 --- a/api/src/Etemplate/Widget/Countdown.php +++ b/api/src/Etemplate/Widget/Countdown.php @@ -49,10 +49,9 @@ class Countdown extends Api\Etemplate\Widget * This is used by Nextmatch on each row to do any needed * adjustments. If not needed, don't implement it. * - * @param type $cname + * @param string $cname * @param array $expand * @param array $data Row data - * @return type */ public function set_row_value($cname, Array $expand, Array &$data) { diff --git a/api/src/Etemplate/Widget/Customfields.php b/api/src/Etemplate/Widget/Customfields.php index 010859225e..0964a7fd9b 100644 --- a/api/src/Etemplate/Widget/Customfields.php +++ b/api/src/Etemplate/Widget/Customfields.php @@ -17,6 +17,8 @@ use EGroupware\Api; /** * Widgets for custom fields and listing custom fields + * + * @todo: fix the two undefined variables ($value and $field) */ class Customfields extends Transformer { @@ -127,9 +129,9 @@ class Customfields extends Transformer if(!$app && !$customfields) { - $app =& $this->setElementAttribute(self::GLOBAL_VALS, 'app', $GLOBALS['egw_info']['flags']['currentapp']); + $app =& self::setElementAttribute(self::GLOBAL_VALS, 'app', $GLOBALS['egw_info']['flags']['currentapp']); if ($this->attrs['sub-app']) $app .= '-'.$this->attrs['sub-app']; - $customfields =& $this->setElementAttribute(self::GLOBAL_VALS, 'customfields', Api\Storage\Customfields::get($app)); + $customfields =& self::setElementAttribute(self::GLOBAL_VALS, 'customfields', Api\Storage\Customfields::get($app)); } // if we are in the etemplate editor or the app has no cf's, load the cf's from the app the tpl belongs too @@ -137,7 +139,7 @@ class Customfields extends Transformer ($GLOBALS['egw_info']['flags']['currentapp'] == 'etemplate' || !$this->attrs['customfields']) || !isset($customfields)) { // app changed - $customfields =& Api\Storage\Customfields::get($app); + $customfields = Api\Storage\Customfields::get($app); } if($this->attrs['customfields']) { @@ -245,8 +247,8 @@ class Customfields extends Transformer if($fields != $customfields) { // This widget has different settings from global - $this->setElementAttribute($form_name, 'customfields', $fields); - $this->setElementAttribute($form_name, 'fields', array_merge( + self::setElementAttribute($form_name, 'customfields', $fields); + self::setElementAttribute($form_name, 'fields', array_merge( array_fill_keys(array_keys($customfields), false), array_fill_keys(array_keys($fields), true) )); diff --git a/api/src/Etemplate/Widget/Date.php b/api/src/Etemplate/Widget/Date.php index 39054f2155..8e7defe63c 100644 --- a/api/src/Etemplate/Widget/Date.php +++ b/api/src/Etemplate/Widget/Date.php @@ -83,10 +83,9 @@ class Date extends Transformer * This is used by Nextmatch on each row to do any needed * adjustments. If not needed, don't implement it. * - * @param type $cname + * @param string $cname * @param array $expand * @param array $data Row data - * @return type */ public function set_row_value($cname, Array $expand, Array &$data) { diff --git a/api/src/Etemplate/Widget/Entry.php b/api/src/Etemplate/Widget/Entry.php index b8b92d839c..f6cb1a4d5b 100644 --- a/api/src/Etemplate/Widget/Entry.php +++ b/api/src/Etemplate/Widget/Entry.php @@ -15,8 +15,6 @@ namespace EGroupware\Api\Etemplate\Widget; -use EGroupware\Api\Storage\Merge; - /** * eTemplate Entry widget * @@ -134,7 +132,7 @@ abstract class Entry extends Transformer /** * Get a list of fields available for display * - * @return Array + * @return array */ protected static function get_field_list() { @@ -144,14 +142,12 @@ abstract class Entry extends Transformer /** * Using ID, field and alternate fields, find the one to use * - * @param Array $attrs - * @param Array $data - * @return Reference into data array for value + * @param array $attrs + * @param array $data + * @return mixed Reference into data array for value */ protected function &get_data_field($attrs, &$data) { - $id = is_array($data) ? static::get_array($data, $this->id) : $data; - $value =& $data; if(!is_array($value)) return $value; @@ -162,7 +158,8 @@ abstract class Entry extends Transformer return $value[$field]; } } - return null; + $ret = null; + return $ret; } /** @@ -173,8 +170,8 @@ abstract class Entry extends Transformer * #infolog_cf/#addressbook_cf/n_fn * etc. * - * @param Array $attrs Current field attributes - * @param Array $data Current entry data + * @param array $attrs Current field attributes + * @param array $data Current entry data */ protected function customfield($attrs, &$data) { @@ -209,13 +206,11 @@ abstract class Entry extends Transformer /** * Handle regex attribute that allows modifying the value via regex replace * - * @param Array $attrs Current field attributes - * @param Array $data Current entry data + * @param array $attrs Current field attributes + * @param array $data Current entry data */ protected function regex($attrs, &$data) { - $data_id = $attrs['value'] ?: $attrs['id']; - $id = is_array($data) ? static::get_array($data, $data_id) : $data; $value =& $this->get_data_field($attrs, $data); if(!$attrs['regex'] || !$value) { diff --git a/api/src/Etemplate/Widget/File.php b/api/src/Etemplate/Widget/File.php index b89f9863da..7946d1ef92 100644 --- a/api/src/Etemplate/Widget/File.php +++ b/api/src/Etemplate/Widget/File.php @@ -50,7 +50,7 @@ class File extends Etemplate\Widget // Legacy multiple - id ends in [] if(substr($this->id,-2) == '[]') { - $this->setElementAttribute($this->id, 'multiple', true); + self::setElementAttribute($this->id, 'multiple', true); } } diff --git a/api/src/Etemplate/Widget/HtmlArea.php b/api/src/Etemplate/Widget/HtmlArea.php index d777c40337..c80b0ab2d4 100644 --- a/api/src/Etemplate/Widget/HtmlArea.php +++ b/api/src/Etemplate/Widget/HtmlArea.php @@ -23,7 +23,7 @@ class HtmlArea extends Etemplate\Widget { /** * font families - * @var type array + * @var array */ public static $font_options = array( 'andale mono,times' => 'Andale Mono', @@ -49,7 +49,7 @@ class HtmlArea extends Etemplate\Widget /** * font size options - * @var type array + * @var array */ public static $font_size_options = array( 8 => '8', @@ -72,7 +72,7 @@ class HtmlArea extends Etemplate\Widget /** * font unit options - * @var type array + * @var array */ public static $font_unit_options = array( 'pt' => 'pt: points (1/72 inch)', @@ -81,7 +81,7 @@ class HtmlArea extends Etemplate\Widget /** * List of exisitng toolbar actions - * @var type array + * @var array */ public static $toolbar_list = [ 'undo', 'redo', 'bold', 'italic', 'strikethrough', 'forecolor', 'backcolor', @@ -92,7 +92,7 @@ class HtmlArea extends Etemplate\Widget /** * Default list of toolbar actions - * @var type array + * @var array */ public static $toolbar_default_list = [ 'undo', 'redo','formatselect', 'fontselect', 'fontsizeselect', diff --git a/api/src/Etemplate/Widget/ItemPicker.php b/api/src/Etemplate/Widget/ItemPicker.php index 61865fbe57..8ec61cdf0d 100755 --- a/api/src/Etemplate/Widget/ItemPicker.php +++ b/api/src/Etemplate/Widget/ItemPicker.php @@ -26,7 +26,7 @@ class ItemPicker extends Etemplate\Widget /** * Constructor * - * @param string|XMLReader $xml string with xml or XMLReader positioned on the element to construct + * @param string|\XMLReader $xml string with xml or XMLReader positioned on the element to construct * @throws Api\Exception\WrongParameter */ public function __construct($xml = '') diff --git a/api/src/Etemplate/Widget/Link.php b/api/src/Etemplate/Widget/Link.php index 001d79ff3c..496662b66c 100644 --- a/api/src/Etemplate/Widget/Link.php +++ b/api/src/Etemplate/Widget/Link.php @@ -32,7 +32,7 @@ class Link extends Etemplate\Widget /** * Constructor * - * @param string|XMLReader $xml string with xml or XMLReader positioned on the element to construct + * @param string|\XMLReader $xml string with xml or XMLReader positioned on the element to construct * @throws Api\Exception\WrongParameter */ public function __construct($xml = '') @@ -275,7 +275,8 @@ class Link extends Etemplate\Widget } elseif ($action == "move") { - Api\Vfs::move_files($files, Api\Link::vfs_path($app, $id, '', true), $errs = array(), $moved = array()); + $errs = $moved = []; + Api\Vfs::move_files($files, Api\Link::vfs_path($app, $id, '', true), $errs, $moved); } else { diff --git a/api/src/Etemplate/Widget/Nextmatch/Accountfilter.php b/api/src/Etemplate/Widget/Nextmatch/Accountfilter.php index a48ad5d621..d3af2d2bd9 100644 --- a/api/src/Etemplate/Widget/Nextmatch/Accountfilter.php +++ b/api/src/Etemplate/Widget/Nextmatch/Accountfilter.php @@ -23,7 +23,7 @@ class Accountfilter extends Widget\Taglist /** * Parse and set extra attributes from xml in template object * - * @param string|XMLReader $xml + * @param string|\XMLReader $xml * @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object */ public function set_attrs($xml, $cloned=true) diff --git a/api/src/Etemplate/Widget/Nextmatch/Customfilter.php b/api/src/Etemplate/Widget/Nextmatch/Customfilter.php index 4d04e16e7f..b48e4fb462 100644 --- a/api/src/Etemplate/Widget/Nextmatch/Customfilter.php +++ b/api/src/Etemplate/Widget/Nextmatch/Customfilter.php @@ -50,12 +50,12 @@ class Customfilter extends Widget\Transformer } $form_name = self::form_name($cname, $this->id, $expand); - $this->setElementAttribute($form_name, 'options', trim($this->attrs['widget_options']) != '' ? $this->attrs['widget_options'] : ''); + self::setElementAttribute($form_name, 'options', trim($this->attrs['widget_options']) != '' ? $this->attrs['widget_options'] : ''); - $this->setElementAttribute($form_name, 'type', $this->attrs['type']); + self::setElementAttribute($form_name, 'type', $this->attrs['type']); if($widget_type) { - $this->setElementAttribute($form_name, 'widget_type', $widget_type); + self::setElementAttribute($form_name, 'widget_type', $widget_type); } parent::beforeSendToClient($cname, $expand); } @@ -71,6 +71,7 @@ class Customfilter extends Widget\Transformer */ public function validate($cname, array $expand, array $content, &$validated=array()) { + $form_name = self::form_name($cname, $this->id, $expand); $value = $value_in = self::get_array($content, $form_name); $valid =& self::get_array($validated, $form_name, true); diff --git a/api/src/Etemplate/Widget/Password.php b/api/src/Etemplate/Widget/Password.php index fc13216882..ae4d5ef7f3 100644 --- a/api/src/Etemplate/Widget/Password.php +++ b/api/src/Etemplate/Widget/Password.php @@ -16,6 +16,7 @@ namespace EGroupware\Api\Etemplate\Widget; use EGroupware\Api\Etemplate; use EGroupware\Api\Auth; use EGroupware\Api\Mail\Credentials; +use EGroupware\Api; use XMLReader; /** diff --git a/api/src/Etemplate/Widget/Select.php b/api/src/Etemplate/Widget/Select.php index e8cf3c18df..713a5d21e2 100644 --- a/api/src/Etemplate/Widget/Select.php +++ b/api/src/Etemplate/Widget/Select.php @@ -77,7 +77,7 @@ class Select extends Etemplate\Widget /** * Constructor * - * @param string|XMLReader $xml string with xml or XMLReader positioned on the element to construct + * @param string|\XMLReader $xml string with xml or XMLReader positioned on the element to construct * @throws Api\Exception\WrongParameter */ public function __construct($xml = '') @@ -100,7 +100,7 @@ class Select extends Etemplate\Widget * * Reimplemented to parse our differnt attributes * - * @param string|XMLReader $xml + * @param string|\XMLReader $xml * @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object * @return Template current object or clone, if any attribute was set * @todo Use legacy_attributes instead of leaving it to typeOptions method to parse them diff --git a/api/src/Etemplate/Widget/Taglist.php b/api/src/Etemplate/Widget/Taglist.php index b89a7ab207..43a83210c2 100644 --- a/api/src/Etemplate/Widget/Taglist.php +++ b/api/src/Etemplate/Widget/Taglist.php @@ -36,7 +36,7 @@ class Taglist extends Etemplate\Widget * * Overrides parent to check for $xml first, prevents errors when instanciated without (via AJAX) * - * @param string|XMLReader $xml string with xml or XMLReader positioned on the element to construct + * @param string|\XMLReader $xml string with xml or XMLReader positioned on the element to construct * @throws Api\Exception\WrongParameter */ public function __construct($xml = '') diff --git a/api/src/Etemplate/Widget/Textbox.php b/api/src/Etemplate/Widget/Textbox.php index a42655e086..fe8e836671 100644 --- a/api/src/Etemplate/Widget/Textbox.php +++ b/api/src/Etemplate/Widget/Textbox.php @@ -14,6 +14,7 @@ namespace EGroupware\Api\Etemplate\Widget; use EGroupware\Api\Etemplate; +use EGroupware\Api; use XMLReader; /** @@ -65,9 +66,9 @@ class Textbox extends Etemplate\Widget // so you got an input element, but it was not editable. if ($this->attrs['size'] < 0) { - $this->setElementAttribute($this->id, 'size', abs($this->attrs['size'])); + self::setElementAttribute($this->id, 'size', abs($this->attrs['size'])); self::$request->readonlys[$this->id] = false; - $this->setElementAttribute($this->id, 'readonly', true); + self::setElementAttribute($this->id, 'readonly', true); trigger_error("Using a negative size to set textbox readonly. " .$this, E_USER_DEPRECATED); } return $this; diff --git a/api/src/Etemplate/Widget/Tree.php b/api/src/Etemplate/Widget/Tree.php index 46644dccf1..1fa12c56d0 100644 --- a/api/src/Etemplate/Widget/Tree.php +++ b/api/src/Etemplate/Widget/Tree.php @@ -113,7 +113,7 @@ class Tree extends Etemplate\Widget /** * Constructor * - * @param string|XMLReader $xml string with xml or XMLReader positioned on the element to construct + * @param string|\XMLReader $xml string with xml or XMLReader positioned on the element to construct * @throws Api\Exception\WrongParameter */ public function __construct($xml = '') @@ -133,9 +133,9 @@ class Tree extends Etemplate\Widget * * Reimplemented to parse our differnt attributes * - * @param string|XMLReader $xml + * @param string|\XMLReader $xml * @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object - * @return Etempalte\Widget current object or clone, if any attribute was set + * @return Etemplate\Widget current object or clone, if any attribute was set */ public function set_attrs($xml, $cloned=true) { @@ -145,7 +145,7 @@ class Tree extends Etemplate\Widget // set attrs[multiple] from attrs[options] if ($this->attrs['options'] > 1) { - $this->setElementAttribute($this->id, 'multiple', true); + self::setElementAttribute($this->id, 'multiple', true); } } diff --git a/api/src/Etemplate/Widget/Vfs.php b/api/src/Etemplate/Widget/Vfs.php index 2b3b2d0f13..ee94a21ced 100644 --- a/api/src/Etemplate/Widget/Vfs.php +++ b/api/src/Etemplate/Widget/Vfs.php @@ -49,7 +49,7 @@ class Vfs extends File $path = $form_name; } - $this->setElementAttribute($form_name, 'path', $path); + self::setElementAttribute($form_name, 'path', $path); // ID maps to path - check there for any existing files list($app,$id,$relpath) = explode(':',$path,3); if($app && $id) diff --git a/api/src/Framework.php b/api/src/Framework.php index eb1421d545..68ff8556eb 100644 --- a/api/src/Framework.php +++ b/api/src/Framework.php @@ -137,7 +137,7 @@ abstract class Framework extends Framework\Extra return preg_match('/^[A-Z0-9_-]+$/i', $template) && file_exists(EGW_SERVER_ROOT.'/'.$template) && file_exists($file=EGW_SERVER_ROOT.'/'.$template.'/setup/setup.inc.php') && - include_once($file) && !empty($GLOBALS['egw_info']['template'][$template]); + include($file) && !empty($GLOBALS['egw_info']['template'][$template]); } /** @@ -367,11 +367,11 @@ abstract class Framework extends Framework\Extra public static function get_page_generation_time() { $times = array( - 'page_generation_time' => sprintf('%4.2lf', microtime(true) - $GLOBALS['egw_info']['flags']['page_start_time']), + 'page_generation_time' => sprintf('%4.2f', microtime(true) - $GLOBALS['egw_info']['flags']['page_start_time']), ); if ($GLOBALS['egw_info']['flags']['session_restore_time']) { - $times['session_restore_time'] = sprintf('%4.2lf', $GLOBALS['egw_info']['flags']['session_restore_time']); + $times['session_restore_time'] = sprintf('%4.2f', $GLOBALS['egw_info']['flags']['session_restore_time']); } return $times; } @@ -594,8 +594,8 @@ abstract class Framework extends Framework\Extra /** * Get login logo or background image base on requested config type * - * @param type $type config type to fetch. e.g.: "login_logo_file" - * @param type $find_type type of image to search on as alternative option. e.g.: "logo" + * @param string $type config type to fetch. e.g.: "login_logo_file" + * @param string $find_type type of image to search on as alternative option. e.g.: "logo" * * @return string returns full url of the image */ @@ -643,7 +643,8 @@ abstract class Framework extends Framework\Extra */ protected static function _user_avatar_menu() { - $stat = array_pop(Hooks::process('framework_avatar_stat')); + $stats = Hooks::process('framework_avatar_stat'); + $stat = array_pop($stats); return '(.*)\n\\s*/s"; $match = null; if (!preg_match($reg,$str,$match)) diff --git a/api/src/Header/Authenticate.php b/api/src/Header/Authenticate.php index 1afef04274..f1fc5fe45b 100644 --- a/api/src/Header/Authenticate.php +++ b/api/src/Header/Authenticate.php @@ -198,7 +198,7 @@ class Authenticate { if (self::digest_auth_available($realm)) { - $nonce = uniqid(); + $nonce = Api\Auth::randomstring(); header('WWW-Authenticate: Digest realm="'.$realm.'",qop="auth",nonce="'.$nonce.'",opaque="'.md5($realm).'"'); if (self::ERROR_LOG) error_log(__METHOD__."() offering digest auth for realm '$realm' using nonce='$nonce'"); } @@ -219,7 +219,8 @@ class Authenticate $data = self::parse_digest($auth_digest); - if (!$data || !($A1 = self::get_digest_A1($realm,$username=$data['username'],$password=null))) + $password = null; + if (!$data || !($A1 = self::get_digest_A1($realm,$username=$data['username'],$password))) { error_log(__METHOD__."('$realm','$auth_digest','$username') returning FALSE"); return false; diff --git a/api/src/Hooks.php b/api/src/Hooks.php index 4b61f7b303..889c12a956 100644 --- a/api/src/Hooks.php +++ b/api/src/Hooks.php @@ -143,7 +143,7 @@ class Hooks $ret[] = ExecMethod2($hook, $args); } } - catch (Api\Exception\AssertionFailed $e) + catch (Exception\AssertionFailed $e) { if (preg_match('/ file .+ not found!$/', $e->getMessage())) { diff --git a/api/src/Html.php b/api/src/Html.php index 4cca2218a9..4b8fa8e2d3 100644 --- a/api/src/Html.php +++ b/api/src/Html.php @@ -1218,7 +1218,7 @@ tinymce.init({ $tree_initialised = true; if (!$_folders && !$autoLoading) return null; } - $html = self::div("\n",'id="'.$tree.'"',$_divClass).$html; + $html = self::div("\n",'id="'.$tree.'"',$_divClass); $html .= "