Skip to content

Additiona php deprecation fixes for the 1.2 branch. #309

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion lib/HTMLTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public function draw($onlytree=false) {
$this->javascript .= '<div>';
$this->javascript .= '<input type="hidden" name="cmd" value="template_engine" />';
$this->javascript .= sprintf('<input type="hidden" name="server_id" value="%s" />',$server->getIndex());
$this->javascript .= sprintf('<input type="hidden" name="container" value="%s" />',htmlspecialchars($server->getContainer($base->getDN())));
$t = $server->getContainer($base->getDN());
$this->javascript .= sprintf('<input type="hidden" name="container" value="%s" />',htmlspecialchars(is_null($t)? '': $t));
Comment on lines +101 to +102

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use $this->javascript .= sprintf('<input type="hidden" name="container" value="%s" />',htmlspecialchars($server->getContainer($base->getDN() ?? '')));

In what case did you encounter a null value ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to retain php 5.6 compatibility thus I don't use ??

In what case did you encounter a null value ?

I don't remember. exactly: I wrote it a long time ago and, as PR were not very responsive here, did not submit it.
AFAICR, I was experimenting with a DN component count <= 1.
See

phpLDAPadmin/lib/ds_ldap.php

Lines 1066 to 1067 in 3c1f016

if (count($parts) <= 1)
$return = null;

$this->javascript .= sprintf('<input type="hidden" name="rdn" value="%s" />',get_rdn($base->getDN()));
$this->javascript .= sprintf('<input type="hidden" name="rdn_attribute[]" value="%s" />',$rdn[0]);
$this->javascript .= sprintf('<input type="hidden" name="new_values[%s][]" value="%s" />',$rdn[0],$rdn[1]);
Expand Down
1 change: 1 addition & 0 deletions lib/PLAAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @package phpLDAPadmin
* @subpackage Templates
*/
#[\AllowDynamicProperties]
class PLAAttribute {
# Attribute Name
public $name;
Expand Down
1 change: 1 addition & 0 deletions lib/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @package phpLDAPadmin
* @subpackage Queries
*/
#[\AllowDynamicProperties]
class Query extends xmlTemplate {
protected $description = '';
public $results = array();
Expand Down
1 change: 1 addition & 0 deletions lib/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* @todo RDN attributes need to be checked that are included in the schema, otherwise mark it is invalid
* @todo askcontainer is no longer used?
*/
#[\AllowDynamicProperties]
class Template extends xmlTemplate {
# If this template visible on the template choice list
private $visible = true;
Expand Down
2 changes: 2 additions & 0 deletions lib/TemplateRender.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
class TemplateRender extends PageRender {
# Page number
private $pagelast;
private $url_base;
private $layout;

/** CORE FUNCTIONS **/

Expand Down
11 changes: 7 additions & 4 deletions lib/ds_ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,13 @@ protected function connect($method,$debug=false,$new=false) {
if (function_exists('run_hook'))
run_hook('pre_connect',array('server_id'=>$this->index,'method'=>$method));

if ($this->getValue('server','port'))
$resource = ldap_connect($this->getValue('server','host'),$this->getValue('server','port'));
else
$resource = ldap_connect($this->getValue('server','host'));
$uri = $this->getValue('server','host');
if (strpos($uri, '://') === false) {
$uri = 'ldap://' . urlencode($uri);
if ($this->getValue('server','port'))
$uri .= ':' . $this->getValue('server','port');
}
$resource = ldap_connect($uri);

$this->noconnect = false;
$CACHE[$this->index][$method] = $resource;
Expand Down
15 changes: 12 additions & 3 deletions lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function app_error_handler($errno,$errstr,$file,$lineno) {
$errtype = '';

switch ($errno) {
case E_STRICT: $errtype = 'E_STRICT'; break;
case E_DEPRECATED: $errtype = 'E_DEPRECATED'; break;
case E_ERROR: $errtype = 'E_ERROR'; break;
case E_WARNING: $errtype = 'E_WARNING'; break;
case E_PARSE: $errtype = 'E_PARSE'; break;
Expand Down Expand Up @@ -642,8 +642,17 @@ function error($msg,$type='note',$redirect=null,$fatal=false,$backtrace=false) {
_('Function'),$line['function']);

if (isset($line['args'])) {
$display = strlen(serialize($line['args'])) < 50 ? htmlspecialchars(serialize($line['args'])) : htmlspecialchars(substr(serialize($line['args']),0,50)).'...<TRUNCATED>';
$_SESSION['backtrace'][$error]['args'] = $line['args'];
$args = $line['args'];
// Filter out SensitiveParameterValue objects
$args = array_map(function ($arg) {
if ($arg instanceof \SensitiveParameterValue) {
return '**SENSITIVE**';
}
return $arg;
}, $args);

$display = strlen(serialize($args)) < 50 ? htmlspecialchars(serialize($args)) : htmlspecialchars(substr(serialize($args),0,50)).'...<TRUNCATED>';
$_SESSION['backtrace'][$error]['args'] = $args;
if (file_exists(LIBDIR.'../tools/unserialize.php'))
$body .= sprintf('&nbsp;(<a href="%s?index=%s" onclick="target=\'backtrace\';">%s</a>)',
'../tools/unserialize.php',$error,$display);
Expand Down
1 change: 1 addition & 0 deletions lib/import_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public function LDAPimport() {
* @package phpLDAPadmin
* @subpackage Import
*/
#[\AllowDynamicProperties]
class ImportLDIF extends Import {
private $_currentLineNumber = 0;
private $_currentLine = '';
Expand Down
1 change: 1 addition & 0 deletions lib/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @package phpLDAPadmin
* @subpackage Page
*/
#[\AllowDynamicProperties]
class page {
# pre-HTML headers
protected $_pageheader;
Expand Down
2 changes: 1 addition & 1 deletion lib/schema_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ abstract class SchemaItem {
# The description of this schema item.
protected $description = '';
# Boolean value indicating whether this objectClass is obsolete
private $is_obsolete = false;
protected $is_obsolete = false;

public function setOID($oid) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
Expand Down
5 changes: 2 additions & 3 deletions lib/xml2array.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ private function pop_pos() {

public function parseXML($strInputXML,$filename) {
$this->resParser = xml_parser_create();
xml_set_object($this->resParser,$this);
xml_set_element_handler($this->resParser,'tagOpen','tagClosed');
xml_set_element_handler($this->resParser, [$this, 'tagOpen'], [$this, 'tagClosed']);

xml_set_character_data_handler($this->resParser,'tagData');
xml_set_character_data_handler($this->resParser, [$this, 'tagData']);

$this->push_pos($this->arrOutput);

Expand Down