Fixes #101 Large sites and SaleMaker vs Specials

<a href='#crh-start'></a><a href='#crh-data-%7B%22processed%22%3A%20%5B%22https%3A//github.com/zencart/zc-v1-series/pull/102%23issuecomment-49110288%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23issuecomment-49195614%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23issuecomment-49195810%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14975938%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14976094%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14976131%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14976289%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14977133%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14977137%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14977142%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14979117%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14979935%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14980861%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14981143%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14981211%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14981316%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14982147%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r15007004%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r15009180%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r15012558%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r15012559%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r15012560%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r15012562%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r15012563%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r15012565%22%2C%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r15012566%22%5D%2C%20%22comments%22%3A%20%7B%22General%20Comment%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23issuecomment-49110288%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222014-07-16T00%3A27%3A54Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/404472%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/drbyte%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%20%22%2C%20%22created_at%22%3A%20%222014-07-16T17%3A01%3A16Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/227354%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/zcwilt%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3Ashipit%3A%22%2C%20%22created_at%22%3A%20%222014-07-16T17%3A02%3A53Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/227354%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/zcwilt%22%7D%7D%5D%2C%20%22title%22%3A%20%22General%20Comment%22%7D%2C%20%22Pull%20b41046c2cc6f73ce47b04f4dea660d7e80b8a236%20admin/specials.php%20169%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14977137%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Another%20unnecessary%20%60else%60%5Cr%5Cn%60%60%60php%5Cr%5Cnif%20%28%21%24check_special-%3EEOF%20%26%26%20%21%24skip_specials%29%20%7B%5Cr%5Cn%20%20%20%24db-%3EExecute%28...%5Cr%5Cn%7D%5Cr%5Cn%60%60%60%22%2C%20%22created_at%22%3A%20%222014-07-16T01%3A01%3A05Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1590605%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/texdc%22%7D%7D%2C%20%7B%22body%22%3A%20%22Still%20need%20the%20%60continue%60%20though.%5Cr%5Cn%60%60%60php%5Cr%5Cnif%20%28%21%24chk_special-%3EEOF%20%26%26%20%21%24skip_specials%29%20%7B%5Cr%5Cn%20%20%24db-%3EExecute%28...%5Cr%5Cn%7D%20else%20%7B%5Cr%5Cn%20%20continue%3B%5Cr%5Cn%7D%5Cr%5Cn%60%60%60%22%2C%20%22created_at%22%3A%20%222014-07-16T02%3A44%3A49Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/404472%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/drbyte%22%7D%7D%2C%20%7B%22body%22%3A%20%22Unfortunately%2C%20neither%20of%20those%20ideas%20can%20work.%5Cr%5Cn%5Cr%5CnThe%20point%20of%20the%20%60continue%60%20is%20to%20break%20out%20of%20the%20loop%2C%20and%20not%20run%20the%20rest%20of%20the%20code.%20The%20%60else%60%20is%20to%20make%20the%20rest%20of%20the%20code%20%28do%20the%20insert%29%20execute.%5Cr%5Cn%22%2C%20%22created_at%22%3A%20%222014-07-16T03%3A32%3A21Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1992427%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/ajeh%22%7D%7D%2C%20%7B%22body%22%3A%20%22What%20are%20we%20trying%20to%20accomplish%3F%20%28It%27s%20not%20just%20about%20using%20%60else%60.%29%20%20For%20instance%2C%20if%20%60%24skip_specials%20%3D%3D%20true%60%20should%20we%20check%20for%20any%20specials%3F%20%20Perhaps%20I%20don%27t%20understand%20the%20purpose%20of%20%60%24skip_specials%60.%5Cr%5Cn%60%60%60php%5Cr%5Cnif%20%28%24skip_specials%29%20%7B%5Cr%5Cn%20%20continue%3B%5Cr%5Cn%7D%5Cr%5Cn%24products_id%20%3D%20zen_db_prepare_input%28%24new_specials_products_id%29%3B%5Cr%5Cn%24check_special_query%20%3D%20%5C%22SELECT%20products_id%20from%20%5C%22%20.%20TABLE_SPECIALS%20.%20%5C%22%20WHERE%20products_id%20%3D%20%27%5C%22%20.%20%24products_id%20.%20%5C%22%27%5C%22%3B%5Cr%5Cn%24check_special%20%3D%20%24db-%3EExecute%28%24check_special_query%29%3B%5Cr%5Cnif%20%28%21%24check_special-%3EEOF%29%20%7B%5Cr%5Cn%20%20%20%20%24db-%3EExecute%28...%5Cr%5Cn%7D%5Cr%5Cn%60%60%60%22%2C%20%22created_at%22%3A%20%222014-07-16T04%3A27%3A10Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1590605%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/texdc%22%7D%7D%2C%20%7B%22body%22%3A%20%22Remember%3A%20code%20review%20is%20not%20just%20syntax%20review.%20Gotta%20take%20the%20larger%20context%20into%20the%20picture.%5Cr%5CnThis%20larger%20block%20of%20code%20is%20for%20doing%20a%20mass-insert%20of%20records%20to%20put%20products%20on%20special%20based%20on%20being%20in%20a%20specified%20category.%5Cr%5Cn%5Cr%5CnThe%20couple%20lines%20under%20scrutiny%20here%20are%20doing%3A%5Cr%5Cn%60%60%60%5Cr%5Cngiven%20that%20%28there%27s%20an%20existing%20special%20in%20the%20db%29%20%7B%5Cr%5Cn%20%20if%20%28we%27re%20supposed%20to%20leave%20existing%20specials%20alone%2C%20instead%20of%20replacing%20them%20with%20a%20new%20special%29%20%7B%5Cr%5Cn%20%20%20%20%20then%20jump%20to%20the%20next%20record%20%28continue%29%5Cr%5Cn%20%20else%20%5Cr%5Cn%20%20%20%20%20since%20there%27s%20an%20existing%20record%2C%20we%20need%20to%20delete%20it%20%28so%20we%20can%20replace%20it%20with%20a%20new%20one%20below%29%5Cr%5Cn%20%20%7D%20%5Cr%5Cn%7D%5Cr%5Cn...%20and%20now%20that%20we%27ve%20cleaned%20up%20the%20existing%20record%2C%20we%20proceed%20with%20%5Cr%5Cnthe%20rest%20of%20the%20following%20steps%20to%20insert%20the%20requested%20new%20record.%5Cr%5Cn%60%60%60%22%2C%20%22created_at%22%3A%20%222014-07-16T04%3A46%3A26Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/404472%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/drbyte%22%7D%7D%2C%20%7B%22body%22%3A%20%22Right%2C%20what%20I%27m%20getting%20at%20is%20beyond%20syntax.%20%20If%20%60%24skip_specials%20%3D%3D%20true%60%2C%20there%27s%20nothing%20else%20that%20needs%20to%20be%20done.%20%20So%2C%20the%20entire%20loop%20can%20be%20skipped%3B%20%20no%20delete%2C%20no%20insert%2C%20just%20skip%20specials%20altogether.%22%2C%20%22created_at%22%3A%20%222014-07-16T04%3A51%3A01Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1590605%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/texdc%22%7D%7D%2C%20%7B%22body%22%3A%20%22But%20you%27re%20missing%20that%20this%20is%20based%20on%20skip-the-loop-only-if-we%27re-processing-for-a-specific-record.%22%2C%20%22created_at%22%3A%20%222014-07-16T04%3A57%3A03Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/404472%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/drbyte%22%7D%7D%2C%20%7B%22body%22%3A%20%22Ok%2C%20follow%20the%20logic%3A%20%20This%20is%20the%20%60specials.php%60%20file%20and%20we%27re%20inserting%20specials%20data%20for%20a%20category.%20%20We%20grab%20all%20the%20products%20for%20that%20category%20and%20if%20a%20product%20already%20has%20a%20special%2C%20update%20it%2C%20otherwise%20add%20one.%5Cr%5Cn%5Cr%5CnNow%2C%20we%20need%20to%20be%20able%20to%20toggle%20updating%20existing%20specials.%20%20So%2C%20the%20%60skip_specials%60%20terminology%20is%20misleading.%20%20I%20believe%20the%20intended%20functionality%20is%20to%20skip%20updating%20existing%20specials%2C%20not%20skip%20specials%20altogether.%20%20Therefore%2C%20I%20recommend%20changing%20%60skip_specials%60%20to%20%60skip_update%60.%5Cr%5Cn%5Cr%5CnThen%2C%20when%20we%20find%20an%20existing%20special%20and%20%60skip_update%20%3D%3D%20true%60%2C%20continue.%5Cr%5Cn%60%60%60php%5Cr%5Cnif%20%28%21%24check_specials-%3EEOF%20%26%26%20%24skip_update%29%20%7B%5Cr%5Cn%20%20continue%3B%5Cr%5Cn%7D%5Cr%5Cnif%20%28%21%24check_specials-%3EEOF%29%20%7B%5Cr%5Cn%20%20//%20remove%20existing%20special%5Cr%5Cn%20%20%24db-%3EExecute%28...%5Cr%5Cn%7D%5Cr%5Cn%60%60%60%22%2C%20%22created_at%22%3A%20%222014-07-16T05%3A45%3A40Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1590605%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/texdc%22%7D%7D%2C%20%7B%22body%22%3A%20%22And%20so%20it%27s%20back%20to%20the%20same%20original%20code.%20%5Cr%5CnSure%2C%20it%20avoids%20any%20hint%20of%20the%20arrow%20antipattern%2C%20and%20avoids%20using%20an%20evil%20%60else%60.%5Cr%5CnBut%20it%27s%20no%20more%20performant%20and%20no%20more%20readable%2C%20other%20than%20changing%20the%20variable%20name.%5Cr%5Cn...%20and%20seems%20redundant%20%28and%20at%20first%20glance%20even%20looks%20like%20an%20error%29%20to%20be%20running%20the%20same%20%60if%20%21EOF%60%20twice%20in%20a%20row.%22%2C%20%22created_at%22%3A%20%222014-07-16T16%3A03%3A30Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/404472%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/drbyte%22%7D%7D%2C%20%7B%22body%22%3A%20%22True%2C%20so%20at%20the%20very%20least%2C%20please%20change%20the%20variable%20name.%20%20There%20are%20a%20lot%20of%20opportunities%20for%20%5Brefactoring%5D%28https%3A//gist.github.com/texdc/598b71f42467e7a93c94%29%20this%20that%20can%20be%20done%20later.%20%20And%2C%20avoiding%20%60else%60%20at%20all%20costs%20is%20an%20excellent%20exercise%20in%20clarity%20by%20organizing%20code%20by%20very%20specific%20functionality.%22%2C%20%22created_at%22%3A%20%222014-07-16T16%3A15%3A26Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1590605%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/texdc%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%3Ca%20href%3D%27%23crh-update-none%27%3E%3C/a%3E%22%2C%20%22created_at%22%3A%20%222014-07-16T17%3A02%3A27Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/227354%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/zcwilt%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/specials.php%3AL75-314%22%7D%2C%20%22Pull%20e82ba64c9d2bb1e97c48fb064ce39a343109c194%20admin/specials.php%20120%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r15012559%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22%3A%2B1%3A%3Ca%20href%3D%27%23crh-update-none%27%3E%3C/a%3E%22%2C%20%22created_at%22%3A%20%222014-07-16T17%3A02%3A28Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/227354%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/zcwilt%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/specials.php%3AL75-314%22%7D%2C%20%22Pull%20c372c4e582835802349dcec1e63571d5c15d6d15%20admin/specials.php%20231%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r15012560%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22%3A%2B1%3A%3Ca%20href%3D%27%23crh-update-none%27%3E%3C/a%3E%22%2C%20%22created_at%22%3A%20%222014-07-16T17%3A02%3A28Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/227354%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/zcwilt%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/specials.php%3AL75-314%22%7D%2C%20%22Pull%20b41046c2cc6f73ce47b04f4dea660d7e80b8a236%20admin/specials.php%20256%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14977142%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Another%20unnecessary%20%60else%60%5Cr%5Cn%60%60%60php%5Cr%5Cn//%20do%20not%20show%20products%20when%20setting%20global%20additions%20or%20deletions%5Cr%5Cnif%20%28%24action%20%3D%3D%20%27%27%29%20%7B%5Cr%5Cn%60%60%60%22%2C%20%22created_at%22%3A%20%222014-07-16T01%3A01%3A12Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1590605%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/texdc%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%3Ca%20href%3D%27%23crh-update-none%27%3E%3C/a%3E%22%2C%20%22created_at%22%3A%20%222014-07-16T17%3A02%3A29Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/227354%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/zcwilt%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/specials.php%3AL543-554%22%7D%2C%20%22Pull%20c372c4e582835802349dcec1e63571d5c15d6d15%20admin/specials.php%20321%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14975938%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22%60%3Cb%3ETESTING%20ONLY%20WORKS%20ON%20MANUFACTURER%2010%3C/b%3E%60%20in%202%20places%3F%22%2C%20%22created_at%22%3A%20%222014-07-16T00%3A15%3A37Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/404472%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/drbyte%22%7D%7D%2C%20%7B%22body%22%3A%20%22Debug%20code%20now%20removed%22%2C%20%22created_at%22%3A%20%222014-07-16T00%3A21%3A48Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1992427%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/ajeh%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%3Ca%20href%3D%27%23crh-update-none%27%3E%3C/a%3E%22%2C%20%22created_at%22%3A%20%222014-07-16T17%3A02%3A29Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/227354%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/zcwilt%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/specials.php%3AL697-752%22%7D%2C%20%22Pull%20b41046c2cc6f73ce47b04f4dea660d7e80b8a236%20admin/specials.php%2028%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14977133%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22Please%20condense%20these.%20%20The%20%60else%60%20statements%20are%20%5Bnot%20necessary%5D%28http%3A//c2.com/cgi/wiki%3FElseConsideredSmelly%29.%20%20%28also%20other%20similar%20occurrences%20below%29%5Cr%5Cn%60%60%60php%5Cr%5Cn%24skip_specials%20%3D%20%28%24_POST%5B%27skip_specials%27%5D%20%3D%3D%20%27skip_specials_yes%27%29%3B%5Cr%5Cn//%20etc.%5Cr%5Cn%60%60%60%22%2C%20%22created_at%22%3A%20%222014-07-16T01%3A00%3A57Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1590605%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/texdc%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%3Ca%20href%3D%27%23crh-update-none%27%3E%3C/a%3E%22%2C%20%22created_at%22%3A%20%222014-07-16T17%3A02%3A29Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/227354%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/zcwilt%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/specials.php%3AL75-314%22%7D%2C%20%22Pull%20c372c4e582835802349dcec1e63571d5c15d6d15%20admin/specials.php%20162%22%3A%20%7B%22html_url%22%3A%20%22https%3A//github.com/zencart/zc-v1-series/pull/102%23discussion_r14976094%22%2C%20%22comments%22%3A%20%5B%7B%22body%22%3A%20%22ship_specials%20vs%20skip_specials%3F%20%20%28I%20know%2C%20it%27s%20just%20a%20comment%2C%20but%20...%29%22%2C%20%22created_at%22%3A%20%222014-07-16T00%3A20%3A27Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/404472%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/drbyte%22%7D%7D%2C%20%7B%22body%22%3A%20%22Typo%20fixed%20on%20all%204%20lines%20fixed%22%2C%20%22created_at%22%3A%20%222014-07-16T00%3A26%3A53Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/1992427%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/ajeh%22%7D%7D%2C%20%7B%22body%22%3A%20%22%3A%2B1%3A%3Ca%20href%3D%27%23crh-update-complete%27%3E%3C/a%3E%22%2C%20%22created_at%22%3A%20%222014-07-16T17%3A02%3A29Z%22%2C%20%22user%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/227354%3F%22%2C%20%22html_url%22%3A%20%22https%3A//github.com/zcwilt%22%7D%7D%5D%2C%20%22title%22%3A%20%22File%3A%20admin/specials.php%3AL75-314%22%7D%7D%2C%20%22approved%22%3A%20%7B%22https%3A//github.com/zcwilt%22%3A%20%7B%22avatar_url%22%3A%20%22https%3A//avatars.githubusercontent.com/u/227354%3F%22%7D%7D%7D'></a>
<a href='https://www.codereviewhub.com/'><img src='http://www.codereviewhub.com/site/github-bar.png' height=40></a>

<img src='http://www.codereviewhub.com/site/github-approved-avatar.png'><a href='https://github.com/zcwilt'><img src='https://avatars.githubusercontent.com/u/227354?size=34' width=34 height=34></a>

- [x] <a href='#crh-comment-Pull c372c4e582835802349dcec1e63571d5c15d6d15 admin/specials.php 321'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/zencart/zc-v1-series/pull/102#discussion_r14975938'>File: admin/specials.php:L697-752</a></b>
- <a href='https://github.com/drbyte'><img border=0 src='https://avatars.githubusercontent.com/u/404472?size=16' height=16 width=16'></a> `<b>TESTING ONLY WORKS ON MANUFACTURER 10</b>` in 2 places?
- <a href='https://github.com/ajeh'><img border=0 src='https://avatars.githubusercontent.com/u/1992427?size=16' height=16 width=16'></a> Debug code now removed
- [x] <a href='#crh-comment-Pull c372c4e582835802349dcec1e63571d5c15d6d15 admin/specials.php 162'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/zencart/zc-v1-series/pull/102#discussion_r14976094'>File: admin/specials.php:L75-314</a></b>
- <a href='https://github.com/drbyte'><img border=0 src='https://avatars.githubusercontent.com/u/404472?size=16' height=16 width=16'></a> ship_specials vs skip_specials?  (I know, it's just a comment, but ...)
- <a href='https://github.com/ajeh'><img border=0 src='https://avatars.githubusercontent.com/u/1992427?size=16' height=16 width=16'></a> Typo fixed on all 4 lines fixed
- [x] <a href='#crh-comment-Pull b41046c2cc6f73ce47b04f4dea660d7e80b8a236 admin/specials.php 28'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/zencart/zc-v1-series/pull/102#discussion_r14977133'>File: admin/specials.php:L75-314</a></b>
- <a href='https://github.com/texdc'><img border=0 src='https://avatars.githubusercontent.com/u/1590605?size=16' height=16 width=16'></a> Please condense these.  The `else` statements are [not necessary](http://c2.com/cgi/wiki?ElseConsideredSmelly).  (also other similar occurrences below)
```php
$skip_specials = ($_POST['skip_specials'] == 'skip_specials_yes');
// etc.
```
- [x] <a href='#crh-comment-Pull b41046c2cc6f73ce47b04f4dea660d7e80b8a236 admin/specials.php 169'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/zencart/zc-v1-series/pull/102#discussion_r14977137'>File: admin/specials.php:L75-314</a></b>
- <a href='https://github.com/texdc'><img border=0 src='https://avatars.githubusercontent.com/u/1590605?size=16' height=16 width=16'></a> Another unnecessary `else`
```php
if (!$check_special->EOF && !$skip_specials) {
$db->Execute(...
}
```
- <a href='https://github.com/drbyte'><img border=0 src='https://avatars.githubusercontent.com/u/404472?size=16' height=16 width=16'></a> Still need the `continue` though.
```php
if (!$chk_special->EOF && !$skip_specials) {
$db->Execute(...
} else {
continue;
}
```
- <a href='https://github.com/ajeh'><img border=0 src='https://avatars.githubusercontent.com/u/1992427?size=16' height=16 width=16'></a> Unfortunately, neither of those ideas can work.
The point of the `continue` is to break out of the loop, and not run the rest of the code. The `else` is to make the rest of the code (do the insert) execute.
- <a href='https://github.com/texdc'><img border=0 src='https://avatars.githubusercontent.com/u/1590605?size=16' height=16 width=16'></a> What are we trying to accomplish? (It's not just about using `else`.)  For instance, if `$skip_specials == true` should we check for any specials?  Perhaps I don't understand the purpose of `$skip_specials`.
```php
if ($skip_specials) {
continue;
}
$products_id = zen_db_prepare_input($new_specials_products_id);
$check_special_query = "SELECT products_id from " . TABLE_SPECIALS . " WHERE products_id = '" . $products_id . "'";
$check_special = $db->Execute($check_special_query);
if (!$check_special->EOF) {
$db->Execute(...
}
```
- <a href='https://github.com/drbyte'><img border=0 src='https://avatars.githubusercontent.com/u/404472?size=16' height=16 width=16'></a> Remember: code review is not just syntax review. Gotta take the larger context into the picture.
This larger block of code is for doing a mass-insert of records to put products on special based on being in a specified category.
The couple lines under scrutiny here are doing:
```
given that (there's an existing special in the db) {
if (we're supposed to leave existing specials alone, instead of replacing them with a new special) {
then jump to the next record (continue)
else
since there's an existing record, we need to delete it (so we can replace it with a new one below)
}
}
... and now that we've cleaned up the existing record, we proceed with
the rest of the following steps to insert the requested new record.
```
- <a href='https://github.com/texdc'><img border=0 src='https://avatars.githubusercontent.com/u/1590605?size=16' height=16 width=16'></a> Right, what I'm getting at is beyond syntax.  If `$skip_specials == true`, there's nothing else that needs to be done.  So, the entire loop can be skipped;  no delete, no insert, just skip specials altogether.
- <a href='https://github.com/drbyte'><img border=0 src='https://avatars.githubusercontent.com/u/404472?size=16' height=16 width=16'></a> But you're missing that this is based on skip-the-loop-only-if-we're-processing-for-a-specific-record.
- <a href='https://github.com/texdc'><img border=0 src='https://avatars.githubusercontent.com/u/1590605?size=16' height=16 width=16'></a> Ok, follow the logic:  This is the `specials.php` file and we're inserting specials data for a category.  We grab all the products for that category and if a product already has a special, update it, otherwise add one.
Now, we need to be able to toggle updating existing specials.  So, the `skip_specials` terminology is misleading.  I believe the intended functionality is to skip updating existing specials, not skip specials altogether.  Therefore, I recommend changing `skip_specials` to `skip_update`.
Then, when we find an existing special and `skip_update == true`, continue.
```php
if (!$check_specials->EOF && $skip_update) {
continue;
}
if (!$check_specials->EOF) {
// remove existing special
$db->Execute(...
}
```
- <a href='https://github.com/drbyte'><img border=0 src='https://avatars.githubusercontent.com/u/404472?size=16' height=16 width=16'></a> And so it's back to the same original code.
Sure, it avoids any hint of the arrow antipattern, and avoids using an evil `else`.
But it's no more performant and no more readable, other than changing the variable name.
... and seems redundant (and at first glance even looks like an error) to be running the same `if !EOF` twice in a row.
- <a href='https://github.com/texdc'><img border=0 src='https://avatars.githubusercontent.com/u/1590605?size=16' height=16 width=16'></a> True, so at the very least, please change the variable name.  There are a lot of opportunities for [refactoring](https://gist.github.com/texdc/598b71f42467e7a93c94) this that can be done later.  And, avoiding `else` at all costs is an excellent exercise in clarity by organizing code by very specific functionality.
- [x] <a href='#crh-comment-Pull b41046c2cc6f73ce47b04f4dea660d7e80b8a236 admin/specials.php 256'></a> <img src='http://www.codereviewhub.com/site/github-completed.png' height=16 width=60>&nbsp;<b><a href='https://github.com/zencart/zc-v1-series/pull/102#discussion_r14977142'>File: admin/specials.php:L543-554</a></b>
- <a href='https://github.com/texdc'><img border=0 src='https://avatars.githubusercontent.com/u/1590605?size=16' height=16 width=16'></a> Another unnecessary `else`
```php
// do not show products when setting global additions or deletions
if ($action == '') {
```


<a href='https://www.codereviewhub.com/zencart/zc-v1-series/pull/102?mark_as_completed=1'><img src='http://www.codereviewhub.com/site/github-mark-as-completed.png' height=26></a>&nbsp;<a href='https://www.codereviewhub.com/zencart/zc-v1-series/pull/102?approve=1'><img src='http://www.codereviewhub.com/site/github-approve.png' height=26></a>&nbsp;<a href='https://www.codereviewhub.com/zencart/zc-v1-series/pull/102?approve=0'><img src='http://www.codereviewhub.com/site/github-undo-approve.png' height=26></a>&nbsp;<a href='https://github.com/zencart/zc-v1-series/pull/102'><img src='http://www.codereviewhub.com/site/github-refresh.png' height=26></a>
<a href='#crh-end'></a>