I have created platfor using git repo. But during the verification it show a warning message "trim() expects parameter 1 to be string, array given provision_git.drush.inc:458"

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Abhinand Gokhala K created an issue. See original summary.

Abhinand Gokhala K’s picture

Abhinand Gokhala K’s picture

Assigned: Abhinand Gokhala K » Unassigned
Status: Active » Needs review
colan’s picture

Status: Needs review » Needs work

Good catch. Some review:

+++ b/drush/provision_git.drush.inc
@@ -455,7 +455,13 @@ function _provision_git_update_git_meta_data() {
-      $git_ref = trim(str_replace('refs/heads/', '',drush_shell_exec_output()));;
+      $temp_git_ref =  str_replace('refs/heads/', '',drush_shell_exec_output());
+      ¶
+      if(!empty($temp_git_ref) && is_string($temp_git_ref)) {
+        $temp_git_ref = trim($temp_git_ref);
+      }
+
+      $git_ref = $temp_git_ref;

All of this could be shortened to:

$temp_git_ref = str_replace('refs/heads/', '',drush_shell_exec_output());
$git_ref = (!empty($temp_git_ref) && is_string($temp_git_ref)) ? trim($temp_git_ref) : $temp_git_ref;

Other minor things:

  • Extra whitespace on line 460.
  • Space needed after "if", but we no longer need it.
Abhinand Gokhala K’s picture

Yes, Thanks for the replay.

Abhinand Gokhala K’s picture

Abhinand Gokhala K’s picture

Abhinand Gokhala K’s picture

Status: Needs work » Needs review
Abhinand Gokhala K’s picture

Issue summary: View changes
Abhinand Gokhala K’s picture

Is this fine?

colan’s picture

Status: Needs review » Reviewed & tested by the community

Code looks good. It would be great if someone else could test it, but maybe we're okay with the tests we have.

helmo’s picture

I noticed the same warning and this patch resolved it.

Committed.

helmo’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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