Skip to content

Commit

Permalink
Add a deprecation check for null parameters for explode() and strlen(…
Browse files Browse the repository at this point in the history
…) function calls
  • Loading branch information
tbsiqueira committed Jul 11, 2023
1 parent 0ec64df commit 4822cf6
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion modules/custom/activity_basics/activity_basics.install
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function activity_basics_update_8103() : void {
$activity_bundle_entity = $config->get('third_party_settings.activity_logger.activity_bundle_entity');
$config->clear('third_party_settings.activity_logger.activity_bundle_entity');

$bundle_entity = explode('.', $activity_bundle_entity);
$bundle_entity = explode('.', $activity_bundle_entity ?? "");
$activity_bundle_entity_new = $bundle_entity[0] . '-' . $bundle_entity[1];
$activity_bundle_entities = [$activity_bundle_entity_new => $activity_bundle_entity_new];

Expand Down
2 changes: 1 addition & 1 deletion modules/custom/download_count/download_count.module
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function download_count_file_access(EntityInterface $entity, $operation, Account
}

// Validate file has extension that should be counted, if not return.
$extensions = explode(' ', mb_strtolower(trim($config->get('download_count_excluded_file_extensions'))));
$extensions = explode(' ', mb_strtolower(trim($config->get('download_count_excluded_file_extensions') ?? "")));
$extension = mb_strtolower(pathinfo($entity->getFilename(), PATHINFO_EXTENSION));
if (in_array($extension, $extensions, TRUE)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ function _social_path_manager_update_alias(EntityInterface $entity, $op, $bulk =
$entity_language = $entity->language()->getId();

// Prevent adding alias for default tab.
$source_parts = explode('/', $path['source']);
$source_parts = explode('/', $path['source'] ?? "");
if (end($source_parts) === $suffix) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function social_follow_user_uninstall(): void {

if (!empty($config->getRawData())) {
$pages = $config->get('visibility.request_path.pages');
$pages = explode("\r\n", $pages);
$pages = explode("\r\n", $pages ?? "");

foreach ($pages as $delta => $page) {
if (in_array($page, $paths)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
* List of emails to invite .
*/
private function getSubmittedEmails(FormStateInterface $form_state) {
return array_map('trim', array_unique(explode("\r\n", trim($form_state->getValue('email_address')))));
return array_map('trim', array_unique(explode("\r\n", trim($form_state->getValue('email_address') ?? ""))));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function social_landing_page_field_widget_block_field_default_form_alter(&$eleme

// Grab the id.
$id = $block_settings['#attributes']['id'];
$items = explode('-', $id);
$items = explode('-', $id ?? "");

// Generate the new state name.
// We use block id, to get all the parent names
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SocialPostAlbumManagedFile extends ManagedFile {
*/
public static function uploadAjaxCallback(&$form, FormStateInterface &$form_state, Request $request) {
$response = parent::uploadAjaxCallback($form, $form_state, $request);
$parents = explode('/', $request->query->get('element_parents'));
$parents = explode('/', $request->query->get('element_parents') ?? "");

return $response->addCommand(new InvokeCommand(
'#edit-' . str_replace('_', '-', $parents[0]) . '-wrapper',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getUserIdsFromName($name, $count, $suggestion_format = SOCIAL_PR
case SOCIAL_PROFILE_SUGGESTIONS_FULL_NAME:
case SOCIAL_PROFILE_SUGGESTIONS_ALL:
if ($this->useFullName()) {
$strings = explode(' ', $name);
$strings = explode(' ', $name ?? "");

if (count($strings) > 1) {
$query->where("CONCAT(TRIM(fn.field_profile_first_name_value), ' ', TRIM(ln.field_profile_last_name_value)) LIKE :full_name", [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function social_swiftmail_preprocess_swiftmailer(array &$variables) {
$secondary = $colors['brand-secondary'];
$accent = $colors['brand-accent'];
$link = $colors['brand-link'];
$border_radius = Xss::filter(theme_get_setting('border_radius', $theme_id));
$border_radius = Xss::filter(theme_get_setting('border_radius', $theme_id) ?? "");

// Add variables to send to the html template.
$variables['logo'] = $logo;
Expand Down Expand Up @@ -117,7 +117,7 @@ function social_swiftmail_preprocess_swiftmailer(array &$variables) {
}

$disabled_greeting_keys = $social_swiftmail_config->get("disabled_user_greeting_keys");
$disabled_greeting_keys = explode("\r\n", $disabled_greeting_keys);
$disabled_greeting_keys = explode("\r\n", $disabled_greeting_keys ?? "");
$replace = [
'@display_name' => $display_name,
];
Expand Down

0 comments on commit 4822cf6

Please sign in to comment.