title: Error only with php 7.1 how to solve the "Too few arguments to function get_query_var()"
body: <p>Please just le me say some things important</p>
  
  <p>1) I'm a completely newbie to php coding, basically i don't know how to code, I'm able just to "understand" something looking at the code but in the most times I don't know how to solve an issue, I just try to change something in the code and try an try again.</p>
  
  <p>2) I see there are other question-topic like this but no one of them seems to solve my issue because no one of them explains WHAT to change in the code. </p>
  
  <p>I have a wordpress site and since my hosting provider updated to php 7.1 I receive this error during a checkout process</p>
  
  <pre><code>  Fatal error: Uncaught ArgumentCountError: Too few arguments to function get_query_var(), 0 passed in /homepages/27/d717103608/htdocs/clickandbuilds/IlCrudoeIlCotto/wp-content/plugins/woocommerce_events/classes/woohelper.php on line 688 and at least 1 expected in /homepages/27/d717103608/htdocs/clickandbuilds/IlCrudoeIlCotto/wp-includes/query.php:26 Stack trace: #0 /homepages/27/d717103608/htdocs/clickandbuilds/IlCrudoeIlCotto/wp-content/plugins/woocommerce_events/classes/woohelper.php(688): get_query_var() #1 /homepages/27/d717103608/htdocs/clickandbuilds/IlCrudoeIlCotto/wp-includes/class-wp-hook.php(288): Woo_Helper-&gt;display_thank_you_text('Grazie. Il tuo ...') #2 /homepages/27/d717103608/htdocs/clickandbuilds/IlCrudoeIlCotto/wp-includes/plugin.php(203): WP_Hook-&gt;apply_filters('Grazie. Il tuo ...', Array) #3 /homepages/27/d717103608/htdocs/clickandbuilds/IlCrudoeIlCotto/wp-content/plugins/woocommerce/templates/checkout/thankyou.php(41): apply_filters('woocommerce_tha...', 'Grazie. Il tuo ...', Object(WC_Order)) #4 /homep in /homepages/27/d717103608/htdocs/clickandbuilds/IlCrudoeIlCotto/wp-includes/query.php on line 26
  </code></pre>
  
  <p>I know this is a well-know issue because in php 7.1 what was a "warning" has been promoted to be fatal error
  see this:
  <a href="https://www.bestwebframeworks.com/tutorials/php/153/solve-php-uncaught-argumentcounterror-too-few-arguments-to-function/" rel="nofollow noreferrer">https://www.bestwebframeworks.com/tutorials/php/153/solve-php-uncaught-argumentcounterror-too-few-arguments-to-function/</a></p>
  
  <p>and this
  <a href="http://php.net/manual/en/class.argumentcounterror.php" rel="nofollow noreferrer">http://php.net/manual/en/class.argumentcounterror.php</a></p>
  
  <p>The problem is.. I completely don't know what to change in my php files to have this working again, and I dont know where to check for some error. 
  I understood that this problem belongs to a function that expect like 1 argument and receives nothing, but I dont know how to chek... This place is my last resource. </p>
  
  <p>Then I put here my php files involved in the error, hope that someone will be so kind to help me. Thanks</p>
  
  <p>At these URLs you can find the whole php files
  woohelper.php
  <a href="https://pastebin.com/EAwjg9Wm" rel="nofollow noreferrer">https://pastebin.com/EAwjg9Wm</a></p>
  
  <p>class-wp-hook.php
  <a href="https://pastebin.com/9K9nrk20" rel="nofollow noreferrer">https://pastebin.com/9K9nrk20</a></p>
  
  <p>query.php
  <a href="https://pastebin.com/Qy6aGmcX" rel="nofollow noreferrer">https://pastebin.com/Qy6aGmcX</a></p>
  
  <p>plugin.php
  <a href="https://pastebin.com/HutKXEuy" rel="nofollow noreferrer">https://pastebin.com/HutKXEuy</a></p>
  
  <p>thankyou.php
  <a href="https://pastebin.com/yDw8mCi8" rel="nofollow noreferrer">https://pastebin.com/yDw8mCi8</a></p>
  
  <p>From here I will just copy the parts that are listed in the error received.</p>
  
  <p>Please also note.. if I revert my server php version prior to 7.1 (e.g. 7.0 or 6.9) everything works fine.</p>
  
  <p>woohelper.php (error in line 688)</p>
  
  <pre><code>  public function display_thank_you_text($thankYouText) {
  
          global $woocommerce;
          global $post;
  
          $paged = get_query_var();    /*THIS IS LINE 688*/
  
          $actualLink = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
          $segments = array_reverse(explode('/', $actualLink));
  
          $orderID = $segments[1];
          $order = new WC_Order($orderID);
          $items = $order-&gt;get_items();
  
          $products = array();
  
          foreach($items as $item) {
  
              $products[$item['product_id']] = $item['product_id'];
  
          }
  
          foreach($products as $key =&gt; $productID) {
  
              $WooCommerceEventsThankYouText = get_post_meta($productID, 'WooCommerceEventsThankYouText', true);
  
              if(!empty($WooCommerceEventsThankYouText)) {
  
                  echo $WooCommerceEventsThankYouText."&lt;br/&gt;&lt;br/&gt;";
  
              }
  
          }
  
          return $thankYouText;
  
      }
  </code></pre>
  
  <p>query.php  (error in line 26)</p>
  
  <pre><code>    function get_query_var( $var, $default = '' ) {    /* THIS IS LINE 26 */
      global $wp_query;
      return $wp_query-&gt;get( $var, $default );
  }
  </code></pre>
  
  <p>wp-class-hook.php (error in line 288)</p>
  
  <pre><code>        /**
       * Calls the callback functions added to a filter hook.
       *
       * @since 4.7.0
       *
       * @param mixed $value The value to filter.
       * @param array $args  Arguments to pass to callbacks.
       * @return mixed The filtered value after all hooked functions are applied to it.
       */
      public function apply_filters( $value, $args ) {
          if ( ! $this-&gt;callbacks ) {
              return $value;
          }
  
          $nesting_level = $this-&gt;nesting_level++;
  
          $this-&gt;iterations[ $nesting_level ] = array_keys( $this-&gt;callbacks );
          $num_args = count( $args );
  
          do {
              $this-&gt;current_priority[ $nesting_level ] = $priority = current( $this-&gt;iterations[ $nesting_level ] );
  
              foreach ( $this-&gt;callbacks[ $priority ] as $the_ ) {
                  if( ! $this-&gt;doing_action ) {
                      $args[ 0 ] = $value;
                  }
  
                  // Avoid the array_slice if possible.
                  if ( $the_['accepted_args'] == 0 ) {
                      $value = call_user_func_array( $the_['function'], array() );
                  } elseif ( $the_['accepted_args'] &gt;= $num_args ) {
                      $value = call_user_func_array( $the_['function'], $args );
                  } else {
  /** THIS IS LINE 288 */ $value = call_user_func_array( $the_['function'], array_slice( $args, 0, (int)$the_['accepted_args'] ) );
                  }
              }
          } while ( false !== next( $this-&gt;iterations[ $nesting_level ] ) );
  
          unset( $this-&gt;iterations[ $nesting_level ] );
          unset( $this-&gt;current_priority[ $nesting_level ] );
  
          $this-&gt;nesting_level--;
  
          return $value;
      }
  </code></pre>
  
  <p>plugin.php (error in line 203)</p>
  
  <pre><code>    function apply_filters( $tag, $value ) {
      global $wp_filter, $wp_current_filter;
  
      $args = array();
  
      // Do 'all' actions first.
      if ( isset($wp_filter['all']) ) {
          $wp_current_filter[] = $tag;
          $args = func_get_args();
          _wp_call_all_hook($args);
      }
  
      if ( !isset($wp_filter[$tag]) ) {
          if ( isset($wp_filter['all']) )
              array_pop($wp_current_filter);
          return $value;
      }
  
      if ( !isset($wp_filter['all']) )
          $wp_current_filter[] = $tag;
  
      if ( empty($args) )
          $args = func_get_args();
  
      // don't pass the tag name to WP_Hook
      array_shift( $args );
  
  /* THIS IS LINE 203 */  $filtered = $wp_filter[ $tag ]-&gt;apply_filters( $value, $args );
  
      array_pop( $wp_current_filter );
  
      return $filtered;
  }
  </code></pre>
  
  <p>thankyou.php</p>
  
  <pre><code>    &lt;div class="woocommerce-order"&gt;
  
      &lt;?php if ( $order ) : ?&gt;
  
          &lt;?php if ( $order-&gt;has_status( 'failed' ) ) : ?&gt;
  
              &lt;p class="woocommerce-notice woocommerce-notice--error woocommerce-thankyou-order-failed"&gt;&lt;?php _e( 'Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction. Please attempt your purchase again.', 'woocommerce' ); ?&gt;&lt;/p&gt;
  
              &lt;p class="woocommerce-notice woocommerce-notice--error woocommerce-thankyou-order-failed-actions"&gt;
                  &lt;a href="&lt;?php echo esc_url( $order-&gt;get_checkout_payment_url() ); ?&gt;" class="button pay"&gt;&lt;?php _e( 'Pay', 'woocommerce' ) ?&gt;&lt;/a&gt;
                  &lt;?php if ( is_user_logged_in() ) : ?&gt;
                      &lt;a href="&lt;?php echo esc_url( wc_get_page_permalink( 'myaccount' ) ); ?&gt;" class="button pay"&gt;&lt;?php _e( 'My account', 'woocommerce' ); ?&gt;&lt;/a&gt;
                  &lt;?php endif; ?&gt;
              &lt;/p&gt;
  
          &lt;?php else : ?&gt;
  
  !-- this is line 41 -!  &lt;p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"&gt;&lt;?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), $order ); ?&gt;&lt;/p&gt;
  
              &lt;ul class="woocommerce-order-overview woocommerce-thankyou-order-details order_details"&gt;
  
                  &lt;li class="woocommerce-order-overview__order order"&gt;
                      &lt;?php _e( 'Order number:', 'woocommerce' ); ?&gt;
                      &lt;strong&gt;&lt;?php echo $order-&gt;get_order_number(); ?&gt;&lt;/strong&gt;
                  &lt;/li&gt;
  
                  &lt;li class="woocommerce-order-overview__date date"&gt;
                      &lt;?php _e( 'Date:', 'woocommerce' ); ?&gt;
                      &lt;strong&gt;&lt;?php echo wc_format_datetime( $order-&gt;get_date_created() ); ?&gt;&lt;/strong&gt;
                  &lt;/li&gt;
  
                  &lt;?php if ( is_user_logged_in() &amp;&amp; $order-&gt;get_user_id() === get_current_user_id() &amp;&amp; $order-&gt;get_billing_email() ) : ?&gt;
                      &lt;li class="woocommerce-order-overview__email email"&gt;
                          &lt;?php _e( 'Email:', 'woocommerce' ); ?&gt;
                          &lt;strong&gt;&lt;?php echo $order-&gt;get_billing_email(); ?&gt;&lt;/strong&gt;
                      &lt;/li&gt;
                  &lt;?php endif; ?&gt;
  
                  &lt;li class="woocommerce-order-overview__total total"&gt;
                      &lt;?php _e( 'Total:', 'woocommerce' ); ?&gt;
                      &lt;strong&gt;&lt;?php echo $order-&gt;get_formatted_order_total(); ?&gt;&lt;/strong&gt;
                  &lt;/li&gt;
  
                  &lt;?php if ( $order-&gt;get_payment_method_title() ) : ?&gt;
                      &lt;li class="woocommerce-order-overview__payment-method method"&gt;
                          &lt;?php _e( 'Payment method:', 'woocommerce' ); ?&gt;
                          &lt;strong&gt;&lt;?php echo wp_kses_post( $order-&gt;get_payment_method_title() ); ?&gt;&lt;/strong&gt;
                      &lt;/li&gt;
                  &lt;?php endif; ?&gt;
  
              &lt;/ul&gt;
  
          &lt;?php endif; ?&gt;
  
          &lt;?php do_action( 'woocommerce_thankyou_' . $order-&gt;get_payment_method(), $order-&gt;get_id() ); ?&gt;
          &lt;?php do_action( 'woocommerce_thankyou', $order-&gt;get_id() ); ?&gt;
  
      &lt;?php else : ?&gt;
  
          &lt;p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"&gt;&lt;?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), null ); ?&gt;&lt;/p&gt;
  
      &lt;?php endif; ?&gt;
  
  &lt;/div&gt;
  </code></pre>