Required parameter $flatten follows optional parameter $type in ldap_servers/ldap_servers.module

Created on 6 August 2022, over 2 years ago
Updated 15 January 2024, 10 months ago

Problem/Motivation

Address deprecations when upgrading from PHP 7.x to PHP 8.0

Steps to reproduce

Upgrade environment to PHP 8.0
Warning message results:
Deprecated: Required parameter $flatten follows optional parameter $type in /var/www/html/sites/all/modules/ldap/ldap_servers/ldap_servers.module on line 584

Proposed resolution

Fix line with deprecated code

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Closed: outdated

Version

2.0

Component

Code

Created by

🇺🇸United States ethomas08 SF Bay Area

Live updates comments and jobs are added and updated live.
  • PHP 8.0

    The issue particularly affects sites running on PHP version 8.0.0 or later.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India raveendrab

    I am getting the following error after applying the patches.
    Deprecated function: Creation of dynamic property LdapUserConf::$createLDAPAccounts is deprecated in LdapUserConf->load() (line 265 contrib/modules/ldap/ldap_user/LdapUserConf.class.php).

    May be 8.2 specific.
    Upgrading Drupal 7 on Debian 12 bookworm.

  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The last patch failed to apply. Therefore, the status is Needs work.

  • Status changed to RTBC over 1 year ago
  • The latest patch is for a different problem. If #7 still applies, I would just stick with that and then make new issue(s) for the items mentioned in #8 and #10.

  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -function ldap_query_get_queries($qid = NULL, $type, $flatten = FALSE, $reset = FALSE) {
    +function ldap_query_get_queries($qid = NULL, $type = 'all', $flatten = FALSE, $reset = FALSE) {

    Truly, it is not necessary to make all the parameters optional. PHP handles a function declaration like ldap_query_get_queries($qid = NULL, $type, $flatten = FALSE, $reset = FALSE) as ldap_query_get_queries($qid, $type, $flatten = FALSE, $reset = FALSE) because it simply ignores the default value given for the optional parameters that comes before the required parameters. In previous PHP versions, that happened silently; the last versions opted for a deprecation message.

    The correct change is the following one.

    -function ldap_query_get_queries($qid = NULL, $type, $flatten = FALSE, $reset = FALSE) {
    +function ldap_query_get_queries($qid, $type, $flatten = FALSE, $reset = FALSE) {
  • Open in Jenkins → Open on Drupal.org →
    Core: 7.x + Environment: PHP 5.6 & MySQL 5.5
    last update over 1 year ago
    run-tests.sh fatal error
  • @solideogloria opened merge request.
  • Status changed to Needs review over 1 year ago
  • Applied patch #7, along with your recommended change in #13.

    #8 doesn't apply because the change was already in dev.

    #10 has been fixed in the MR, I think, since I added the properties to the class.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 7.x + Environment: PHP 7.4 & MySQL 8
    last update about 1 year ago
    2 pass, 27 fail
  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Closed: outdated 11 months ago
  • Beware, the patch ldap-php-8-compatibility-3302242-7 breaks LDAP pagination.

    Instead of having:
    ```
    ldap_search($this->connection, $ldap_query_params['base_dn'], $ldap_query_params['filter'], array("*"), 0, $this->searchPageSize, -1, LDAP_DEREF_NEVER, $servercontrols);
    $result = $this->ldapQuery($ldap_query_params['scope'], $ldap_query_params);
    ```
    we should just have :
    ```
    $result = ldap_search($this->connection, $ldap_query_params['base_dn'], $ldap_query_params['filter'], array("*"), 0, $this->searchPageSize, -1, LDAP_DEREF_NEVER, $servercontrols);
    ```

    The ldap_servers_php_supports_pagination has not been updated either. If patched as follows, it works again:
    ```
    function ldap_servers_php_supports_pagination() {
    if (version_compare(PHP_VERSION, '8.0.0') >= 0) {
    return TRUE;
    }
    return (boolean)(function_exists('ldap_control_paged_result_response') && function_exists('ldap_control_paged_result'));
    }
    ```

    Despite these pagination issues, everything else works great with this patch.

Production build 0.71.5 2024