Sometimes `$options` parameter in `hook_url_outbound_alter()` implementation may be received with `$options['query']` as `NULL` (in my case, pathlogic module is responsible for that). Line `$options['query'] += drupal_get_destination();` within `helper_url_outbound_alter()` cause to throw "Unsupported operand types" when it happens.

Issue fork pathologic-2789953

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

junaidpv created an issue. See original summary.

junaidpv’s picture

Status: Active » Needs review
StatusFileSize
new570 bytes

Attached simple patch to fix the issue.

hiraethmarkb’s picture

Can confirm that this patch works, and resolves the issue when using 7.x-1.9 of the Helper module.

anybody’s picture

Thank you very much. Could the maintainer perhaps create a new dev or even stable release? The module isn't usable under PHP 7.x currently!

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Tested and works! RTBC +1

dave reid’s picture

Status: Reviewed & tested by the community » Needs work

I think I need to push back on this. The documentation for the url() method clearly states that the 'query' option should be an array, it does not say that NULL is a valid value:

'query': An array of query key/value-pairs (without any URL-encoding) to append to the URL.

I think this needs to be addressed in the Pathologic module.

dave reid’s picture

Title: Throws exception "Unsupported operand types" within helper_url_outbound_alter() » Do not set NULL for $options['query']
Project: Helper » Pathologic
Version: 7.x-1.x-dev » 7.x-3.x-dev
dave reid’s picture

Status: Needs work » Needs review
StatusFileSize
new560 bytes

This should resolve it.

dave reid’s picture

Could also use is_array() instead of isset(), or both possibly.

dave reid’s picture

StatusFileSize
new595 bytes

Updated to not use the array short-syntax and add a check for is_array().

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Confirming RTBC again for #10, thank you Dave!

mark_fullmer’s picture

Assigned: Unassigned » mark_fullmer

urvashi_vora made their first commit to this issue’s fork.

mark_fullmer’s picture

Status: Reviewed & tested by the community » Fixed

The merge request in #14 looks like it includes just the same change as the patch in #10, but it's set to merge into master instead of 7.x-3.x. In any case, using the patch in #10 here is sufficient for merging. The code change makes sense and has been RTBC'd.

Merged and setting as "Fixed"!

dww’s picture

Thanks for cleaning this up. Confirmed this bug doesn't exist in the 8.x-1.x branch.

Status: Fixed » Closed (fixed)

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