Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WC causing preg_match(): null byte in regex in wp-includes\functions.php on line 5163 #13008

Closed
indextwo opened this issue Jan 27, 2017 · 1 comment

Comments

@indextwo
Copy link

indextwo commented Jan 27, 2017

EXPLANATION OF THE ISSUE

Running WooCommerce 2.6.13 under WP 2.7.1 or 2.7.2 on XAMPP Apache/PHP7 under Win7, getting error:

preg_match(): null byte in regex in wp-includes\functions.php on line 5163

Getting it on all sites running WooCommerce; stripped down to just WC running with twentyseventeen theme, issue persists. Disable WooCommerce, error disappears.

However, from what I can determine, doesn't seem to be an issue on remote server; nginx running PHP 5.6.

RESULT OF BACKTRACE:

It looks like the core function with the issue is wp_is_stream(). Here's a debug_backtrace of the call stack:

#0  wp_is_stream() called at [C:\xampplite\htdocs\mysite\wp-includes\functions.php:1600]
#1  wp_mkdir_p() called at [C:\xampplite\htdocs\mysite\wp-includes\functions.php:1900]
#2  wp_upload_dir() called at [C:\xampplite\htdocs\mysite\wp-content\plugins\woocommerce\woocommerce.php:178]
#3  WooCommerce->define_constants() called at [C:\xampplite\htdocs\mysite\wp-content\plugins\woocommerce\woocommerce.php:152]
#4  WooCommerce->__construct() called at [C:\xampplite\htdocs\mysite\wp-content\plugins\woocommerce\woocommerce.php:116]
#5  WooCommerce::instance() called at [C:\xampplite\htdocs\mysite\wp-content\plugins\woocommerce\woocommerce.php:551]
#6  WC() called at [C:\xampplite\htdocs\mysite\wp-content\plugins\woocommerce\woocommerce.php:555]
#7  include_once(C:\xampplite\htdocs\mysite\wp-content\plugins\woocommerce\woocommerce.php) called at [C:\xampplite\htdocs\mysite\wp-settings.php:304]
#8  require_once(C:\xampplite\htdocs\mysite\wp-settings.php) called at [C:\xampplite\htdocs\mysite\wp-config.php:142]
#9  require_once(C:\xampplite\htdocs\mysite\wp-config.php) called at [C:\xampplite\htdocs\mysite\wp-load.php:37]
#10 require_once(C:\xampplite\htdocs\mysite\wp-load.php) called at [C:\xampplite\htdocs\mysite\wp-admin\admin.php:31]
#11 require_once(C:\xampplite\htdocs\mysite\wp-admin\admin.php) called at [C:\xampplite\htdocs\mysite\wp-admin\plugins.php:10]

Edit:

having looked into it some more with the information from that call stack, it looks like the issue is directly within the define_constants() function - specifically, if I comment out these two lines:

$upload_dir = wp_upload_dir();
...
$this->define( 'WC_LOG_DIR', $upload_dir['basedir'] . '/wc-logs/' );

...the error disappears.

Edit 2:

I've whittled this down to just the call on wp_upload_dir() - seems to be a core issue. I've submitted a Trac ticket: https://core.trac.wordpress.org/ticket/39722#ticket

SYSTEM STATUS REPORT

### WordPress Environment ###

Home URL: http://localhost/mysite
Site URL: http://localhost/mysite
WC Version: 2.6.13
Log Directory Writable: ?
WP Version: 4.7.2
WP Multisite: –
WP Memory Limit: 1 GB
WP Debug Mode: –
WP Cron: ?
Language: en_GB

### Server Environment ###

Server Info: Apache/2.4.18 (Win32) OpenSSL/1.0.2e PHP/7.0.8
PHP Version: 7.0.8
PHP Post Max Size: 64 MB
PHP Time Limit: 1200
PHP Max Input Vars: 1000
cURL Version: 7.49.1
OpenSSL/1.0.2e

SUHOSIN Installed: –
Max Upload Size: 64 MB
Default Timezone is UTC: ?
fsockopen/cURL: ?
SoapClient: ?
DOMDocument: ?
GZip: ?
Multibyte String: ?
Remote Post: ?
Remote Get: ?

### Database ###

WC Database Version: 2.6.13
: 
woocommerce_sessions: ?
woocommerce_api_keys: ?
woocommerce_attribute_taxonomies: ?
woocommerce_downloadable_product_permissions: ?
woocommerce_order_items: ?
woocommerce_order_itemmeta: ?
woocommerce_tax_rates: ?
woocommerce_tax_rate_locations: ?
woocommerce_shipping_zones: ?
woocommerce_shipping_zone_locations: ?
woocommerce_shipping_zone_methods: ?
woocommerce_payment_tokens: ?
woocommerce_payment_tokenmeta: ?
MaxMind GeoIP Database: ?

### Active Plugins (1) ###

WooCommerce: by WooThemes – 2.6.13

### Settings ###

Force SSL: –
Currency: GBP (£)
Currency Position: left
Thousand Separator: ,
Decimal Separator: .
Number of Decimals: 2

### API ###

API Enabled: ?

### WC Pages ###

Shop Base: #4 - /shop/
Basket: #5 - /basket/
Checkout: #6 - /checkout/
My Account: #7 - /my-account/

### Taxonomies ###

Product Types: external (external)
grouped (grouped)
simple (simple)
variable (variable)


### Theme ###

Name: Twenty Seventeen
Version: 1.1
Author URL: https://wordpress.org/
Child Theme: ? – If you're modifying WooCommerce on a parent theme you didn't build personally
then we recommend using a child theme. See: How to create a child theme

### Templates ###

Overrides: mysite/woocommerce/archive-product.php
mysite/woocommerce/cart\cart-empty.php
mysite/woocommerce/cart\cart-item-data.php
mysite/woocommerce/cart\cart-shipping.php
mysite/woocommerce/cart\cart-totals.php
mysite/woocommerce/cart\cart.php
mysite/woocommerce/cart\cross-sells.php
mysite/woocommerce/cart\mini-cart.php
mysite/woocommerce/cart\proceed-to-checkout-button.php
mysite/woocommerce/checkout\form-billing.php
mysite/woocommerce/checkout\form-checkout.php
mysite/woocommerce/checkout\form-coupon.php
mysite/woocommerce/checkout\form-login.php
mysite/woocommerce/checkout\form-pay.php
mysite/woocommerce/checkout\form-shipping.php
mysite/woocommerce/checkout\payment-method.php
mysite/woocommerce/checkout\payment.php
mysite/woocommerce/checkout\review-order.php
mysite/woocommerce/checkout\terms.php
mysite/woocommerce/checkout\thankyou.php
mysite/woocommerce/content-product.php
mysite/woocommerce/content-single-product.php
mysite/woocommerce/emails\customer-processing-order.php
mysite/woocommerce/emails\email-footer.php
mysite/woocommerce/emails\email-header.php
mysite/woocommerce/emails\email-order-details.php
mysite/woocommerce/emails\email-order-items.php
mysite/woocommerce/emails\email-styles.php
mysite/woocommerce/emails\plain\admin-cancelled-order.php
mysite/woocommerce/emails\plain\admin-failed-order.php
mysite/woocommerce/emails\plain\admin-new-order.php
mysite/woocommerce/emails\plain\customer-completed-order.php
mysite/woocommerce/emails\plain\customer-invoice.php
mysite/woocommerce/emails\plain\customer-new-account.php
mysite/woocommerce/emails\plain\customer-note.php
mysite/woocommerce/emails\plain\customer-processing-order.php
mysite/woocommerce/emails\plain\customer-refunded-order.php
mysite/woocommerce/emails\plain\customer-reset-password.php
mysite/woocommerce/emails\plain\email-addresses.php
mysite/woocommerce/emails\plain\email-customer-details.php
mysite/woocommerce/emails\plain\email-order-details.php
mysite/woocommerce/emails\plain\email-order-items.php
mysite/woocommerce/global\breadcrumb.php
mysite/woocommerce/global\form-login.php
mysite/woocommerce/global\quantity-input.php
mysite/woocommerce/global\sidebar.php
mysite/woocommerce/global\wrapper-end.php
mysite/woocommerce/global\wrapper-start.php
mysite/woocommerce/loop\loop-start.php
mysite/woocommerce/loop\price.php
mysite/woocommerce/loop\sale-flash.php
mysite/woocommerce/myaccount\dashboard.php
mysite/woocommerce/myaccount\form-edit-account.php
mysite/woocommerce/myaccount\form-edit-address.php
mysite/woocommerce/myaccount\form-login.php
mysite/woocommerce/myaccount\form-lost-password.php
mysite/woocommerce/myaccount\form-reset-password.php
mysite/woocommerce/myaccount\lost-password-confirmation.php
mysite/woocommerce/myaccount\my-account.php
mysite/woocommerce/myaccount\my-address.php
mysite/woocommerce/myaccount\my-orders.php
mysite/woocommerce/myaccount\navigation.php
mysite/woocommerce/myaccount\orders.php
mysite/woocommerce/myaccount\view-order.php
mysite/woocommerce/order\form-tracking.php
mysite/woocommerce/order\order-again.php
mysite/woocommerce/order\order-details-customer.php
mysite/woocommerce/order\order-details-item.php
mysite/woocommerce/order\order-details.php
mysite/woocommerce/order\tracking.php
mysite/woocommerce/single-product\add-to-cart\simple.php
mysite/woocommerce/single-product\meta.php
mysite/woocommerce/single-product\price.php
mysite/woocommerce/single-product\product-image.php
mysite/woocommerce/single-product\product-thumbnails.php
mysite/woocommerce/single-product\related.php
mysite/woocommerce/single-product\sale-flash.php
mysite/woocommerce/single-product\share.php
mysite/woocommerce/single-product\short-description.php
mysite/woocommerce/single-product\tabs\tabs.php
mysite/woocommerce/single-product\title.php
mysite/woocommerce/single-product\up-sells.php
mysite/woocommerce/single-product.php
mysite/woocommerce/taxonomy-product_cat.php
mysite/woocommerce/taxonomy-product_tag.php
@indextwo
Copy link
Author

I'm closing this, as it's not a WooCommerce issue but one with the core that WC just happens to trigger when it sets its constants. I have found a fix for the issue which currently requires editing a WP core file. Details can be found here:

https://core.trac.wordpress.org/ticket/39722#comment:1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant