ppy / osu-web

the browser-facing portion of osu!
https://osu.ppy.sh
GNU Affero General Public License v3.0
981 stars 385 forks source link

Adding json with images to a product's images_json throws an ErrorException #36

Closed comentarinformal closed 9 years ago

comentarinformal commented 9 years ago

A product in the store has a json-encoded list of image URLs added to its images_json column (tried with ["https:\/\/upload.wikimedia.org\/wikipedia\/en\/c\/c7\/GlennRhee.jpg"] and ["http:\/\/lorempixel.com\/500\/500\/?76327","http:\/\/lorempixel.com\/500\/500\/?34281","http:\/\/lorempixel.com\/500\/500\/?36519"] )

When loading the page of said product, a 'Read error!' will stop it from working.Full stack By the mentioned line, I guess it's a problem with getting the image size cached

peppy commented 9 years ago

here's a sample for you:

INSERT INTO osu_store.products (product_id, name, description, image, cost, weight, base_shipping, next_shipping, stock, max_quantity, created_at, deleted_at, updated_at, promoted, display_order, header_description, header_image, images_json, master_product_id, type_mappings_json, custom_class) VALUES (12, 'osu! t-shirt (triangles) / White S', 'Brand new osu! t-shirts have arrived! Featuring a tasty triangle design by osu! designer flyte, it''s a welcome addition to any avid osu! player’s wardrobe.

* 100% cotton
* Medium weight, pre-shrunk
* Sizes: S, M, L, XL

Size S M L XL Garment Length 66cm 70cm 74cm 78cm Body width 49cm 52cm 55cm 58cm Shoulder width 44cm 47cm 50cm 53cm Sleeve length 19cm 20cm 22cm 24cm


NOTE: These are Japanese sizes. Overseas customers are advised to check the size chart above!
', null, 16.00, 100, 5.00, 4.00, 42, 5, '2015-05-01 19:56:23', null, null, 1, 0, '# osu! t-shirt swag', 'https://puu.sh/hzgoB/1142f14e8b.jpg', '[
["https://puu.sh/hxpsp/d0b8704769.jpg", "https://puu.sh/hxpsp/d0b8704769.jpg"],
["https://puu.sh/hxptO/71121e05e7.jpg", "https://puu.sh/hxptO/71121e05e7.jpg"],
["https://puu.sh/hzfUF/1b9af4dbd1.jpg", "https://puu.sh/hzfUF/1b9af4dbd1.jpg"]
]', null, '{
  "12": { "size": "S", "colour": "White" },
  "13": { "size": "M", "colour": "White" },
  "14": { "size": "L", "colour": "White" },
  "15": { "size": "XL", "colour": "White" },
  "16": { "size": "S", "colour": "Charcoal" },
  "17": { "size": "M", "colour": "Charcoal" },
  "18": { "size": "L", "colour": "Charcoal" },
  "19": { "size": "XL", "colour": "Charcoal" }
}', null);
INSERT INTO osu_store.products (product_id, name, description, image, cost, weight, base_shipping, next_shipping, stock, max_quantity, created_at, deleted_at, updated_at, promoted, display_order, header_description, header_image, images_json, master_product_id, type_mappings_json, custom_class) VALUES (13, 'osu! t-shirt (triangles) / White M', '', null, 16.00, 100, 5.00, 4.00, 94, 5, '2015-05-01 19:56:23', null, null, 0, 0, '', '', '', 12, '', null);
INSERT INTO osu_store.products (product_id, name, description, image, cost, weight, base_shipping, next_shipping, stock, max_quantity, created_at, deleted_at, updated_at, promoted, display_order, header_description, header_image, images_json, master_product_id, type_mappings_json, custom_class) VALUES (14, 'osu! t-shirt (triangles) / White L', '', null, 16.00, 100, 5.00, 4.00, 92, 5, '2015-05-01 19:56:23', null, null, 0, 0, '', '', '', 12, '', null);
INSERT INTO osu_store.products (product_id, name, description, image, cost, weight, base_shipping, next_shipping, stock, max_quantity, created_at, deleted_at, updated_at, promoted, display_order, header_description, header_image, images_json, master_product_id, type_mappings_json, custom_class) VALUES (15, 'osu! t-shirt (triangles) / White XL', '', null, 16.00, 100, 5.00, 4.00, 41, 5, '2015-05-01 19:56:23', null, null, 0, 0, '', '', '', 12, '', null);
INSERT INTO osu_store.products (product_id, name, description, image, cost, weight, base_shipping, next_shipping, stock, max_quantity, created_at, deleted_at, updated_at, promoted, display_order, header_description, header_image, images_json, master_product_id, type_mappings_json, custom_class) VALUES (16, 'osu! t-shirt (triangles) / Charcoal S', '', null, 16.00, 100, 5.00, 4.00, 37, 5, '2015-05-01 19:56:23', null, null, 0, 0, '', '', '', 12, '', null);
INSERT INTO osu_store.products (product_id, name, description, image, cost, weight, base_shipping, next_shipping, stock, max_quantity, created_at, deleted_at, updated_at, promoted, display_order, header_description, header_image, images_json, master_product_id, type_mappings_json, custom_class) VALUES (17, 'osu! t-shirt (triangles) / Charcoal M', '', null, 16.00, 100, 5.00, 4.00, 99, 5, '2015-05-01 19:56:23', null, null, 0, 0, '', '', '', 12, '', null);
INSERT INTO osu_store.products (product_id, name, description, image, cost, weight, base_shipping, next_shipping, stock, max_quantity, created_at, deleted_at, updated_at, promoted, display_order, header_description, header_image, images_json, master_product_id, type_mappings_json, custom_class) VALUES (18, 'osu! t-shirt (triangles) / Charcoal L', '', null, 16.00, 100, 5.00, 4.00, 100, 5, '2015-05-01 19:56:23', null, null, 0, 0, '', '', '', 12, '', null);
INSERT INTO osu_store.products (product_id, name, description, image, cost, weight, base_shipping, next_shipping, stock, max_quantity, created_at, deleted_at, updated_at, promoted, display_order, header_description, header_image, images_json, master_product_id, type_mappings_json, custom_class) VALUES (19, 'osu! t-shirt (triangles) / Charcoal XL', '', null, 16.00, 100, 5.00, 4.00, 35, 5, '2015-05-01 19:56:23', null, null, 0, 0, '', '', '', 12, '', null);
comentarinformal commented 9 years ago

(....Well, to be fair to myself, json_encode escapes / and doesn't do the extra [] so I don't see my mistake as far-fetched) Thanks for that sample, it helps both with the images issue and illustrating how to use master_product_id and type_mappings.