Deprecated in PHP 8.0: Required parameter follows optional parameter

Created on 30 September 2022, over 1 year ago
Updated 3 November 2023, 8 months ago

Problem/Motivation

src/modules/contrib/smart_ip/includes/smart_ip.utility.inc
------ -------------------------------------------------------------------------------------
40 line Deprecated in PHP 8.0: Required parameter $context follows optional parameter $src.
------ -------------------------------------------------------------------------------------
src/modules/contrib/smart_ip/modules/smart_ip_views_bridge/views/smart_ip_views_bridge_openlayers_proximity_handler_filter_circle.inc
------ ------------------------------------------------------------------------------------------------------------------------------------------
8 line Deprecated in PHP 8.0: Required parameter $field follows optional parameter $op.
------ ------------------------------------------------------------------------------------------------------------------------------------------
src/modules/contrib/smart_ip/modules/smart_ip_views_bridge/views/smart_ip_views_bridge_openlayers_proximity_handler_filter_square.inc
------ ------------------------------------------------------------------------------------------------------------------------------------------
8 line Deprecated in PHP 8.0: Required parameter $field follows optional parameter $op.
------ ------------------------------------------------------------------------------------------------------------------------------------------

πŸ› Bug report
Status

Fixed

Version

2.41

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine Igumnov_aleksey

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.

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.

  • πŸ‡ΈπŸ‡°Slovakia poker10

    Thanks for working on this.

    -function smart_ip_get_zip($src = NULL, &$context) {
    +function smart_ip_get_zip($src, &$context) {
    +  if (empty($src)){
    +    $src = NULL;
    +  }
    

    There is already a fallback if the $src is empty few lines below, so I suppose we just need to remove the NULL from the parameter default value, see:

      if (empty($src)) {
        // Fallback zip file
        $src = SMART_IP_MAXMIND_LITE_CSV_DOWNLOAD_BASE_URL . '/GeoLiteCity_' . format_date(REQUEST_TIME, 'custom', 'Ym') . '01.zip';
      }
    

    -----------

    Regarding the fixes to the op_process() functions, I would say the better fix would be to just add a default value of empty string to the $field parameters, as these parameters does not seems to be used anywhere in the module or in the openlayers_proximity module anyway. And these are required now, so adding the empty string default value will only fix the deprecation, but it will not introduce and BC break.

    Thanks!

  • @poker10 opened merge request.
    • poker10 β†’ committed bf4d4334 on 7.x-2.x
      Issue #3312924 by Igumnov_aleksey, poker10: Deprecated in PHP 8.0:...
  • Status changed to Fixed 8 months ago
  • πŸ‡ΈπŸ‡°Slovakia poker10

    Merged after applying my suggestions from #7. Thanks!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024