Commit Graph

294 Commits

Author SHA1 Message Date
James Allan 82b68b4914 Use strict comparison to compare post dates
With PHP 8.0, non-strict comparisons between integers and strings containing
non-numeric characters are being tightened. This affects comparisons like:

0 < '0000-00-00 00:00:00'

PHP 8.0 that equates to true whereas prior to 8.0 it would be false.

More details of this change can be found at: https://wiki.php.net/rfc/string_to_number_comparison
2020-11-02 11:10:30 +10:00
Nestor Soriano 52eed70f04 Add a 'NumberUtil' class with a 'round' method.
There's a number of places in the WooCommerce codebase where the
built-in function 'round' is executed passing a non-numeric value
(not a number and not a string that can be parsed as a number),
for example round(''). In PHP 7 this yields a value of 0, but in
PHP 8 this throws an error.

This commit adds a 'NumberUtil' class with a static 'round' method,
this method checks if the passed value is numeric and if so it just
executes the built-in function, otherwise it returns 0. And all the
calls to 'round' in the codebase are replaced with 'NumberUtil::round'.
2020-10-01 11:08:51 +02:00
Nestor Soriano b1e81d02da Fix code style/sniffer errors in a few files. 2020-10-01 11:08:51 +02:00
Ramon 7610e1311e
Ensure that the return of get_the_terms is not a WP error 2020-08-21 14:07:26 -03:00
Christopher Allford 7340c9af44
Merge pull request #27171 from woocommerce/fix/25543
Added the parent's SKU to product searches for variations
2020-08-12 12:58:00 -07:00
Claudio Sanches d48f1d4e2e Fixed package tag usage 2020-08-05 13:36:24 -03:00
Christopher Allford 78bff3b2da Added the parent's SKU to product searches for variations
Since the parent's SKU is used when the variation does not have one, we should fall back when searching for consistency.
2020-07-29 16:53:36 -07:00
Vedanshu Jain b45373fe0c Revert "Revert "Introduce a `reserved stock` class and database table to prevent race conditions during checkout"" 2020-06-05 15:18:01 +05:30
Vedanshu Jain ee119e0a7e
Revert "Introduce a `reserved stock` class and database table to prevent race conditions during checkout" 2020-04-21 15:37:21 +05:30
Vedanshu Jain 3bf473517d
Merge pull request #25708 from woocommerce/update/reserve-stock-for-checkout
Introduce a `reserved stock` class and database table to prevent race conditions during checkout
2020-04-07 02:16:22 +05:30
Mike Jolley 51aca598b9 Only implement get_query_for_stock in data store 2020-04-03 15:55:14 +01:00
Claudio Sanches 2ebd86f2dc Revert "Revert "Add support for '_held_for_checkout` records to prevent race conditions."" 2020-04-03 15:55:13 +01:00
Gennady Kovshenin ca996a8941 Fix race condition in update_product_stock
Modify the increment and decrement SQL query in
WC_Product_Data_Store_CPT::update_product_stock to be atomic. This fixes
a race condition in concurrent order placement.
2020-03-31 16:01:26 +03:00
Christopher Allford 57734ca8ce Merge branch 'master' into refactor/add-jetpack-constants 2020-02-04 14:36:35 -08:00
Christopher Allford 1d1413b4ee Replaced direct access of many constants with the Constants library 2020-01-31 22:18:47 -08:00
Mike Jolley 314cc8eee6 Add columns to data store 2020-01-20 14:17:42 +00:00
Christopher Allford 874be93c14 Removed the lowercase conversion of product search terms
When searched in a case sensitive manner, the conversion to lowercase causes uppercase matches that would have been found to be lost. This change increases the tolerance of the OR search format while also removing this unintended side-effect.
2019-12-24 15:00:40 -08:00
Rodrigo Primo 487f96d844 Fix WordPress.DateTime.CurrentTimeTimestamp vilations
This commit fixes all violations of the WordPress.DateTime.CurrentTimeTimestamp sniff automatically using phpcbf.
2019-12-20 14:23:05 -03:00
Claudio Sanches 5fdb880831
Merge branch 'master' into feature/24956 2019-12-04 16:18:39 -03:00
Claudio Sanches 8033d5751e Changed wc_get_product_classname function name to wc_get_product_object 2019-12-04 16:15:16 -03:00
Claudio Sanches a12c25862b
Revert "Add support for '_held_for_checkout` records to prevent race conditions." 2019-12-04 16:03:05 -03:00
Claudio Sanches 0c486785ad
Merge pull request #25089 from woocommerce/fix/24009
Add support for '_held_for_checkout` records to prevent race conditions.
2019-12-03 17:47:22 -03:00
Claudio Sanches 988b72e461 Updated filter name to woocommerce_hold_stock_for_checkout
Also fixed coding standards
2019-12-03 16:38:17 -03:00
Peter Fabian 309c48ab0e Deprecated old cache function and replaced it with a new one. 2019-11-28 14:03:57 +01:00
vedanshujain e87024bb81 Add support for '_held_for_checkout` records to prevent race conditions.
When creating an order, if manage inventory is enabled then add a `_held_for_checkout` record with a expiry timestamp embedded. This is added in an atomic manner along with making a check whether we have current stock or not.
This record is removed when order status goes to either `processing` or `completed`.
2019-11-21 01:21:08 +05:30
Claudio Sanches ba0773d12e Apply wc_get_product_classname() in the current code base 2019-11-13 15:30:09 -03:00
Peter Fabian 3cbea2a902 Simplify 'any-check' to only include empty string. 2019-10-02 16:58:45 +02:00
Peter Fabian 4cfe22eef9 Made the attribute value comparison strict. 2019-10-02 16:05:44 +02:00
Peter Fabian 258e49a8de Allow attribute value 0 to work correctly with variations (especially add to cart and select variation). 2019-10-02 14:58:40 +02:00
Vedanshu Jain 7081c64115
Merge pull request #24294 from woocommerce/fix/24106
Make WC_Product_Query capable to sort products by "include" order
2019-10-02 18:02:06 +05:30
Rodrigo Primo b033c110db
Merge pull request #24229 from rynaldos/woocommerce_update_product_stock_query-changes
Use $new_stock in woocommerce_update_product_stock_query
2019-09-24 18:01:10 -03:00
Gerhard 5a1615a152 PHPCS fix 2019-08-12 20:26:34 +02:00
Claudio Sanches 66dbb44100 Ensure WC_Product_Data_Store_CPT::is_existing_sku() return boolean 2019-08-12 12:45:43 -03:00
Claudio Sanches d624bb57d5 Fixed coding standards 2019-08-01 15:56:02 -03:00
Claudio Sanches decea3d28c Allow sort products by "include" order 2019-08-01 15:55:32 -03:00
rspublishing bb2c929fba Use in woocommerce_update_product_stock_query 2019-07-25 09:31:37 +02:00
Claudio Sanches 60c18ce544
Merge pull request #23067 from woocommerce/pr/23043
Allow matching of "any" attributes in find_matching_product_variation…
2019-07-12 12:40:53 -03:00
Gerhard Potgieter 2734b190c1
Merge pull request #23881 from ionutcalara/master
Update find matching variation method inner query
2019-07-10 15:53:30 +02:00
Claudio Sanches 32996d2fdd Merge branch 'master' into pr/23043 2019-07-09 12:39:40 -03:00
Claudio Sanches 01f5a09d27
Merge pull request #23338 from woocommerce/update/23335
More useful actions in during CRUD save events
2019-07-08 18:56:14 -03:00
oscargare 2c8e45830a Added new action "woocommerce_product_read" (#23181)
* Added new action "woocommerce_read_product_data"

* Added new action woocommerce_product_read
2019-07-04 14:17:34 -03:00
Gerhard 3894d156e6 Explicitly check 0 value attributes when looking up variations. 2019-06-12 11:27:27 +02:00
Ionut Calara 26dfe11493 Update find matching variation method inner query
Fix variation query to prevent the order by being ignored in some mysql
and mariadb versions. The order by has been moved outside and a left
join was added.
2019-06-07 13:05:01 +03:00
Claudio Sanches b5da70c74a Introduced woocommerce_search_products_post_statuses filter 2019-05-28 21:05:26 -03:00
Peter Fabian 207042f7df Put back the manage stock check for lookup table. 2019-05-16 10:57:42 +02:00
Peter Fabian 9f0fb0b404 Foxed the use to correct stock quantity parameter. 2019-05-15 16:18:24 +02:00
Peter Fabian af7950910c Removed the transaction and locking code.
NOWAIT is not supported on MySQL server 5.5,

SELECT ... FOR UPDATE can leave lingering locks on InnoDB ("When InnoDB performs a complete rollback of a transaction, all locks set by the transaction are released. However, if just a single SQL statement is rolled back as a result of an error, some of the locks set by the statement may be preserved. This happens because InnoDB stores row locks in a format such that it cannot know afterward which lock was set by which statement.", via https://dev.mysql.com/doc/refman/5.5/en/innodb-deadlock-detection.html)
2019-05-15 15:09:16 +02:00
Peter Fabian 68a325249f Removed the extra parameter that didn't make sense.
Also get_data_for_lookup_table should not be checking db value of  _manage_stock as that can be in the process of being changed.
2019-05-15 14:20:27 +02:00
Peter Fabian 375880e06b Made the increase and decrease operations atomic, set is atomic as it's not fetch-and-update, just update. 2019-05-02 19:41:15 +02:00
Peter Fabian 44f1803c53 Tweaked update lookup table to add the possibility to ignore manage_stock value from the database.
E.g. if manage_stock property has been changed in the object/local copy of the product while updating it, but the product has not been saved to the db yet, the lookup table update would ignore stock quantity update.
2019-05-02 19:29:28 +02:00