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"

Comments

Abhinand Gokhala K created an issue. See original summary.

abhinand gokhala k’s picture

I have solved this issue.

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

I did the changes.

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.