Title: Bug + fix &#8211; Broken plugin path throwing errors
Last modified: July 21, 2021

---

# Bug + fix – Broken plugin path throwing errors

 *  [codepuncher](https://wordpress.org/support/users/krypsin/)
 * (@krypsin)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/bug-fix-broken-plugin-path-throwing-errors/)
 * The plugin has a hardcoded path which causes issues on WP installations that 
   have a different file structure.
 * The message is:
    `Warning: fopen(/path/to/site/web/wp/wp-content/plugins/gravityforms/
   gravityforms.php): failed to open stream: No such file or directory`
 * This error is caused by:
    `gf-form-multicolumn/includes/public/WH_GF_Multicolumn_Public_Form_Current.
   php` in `WH\GF\Multicolumn\Site\WH_GF_Multicolumn_Public_Form_Current::structure_form_elements`
   at line 120.
 * In plugin trunk: [https://plugins.trac.wordpress.org/browser/gf-form-multicolumn/trunk/includes/public/WH_GF_Multicolumn_Public_Form_Current.php#L119](https://plugins.trac.wordpress.org/browser/gf-form-multicolumn/trunk/includes/public/WH_GF_Multicolumn_Public_Form_Current.php#L119)
 * The offending code is:
 *     ```
       		$gfInstallation      = get_plugin_data( ABSPATH .
       		                                        'wp-content/plugins/gravityforms/gravityforms.php' );
       ```
   
 * The solution is:
 *     ```
       		$gfInstallation      = get_plugin_data( WP_CONTENT_DIR .
       		                                        'plugins/gravityforms/gravityforms.php' );
       ```
   
 * tl;dr do not assume the path to the plugins directory as this can be different
   for some installations.
    -  This topic was modified 4 years, 10 months ago by [codepuncher](https://wordpress.org/support/users/krypsin/).

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [WebHolism](https://wordpress.org/support/users/webholism/)
 * (@webholism)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/bug-fix-broken-plugin-path-throwing-errors/#post-14685863)
 * Hi [@krypsin](https://wordpress.org/support/users/krypsin/),
 * Thank you for this detailed description of the issue. This will be addressed 
   and we will notify you soon as we have an update.
 * Many thanks for taking the time to inform us of this issue.
 * Kind regards.
 *  Thread Starter [codepuncher](https://wordpress.org/support/users/krypsin/)
 * (@krypsin)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/bug-fix-broken-plugin-path-throwing-errors/#post-14694307)
 * Thanks [@webholism](https://wordpress.org/support/users/webholism/) .
 * Do you have an ETA on when a new release will be published?
 *  Plugin Author [WebHolism](https://wordpress.org/support/users/webholism/)
 * (@webholism)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/bug-fix-broken-plugin-path-throwing-errors/#post-14697499)
 * Hi [@krypsin](https://wordpress.org/support/users/krypsin/),
 * Thanks for the message.
 * We plan on a release early next week. We hope that this is okay.
 * Kind regards.
 *  Plugin Author [WebHolism](https://wordpress.org/support/users/webholism/)
 * (@webholism)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/bug-fix-broken-plugin-path-throwing-errors/#post-14703008)
 * Hi [@krypsin](https://wordpress.org/support/users/krypsin/),
 * Please can you check the v3.2.1 release to see if it resolves the issue, and 
   advise if you experience any problems?
 * Thank you for your patience.
 * Kind regards.
 *  Thread Starter [codepuncher](https://wordpress.org/support/users/krypsin/)
 * (@krypsin)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/bug-fix-broken-plugin-path-throwing-errors/#post-14794843)
 * Hi [@webholism](https://wordpress.org/support/users/webholism/),
 * Yes, the latest version resolves this issue thanks.
 * However, we are presented with 2 final issues to resolve:
 * Issue 1:
    `Notice: Trying to access array offset on value of type null in gf-
   form-multicolumn/includes/public/WH_GF_Multicolumn_Public_Form_Current.php on
   line 152`
 * Caused by:
 *     ```
       $divisor = ( $this->rowColumnArray[$this->rowCounter] > 0 ) ?
           $this->rowColumnArray[$this->rowCounter] : 1;
       ```
   
 * Why:
    This assumes that `$this->rowColumnArray` is an array. However, it is defined
   without a value which results in it being `null`: `private $rowColumnArray;`
 * The fix:
    Change `private $rowColumnArray;` to `private $rowColumnArray = [];`
 * ==========
 * Issue 2:
    After resolving the above, you will see a new issue. `Notice: Undefined
   offset: 1 in gf-form-multicolumn/includes/public/WH_GF_Multicolumn_Public_Form_Current.
   php on line 152`
 * Caused by:
 *     ```
       $divisor = ( $this->rowColumnArray[$this->rowCounter] > 0 ) ?
           $this->rowColumnArray[$this->rowCounter] : 1;
       ```
   
 * Why:
    This assumes that `$this->rowColumnArray` has an index of `$this->rowCounter`
   but since `$this->rowColumnArray` starts as an empty array, it will result in
   an undefined index.
 * The fix:
    Change
 *     ```
       $divisor = ( $this->rowColumnArray[$this->rowCounter] > 0 ) ?
           $this->rowColumnArray[$this->rowCounter] : 1;
       ```
   
 * To
 *     ```
       $divisor = ( ( $this->rowColumnArray[$this->rowCounter] ?? 0 ) > 0 ) ?
           $this->rowColumnArray[$this->rowCounter] : 1;
       ```
   
 * If the index does not exist, the value will default to 0.
 * All changes proposed are compatible with your plugins minimum PHP version, 7.0.
 * Thanks
    -  This reply was modified 4 years, 9 months ago by [codepuncher](https://wordpress.org/support/users/krypsin/).
 *  Plugin Author [WebHolism](https://wordpress.org/support/users/webholism/)
 * (@webholism)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/bug-fix-broken-plugin-path-throwing-errors/#post-14799796)
 * Hi [@krypsin](https://wordpress.org/support/users/krypsin/),
 * Many thanks for taking the time to provide so much in-depth information on the
   issue and the solutions.
 * It would be ideal to be able to implement the changes in the next update, the
   only problem is that the notice messages that you are providing do not appear
   to be displaying in our WordPress installations. Would it be possible for you
   to state what approach you are using to display those PHP Notice messages that
   you have copied into this thread?
 * Your time and expertise are greatly appreciated.
 * Kind regards.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Bug + fix – Broken plugin path throwing errors’ is closed to new replies.

 * ![](https://ps.w.org/gf-form-multicolumn/assets/icon-256x256.png?rev=1497218)
 * [Multiple Columns for Gravity Forms](https://wordpress.org/plugins/gf-form-multicolumn/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gf-form-multicolumn/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gf-form-multicolumn/)
 * [Active Topics](https://wordpress.org/support/plugin/gf-form-multicolumn/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gf-form-multicolumn/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gf-form-multicolumn/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [WebHolism](https://wordpress.org/support/users/webholism/)
 * Last activity: [4 years, 9 months ago](https://wordpress.org/support/topic/bug-fix-broken-plugin-path-throwing-errors/#post-14799796)
 * Status: not resolved