ynorth-projects / openy_repeat

Decouple openy_repeat.
1 stars 17 forks source link

Resolve deprecated php warnings. #36

Closed Sardis93 closed 1 year ago

Sardis93 commented 1 year ago

Sometimes the class doesn't have a description, thus producing warnings like:

Deprecated function: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\openy_repeat\Controller\RepeatController->getClassesInfo() (line 469 of /app/docroot/modules/contrib/openy_repeat/src/Controller/RepeatController.php)
#0 /app/docroot/core/includes/bootstrap.inc(347): _drupal_error_handler_real(8192, 'strip_tags(): P...', '/app/docroot/mo...', 469)
#1 [internal function]: _drupal_error_handler(8192, 'strip_tags(): P...', '/app/docroot/mo...', 469)
#2 /app/docroot/modules/contrib/openy_repeat/src/Controller/RepeatController.php(469): strip_tags(NULL)
#3 /app/docroot/modules/contrib/openy_repeat/src/Controller/RepeatController.php(323): Drupal\openy_repeat\Controller\RepeatController->getClassesInfo(Array)
Deprecated function: mb_strlen(): Passing null to parameter #1 ($string) of type string is deprecated in text_summary() (line 95 of /app/docroot/core/modules/text/text.module)
#0 /app/docroot/core/includes/bootstrap.inc(347): _drupal_error_handler_real(8192, 'mb_strlen(): Pa...', '/app/docroot/co...', 95)
#1 [internal function]: _drupal_error_handler(8192, 'mb_strlen(): Pa...', '/app/docroot/co...', 95)
#2 /app/docroot/core/modules/text/text.module(95): mb_strlen(NULL)
#3 /app/docroot/modules/contrib/openy_repeat/src/Controller/RepeatController.php(469): text_summary(NULL, NULL, 600)
#4 /app/docroot/modules/contrib/openy_repeat/src/Controller/RepeatController.php(323): Drupal\openy_repeat\Controller\RepeatController->getClassesInfo(Array)
Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in text_summary() (line 71 of /app/docroot/core/modules/text/text.module)
#0 /app/docroot/core/includes/bootstrap.inc(347): _drupal_error_handler_real(8192, 'strpos(): Passi...', '/app/docroot/co...', 71)
#1 [internal function]: _drupal_error_handler(8192, 'strpos(): Passi...', '/app/docroot/co...', 71)
#2 /app/docroot/core/modules/text/text.module(71): strpos(NULL, '<!--break-->')
#3 /app/docroot/modules/contrib/openy_repeat/src/Controller/RepeatController.php(469): text_summary(NULL, NULL, 600)
#4 /app/docroot/modules/contrib/openy_repeat/src/Controller/RepeatController.php(323): Drupal\openy_repeat\Controller\RepeatController->getClassesInfo(Array)

Let's make sure we apply the transformation only when the value for the field is not empty.

Second commit aims to resolve:

Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated in Drupal\openy_repeat\Controller\RepeatController->groupByActivity() (line 648 of /app/docroot/modules/contrib/openy_repeat/src/Controller/RepeatController.php)
#0 /app/docroot/core/includes/bootstrap.inc(347): _drupal_error_handler_real(8192, 'explode(): Pass...', '/app/docroot/mo...', 648)
#1 [internal function]: _drupal_error_handler(8192, 'explode(): Pass...', '/app/docroot/mo...', 648)
#2 /app/docroot/modules/contrib/openy_repeat/src/Controller/RepeatController.php(648): explode(' ', NULL)
#3 /app/docroot/modules/contrib/openy_repeat/src/Controller/RepeatController.php(571): Drupal\openy_repeat\Controller\RepeatController->groupByActivity(Array, '', 0, 0, Array)

This happens when there's no instructor information.