Commit Graph

2 Commits

Author SHA1 Message Date
Nestor Soriano 436a3db6e4 Fix code standards errors 2021-02-16 09:23:50 +01:00
Nestor Soriano 00d6dc40f7 Fix wrong caching of taxonomy in terms and attributes controllers.
The WC_REST_Terms_Controller and WC_REST_Product_Attributes_V1_Controller
classes have a get_taxonomy method that gets the name of the taxonomy
to process from a taxonomy id passed in the request, but once the
taxonomy name has been obtained it's cached and sbsequently reused.
The problem is that these controller instances are reused if more than
one request is processed programmatically, and thus the taxonomy that
was cached once is always used even if the new request specifies a
different taxonomy id.

The fix consists of using a dictionary of taxonomy id - taxonomy name
instead of one single taxonomy for caching.

In the case of WC_REST_Terms_Controller there's a protected $taxonomy
property that needs to be kept for compatibility, it's now set to
the last taxonomy name that has been introduced in the dictionary.
2021-02-12 15:12:58 +01:00