When a simple product with downloads gets converted into a variable
product all the existing download permissions for past orders become
invalid. This commit adds an extra verification procedure to the
product save code:
- Get all the existing download permissions for the product and all
the children (variations)
- For each download permission for the parent product, if there's a
variation that offers the same file for download (same file URL)
AND an equivalent download permission doesn't exist (equivalent means
same file URL, same order id and same user id), then create it.
Additionally, a new WC_Customer_Download_Data_Store::create_from_data
method is added.
The latest version of WPCS that was added to WC last week, changed the name of some sniffs. This commit updates the name of one of those sniffs from WordPress.WP.PreparedSQL.NotPrepared to WordPress.DB.PreparedSQL.NotPrepared.
This commit fixes a bug in WC_Customer_Download_Data_Store::get_downloads() that made impossible to change the order in which the query returned the results. This method accepts the arguments `order_by` and `order` but it was ignoring them and always using the default values ('permission_id' and 'ASC' respectively).
One of the assertions of the WC_Customer_Download_Data_Store::get_downloads() test method was modified to make sure the code now works.
This bug was introduced by commit a443419.
This commit improves WC_Customer_Download_Data_Store::get_downloads() performance by changing the way the SQL query is built. Before this change, this method would get all table fields even when just the permission_id field is returned. Now the method will get from the database only the fields that will be returned. The fields retrieved from the database can be controlled using the parameter `$args['return']`:
- 'objects' (default): all fields are retrieved from the database and an array of WC_Customer_Download objects is returned.
- 'ids': gets and return only permision_ids
- comma separated list of fields (new option added by this commit): gets and return only the required fields. Examples: 'user_email,download_id,order_id' or 'order_id,download_count'.
* fix user id for download file
* fix access expires for download when not set
‚NULL‘ trigger a 0000-00-00 00:00:00
as date in the database column. In order to write a real Null to the
database, the quotations must be deleted