From 97eb52771440d4ff8eb6f6d9e6c3fc9f2ac63b31 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 10 Mar 2012 19:38:50 +0000 Subject: [PATCH 01/16] named constraints --- ext/comment/main.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/comment/main.php b/ext/comment/main.php index 3d813f99..38218f55 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -83,8 +83,8 @@ class CommentList extends Extension { INDEX (image_id), INDEX (owner_ip), INDEX (posted), - FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, - FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT + CONSTRAINT foreign_comments_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, + CONSTRAINT foreign_comments_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT "); $config->set_int("ext_comments_version", 3); } From 3e8614967e79939f11d59703e24d078d52814ab7 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 00:17:09 +0000 Subject: [PATCH 02/16] admin tests --- contrib/admin/test.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/contrib/admin/test.php b/contrib/admin/test.php index 13718ae3..f9d15995 100644 --- a/contrib/admin/test.php +++ b/contrib/admin/test.php @@ -23,12 +23,10 @@ class AdminPageTest extends ShimmieWebTestCase { $this->get_page('admin'); $this->assert_title("Admin Tools"); - $this->set_field("action", "lowercase all tags"); - $this->click("Go"); + $this->click("All tags to lowercase"); $this->get_page("post/view/$image_id_1"); - // FIXME: doesn't work? - //$this->assert_title("Image $image_id_1: testcase$ts"); + $this->assert_title("Image $image_id_1: testcase$ts"); $this->delete_image($image_id_1); $this->log_out(); @@ -39,8 +37,7 @@ class AdminPageTest extends ShimmieWebTestCase { $this->log_in_as_admin(); $this->get_page('admin'); $this->assert_title("Admin Tools"); - $this->set_field("action", "recount tag use"); - $this->click("Go"); + $this->click("Recount tag use"); $this->log_out(); } @@ -48,8 +45,7 @@ class AdminPageTest extends ShimmieWebTestCase { $this->log_in_as_admin(); $this->get_page('admin'); $this->assert_title("Admin Tools"); - $this->set_field("action", "purge unused tags"); - $this->click("Go"); + $this->click("Purge unused tags"); $this->log_out(); } @@ -57,8 +53,7 @@ class AdminPageTest extends ShimmieWebTestCase { $this->log_in_as_admin(); $this->get_page('admin'); $this->assert_title("Admin Tools"); - $this->set_field("action", "database dump"); - $this->click("Go"); + $this->click("Download database contents"); $this->log_out(); } } From 2eceb19bcf90220b70ac16a219b130be58bebc1c Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 00:18:10 +0000 Subject: [PATCH 03/16] favicon moved --- contrib/browser_search/main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 contrib/browser_search/main.php diff --git a/contrib/browser_search/main.php b/contrib/browser_search/main.php old mode 100755 new mode 100644 index 78c3b878..266c7cd1 --- a/contrib/browser_search/main.php +++ b/contrib/browser_search/main.php @@ -34,7 +34,7 @@ class BrowserSearch extends Extension { $search_title = $config->get_string('title'); $search_form_url = make_link('post/list/{searchTerms}'); $suggenton_url = make_link('browser_search/')."{searchTerms}"; - $icon_b64 = base64_encode(file_get_contents("favicon.ico")); + $icon_b64 = base64_encode(file_get_contents("lib/static/favicon.ico")); // Now for the XML $xml = " From 1b30aea557d42b0c621717562f81cee26c7a7bd8 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 00:36:57 +0000 Subject: [PATCH 04/16] compressed coverage logs --- core/util.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/util.inc.php b/core/util.inc.php index fdf97a31..a01c52b2 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -1276,7 +1276,7 @@ function _end_coverage() { $n = 0; $t = time(); while(file_exists("$absolute_path/$t.$n.log")) $n++; - file_put_contents("$absolute_path/$t.$n.log", serialize(xdebug_get_code_coverage())); + file_put_contents("$absolute_path/$t.$n.log", gzdeflate(serialize(xdebug_get_code_coverage()))); } } ?> From 32387dd845dd2bbd67d64f87d88114957be8a7c3 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 00:37:08 +0000 Subject: [PATCH 05/16] saving cache data and profiling data to disk can happen after the client gets the page --- index.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.php b/index.php index 06663820..9895d7c7 100644 --- a/index.php +++ b/index.php @@ -100,6 +100,8 @@ try { $page->display(); $database->db->commit(); + // saving cache data and profiling data to disk can happen later + if(function_exists("fastcgi_finish_request")) fastcgi_finish_request(); _end_cache(); ctx_log_endok(); } From 778c3e8805673532d98439a99bf52217f92cbbc6 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 01:04:25 +0000 Subject: [PATCH 06/16] named constraints --- contrib/ipban/main.php | 5 +++++ contrib/pm/main.php | 4 ++-- contrib/tag_history/main.php | 4 ++-- contrib/wiki/main.php | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/contrib/ipban/main.php b/contrib/ipban/main.php index d0329034..be41efed 100644 --- a/contrib/ipban/main.php +++ b/contrib/ipban/main.php @@ -159,6 +159,11 @@ class IPBan extends Extension { $database->execute("ALTER TABLE bans CHANGE ip ip VARCHAR(15)"); $config->set_int("ext_ipban_version", 6); } + + if($config->get_int("ext_ipban_version") == 6) { + $database->Execute("ALTER TABLE bans ADD CONSTRAINT foreign_bans_banner_id FOREIGN KEY (banner_id) REFERENCES users(id) ON DELETE CASCADE"); + $config->set_int("ext_ipban_version", 7); + } } // }}} // deal with banned person {{{ diff --git a/contrib/pm/main.php b/contrib/pm/main.php index 563efdd2..f0bf9631 100644 --- a/contrib/pm/main.php +++ b/contrib/pm/main.php @@ -58,8 +58,8 @@ class PrivMsg extends Extension { message TEXT NOT NULL, is_read SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, INDEX (to_id), - FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE, - FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE + CONSTRAINT foreign_private_message_from_id FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE, + CONSTRAINT foreign_private_message_to_id FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE "); $config->set_int("pm_version", 1); log_info("pm", "extension installed"); diff --git a/contrib/tag_history/main.php b/contrib/tag_history/main.php index 0eb6e30d..80d3dbba 100644 --- a/contrib/tag_history/main.php +++ b/contrib/tag_history/main.php @@ -115,8 +115,8 @@ class Tag_History extends Extension { tags TEXT NOT NULL, date_set DATETIME NOT NULL, INDEX(image_id), - FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, - FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE + CONSTRAINT foreign_tag_histories_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, + CONSTRAINT foreign_tag_histories_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE "); $config->set_int("ext_tag_history_version", 3); } diff --git a/contrib/wiki/main.php b/contrib/wiki/main.php index 920588b9..df1193e0 100644 --- a/contrib/wiki/main.php +++ b/contrib/wiki/main.php @@ -69,7 +69,7 @@ class Wiki extends Extension { locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, body TEXT NOT NULL, UNIQUE (title, revision), - FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE + CONSTRAINT foreign_wiki_pages_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT "); $config->set_int("ext_wiki_version", 2); } From 7c3554a8ebf61113c4d213ecd638cd2b54c022d9 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 01:20:45 +0000 Subject: [PATCH 07/16] fk names --- contrib/bookmarks/main.php | 2 +- contrib/favorites/main.php | 6 +++--- contrib/numeric_score/main.php | 4 ++-- contrib/report_image/main.php | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/contrib/bookmarks/main.php b/contrib/bookmarks/main.php index 381ab7da..3464c059 100644 --- a/contrib/bookmarks/main.php +++ b/contrib/bookmarks/main.php @@ -43,7 +43,7 @@ class Bookmarks extends Extension { url TEXT NOT NULL, title TEXT NOT NULL, INDEX (owner_id), - FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE + CONSTRAINT foreign_bookmark_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE "); $config->set_int("ext_bookmarks_version", 1); } diff --git a/contrib/favorites/main.php b/contrib/favorites/main.php index a3d683e5..70426703 100644 --- a/contrib/favorites/main.php +++ b/contrib/favorites/main.php @@ -148,8 +148,8 @@ class Favorites extends Extension { created_at DATETIME NOT NULL, INDEX(image_id), UNIQUE(image_id, user_id), - FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, - FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE + CONSTRAINT foreign_user_favorites_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, + CONSTRAINT foreign_user_favorites_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE ) "); $config->set_int("ext_favorites_version", 1); @@ -162,7 +162,7 @@ class Favorites extends Extension { log_info("favorites", "Adding foreign keys to user favourites"); $database->Execute("ALTER TABLE user_favorites ADD CONSTRAINT foreign_user_favorites_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;"); - $database->Execute("ALTER TABLE user_favorites ADD CONSTRAINT user_favorites_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE;"); + $database->Execute("ALTER TABLE user_favorites ADD CONSTRAINT foreign_user_favorites_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE;"); $config->set_int("ext_favorites_version", 2); } } diff --git a/contrib/numeric_score/main.php b/contrib/numeric_score/main.php index 8baae0a1..ca9179b8 100644 --- a/contrib/numeric_score/main.php +++ b/contrib/numeric_score/main.php @@ -252,8 +252,8 @@ class NumericScore extends Extension { score INTEGER NOT NULL, UNIQUE(image_id, user_id), INDEX(image_id), - FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, - FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE + CONSTRAINT foreign_numeric_score_votes_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, + CONSTRAINT foreign_numeric_score_votes_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE "); $config->set_int("ext_numeric_score_version", 1); } diff --git a/contrib/report_image/main.php b/contrib/report_image/main.php index 71dd2de1..846e1fef 100644 --- a/contrib/report_image/main.php +++ b/contrib/report_image/main.php @@ -118,8 +118,8 @@ class ReportImage extends Extension { image_id INTEGER NOT NULL, reporter_id INTEGER NOT NULL, reason TEXT NOT NULL, - FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, - FOREIGN KEY (reporter_id) REFERENCES users(id) ON DELETE CASCADE + CONSTRAINT foreign_image_reports_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, + CONSTRAINT foreign_image_reports_reporter_id FOREIGN KEY (reporter_id) REFERENCES users(id) ON DELETE CASCADE "); $config->set_int("ext_report_image_version", 1); } From f9a92903187fc31d2a652ab6f352ce6814abe9b9 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 01:41:33 +0000 Subject: [PATCH 08/16] don't upgrade twice --- contrib/pm/main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/pm/main.php b/contrib/pm/main.php index f0bf9631..0b2180f3 100644 --- a/contrib/pm/main.php +++ b/contrib/pm/main.php @@ -61,7 +61,7 @@ class PrivMsg extends Extension { CONSTRAINT foreign_private_message_from_id FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE, CONSTRAINT foreign_private_message_to_id FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE "); - $config->set_int("pm_version", 1); + $config->set_int("pm_version", 2); log_info("pm", "extension installed"); } From 9e65732ea15fe05509a202e57e44ed289a0022a3 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 01:52:25 +0000 Subject: [PATCH 09/16] mysql ignores the FK names anyway, so all they were doing was bothering me ~_~ --- contrib/bookmarks/main.php | 2 +- contrib/favorites/main.php | 8 ++++---- contrib/ipban/main.php | 2 +- contrib/numeric_score/main.php | 4 ++-- contrib/pm/main.php | 8 ++++---- contrib/report_image/main.php | 4 ++-- contrib/tag_history/main.php | 4 ++-- contrib/wiki/main.php | 2 +- ext/comment/main.php | 8 ++++---- ext/upgrade/main.php | 2 +- install.php | 6 +++--- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/contrib/bookmarks/main.php b/contrib/bookmarks/main.php index 3464c059..381ab7da 100644 --- a/contrib/bookmarks/main.php +++ b/contrib/bookmarks/main.php @@ -43,7 +43,7 @@ class Bookmarks extends Extension { url TEXT NOT NULL, title TEXT NOT NULL, INDEX (owner_id), - CONSTRAINT foreign_bookmark_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE + FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE "); $config->set_int("ext_bookmarks_version", 1); } diff --git a/contrib/favorites/main.php b/contrib/favorites/main.php index 70426703..35d3c7f0 100644 --- a/contrib/favorites/main.php +++ b/contrib/favorites/main.php @@ -148,8 +148,8 @@ class Favorites extends Extension { created_at DATETIME NOT NULL, INDEX(image_id), UNIQUE(image_id, user_id), - CONSTRAINT foreign_user_favorites_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, - CONSTRAINT foreign_user_favorites_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE ) "); $config->set_int("ext_favorites_version", 1); @@ -161,8 +161,8 @@ class Favorites extends Extension { $database->Execute("DELETE FROM user_favorites WHERE image_id NOT IN (SELECT id FROM images)"); log_info("favorites", "Adding foreign keys to user favourites"); - $database->Execute("ALTER TABLE user_favorites ADD CONSTRAINT foreign_user_favorites_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;"); - $database->Execute("ALTER TABLE user_favorites ADD CONSTRAINT foreign_user_favorites_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE;"); + $database->Execute("ALTER TABLE user_favorites ADD FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;"); + $database->Execute("ALTER TABLE user_favorites ADD FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE;"); $config->set_int("ext_favorites_version", 2); } } diff --git a/contrib/ipban/main.php b/contrib/ipban/main.php index be41efed..4dd485ed 100644 --- a/contrib/ipban/main.php +++ b/contrib/ipban/main.php @@ -161,7 +161,7 @@ class IPBan extends Extension { } if($config->get_int("ext_ipban_version") == 6) { - $database->Execute("ALTER TABLE bans ADD CONSTRAINT foreign_bans_banner_id FOREIGN KEY (banner_id) REFERENCES users(id) ON DELETE CASCADE"); + $database->Execute("ALTER TABLE bans ADD FOREIGN KEY (banner_id) REFERENCES users(id) ON DELETE CASCADE"); $config->set_int("ext_ipban_version", 7); } } diff --git a/contrib/numeric_score/main.php b/contrib/numeric_score/main.php index ca9179b8..8baae0a1 100644 --- a/contrib/numeric_score/main.php +++ b/contrib/numeric_score/main.php @@ -252,8 +252,8 @@ class NumericScore extends Extension { score INTEGER NOT NULL, UNIQUE(image_id, user_id), INDEX(image_id), - CONSTRAINT foreign_numeric_score_votes_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, - CONSTRAINT foreign_numeric_score_votes_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE + FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE "); $config->set_int("ext_numeric_score_version", 1); } diff --git a/contrib/pm/main.php b/contrib/pm/main.php index 0b2180f3..29e4b941 100644 --- a/contrib/pm/main.php +++ b/contrib/pm/main.php @@ -58,8 +58,8 @@ class PrivMsg extends Extension { message TEXT NOT NULL, is_read SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, INDEX (to_id), - CONSTRAINT foreign_private_message_from_id FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE, - CONSTRAINT foreign_private_message_to_id FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE + FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE "); $config->set_int("pm_version", 2); log_info("pm", "extension installed"); @@ -70,8 +70,8 @@ class PrivMsg extends Extension { $database->Execute("delete from private_message where to_id not in (select id from users);"); $database->Execute("delete from private_message where from_id not in (select id from users);"); $database->Execute("ALTER TABLE private_message - ADD CONSTRAINT foreign_private_message_from_id FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE, - ADD CONSTRAINT foreign_private_message_to_id FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE;"); + ADD FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE, + ADD FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE;"); $config->set_int("pm_version", 2); log_info("pm", "extension installed"); } diff --git a/contrib/report_image/main.php b/contrib/report_image/main.php index 846e1fef..71dd2de1 100644 --- a/contrib/report_image/main.php +++ b/contrib/report_image/main.php @@ -118,8 +118,8 @@ class ReportImage extends Extension { image_id INTEGER NOT NULL, reporter_id INTEGER NOT NULL, reason TEXT NOT NULL, - CONSTRAINT foreign_image_reports_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, - CONSTRAINT foreign_image_reports_reporter_id FOREIGN KEY (reporter_id) REFERENCES users(id) ON DELETE CASCADE + FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, + FOREIGN KEY (reporter_id) REFERENCES users(id) ON DELETE CASCADE "); $config->set_int("ext_report_image_version", 1); } diff --git a/contrib/tag_history/main.php b/contrib/tag_history/main.php index 80d3dbba..0eb6e30d 100644 --- a/contrib/tag_history/main.php +++ b/contrib/tag_history/main.php @@ -115,8 +115,8 @@ class Tag_History extends Extension { tags TEXT NOT NULL, date_set DATETIME NOT NULL, INDEX(image_id), - CONSTRAINT foreign_tag_histories_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, - CONSTRAINT foreign_tag_histories_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE + FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE "); $config->set_int("ext_tag_history_version", 3); } diff --git a/contrib/wiki/main.php b/contrib/wiki/main.php index df1193e0..f289f04d 100644 --- a/contrib/wiki/main.php +++ b/contrib/wiki/main.php @@ -69,7 +69,7 @@ class Wiki extends Extension { locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, body TEXT NOT NULL, UNIQUE (title, revision), - CONSTRAINT foreign_wiki_pages_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT + FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT "); $config->set_int("ext_wiki_version", 2); } diff --git a/ext/comment/main.php b/ext/comment/main.php index 38218f55..93a867df 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -83,8 +83,8 @@ class CommentList extends Extension { INDEX (image_id), INDEX (owner_ip), INDEX (posted), - CONSTRAINT foreign_comments_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, - CONSTRAINT foreign_comments_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT + FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, + FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT "); $config->set_int("ext_comments_version", 3); } @@ -111,8 +111,8 @@ class CommentList extends Extension { if($config->get_int("ext_comments_version") == 2) { $config->set_int("ext_comments_version", 3); - $database->Execute("ALTER TABLE comments ADD CONSTRAINT foreign_comments_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE"); - $database->Execute("ALTER TABLE comments ADD CONSTRAINT foreign_comments_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT"); + $database->Execute("ALTER TABLE comments ADD FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE"); + $database->Execute("ALTER TABLE comments ADD FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT"); } // FIXME: add foreign keys, bump to v3 diff --git a/ext/upgrade/main.php b/ext/upgrade/main.php index a77494e9..5471d573 100644 --- a/ext/upgrade/main.php +++ b/ext/upgrade/main.php @@ -57,7 +57,7 @@ class Upgrade extends Extension { $config->set_int("db_version", 10); log_info("upgrade", "Adding foreign keys to images"); - $database->Execute("ALTER TABLE images ADD CONSTRAINT foreign_images_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT"); + $database->Execute("ALTER TABLE images ADD FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT"); log_info("upgrade", "Database at version 10"); $config->set_bool("in_upgrade", false); diff --git a/install.php b/install.php index 404517ed..142fa9f5 100644 --- a/install.php +++ b/install.php @@ -332,7 +332,7 @@ function create_tables() { // {{{ INDEX(owner_id), INDEX(width), INDEX(height), - CONSTRAINT foreign_images_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT + FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT "); $db->create_table("tags", " id SCORE_AIPK, @@ -345,8 +345,8 @@ function create_tables() { // {{{ INDEX(image_id), INDEX(tag_id), UNIQUE(image_id, tag_id), - CONSTRAINT foreign_image_tags_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, - CONSTRAINT foreign_image_tags_tag_id FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE + FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, + FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE "); $db->execute("INSERT INTO config(name, value) VALUES('db_version', 11)"); } From 9c1f544343258b5e1df335270e4dcd9e3493d7c6 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 02:03:28 +0000 Subject: [PATCH 10/16] forum FKs --- contrib/forum/main.php | 68 +++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/contrib/forum/main.php b/contrib/forum/main.php index 5593db9e..cee5d5c8 100644 --- a/contrib/forum/main.php +++ b/contrib/forum/main.php @@ -9,42 +9,48 @@ */ class Forum extends Extension { - public function onInitExt(InitExtEvent $event) { + public function onInitExt(InitExtEvent $event) { global $config, $database; // shortcut to latest - - if ($config->get_int("forum_version") < 1) - { - $database->create_table("forum_threads", " - id SCORE_AIPK, - sticky SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, - title VARCHAR(255) NOT NULL, - user_id INTEGER NOT NULL, - date DATETIME NOT NULL, - uptodate DATETIME NOT NULL, - INDEX (date) - "); - $database->create_table("forum_posts", - " id SCORE_AIPK, - thread_id INTEGER NOT NULL, - user_id INTEGER NOT NULL, - date DATETIME NOT NULL, - message TEXT, - INDEX (date), - FOREIGN KEY (thread_id) REFERENCES forum_threads (id) ON UPDATE CASCADE ON DELETE CASCADE - "); + if ($config->get_int("forum_version") < 1) { + $database->create_table("forum_threads", " + id SCORE_AIPK, + sticky SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, + title VARCHAR(255) NOT NULL, + user_id INTEGER NOT NULL, + date DATETIME NOT NULL, + uptodate DATETIME NOT NULL, + INDEX (date), + FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT + "); - $config->set_int("forum_version", 1); - $config->set_int("forumTitleSubString", 25); - $config->set_int("forumThreadsPerPage", 15); - $config->set_int("forumPostsPerPage", 15); - - $config->set_int("forumMaxCharsPerPost", 512); - - log_info("forum", "extension installed"); - } + $database->create_table("forum_posts", " + id SCORE_AIPK, + thread_id INTEGER NOT NULL, + user_id INTEGER NOT NULL, + date DATETIME NOT NULL, + message TEXT, + INDEX (date), + FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT, + FOREIGN KEY (thread_id) REFERENCES forum_threads (id) ON UPDATE CASCADE ON DELETE CASCADE + "); + + $config->set_int("forum_version", 2); + $config->set_int("forumTitleSubString", 25); + $config->set_int("forumThreadsPerPage", 15); + $config->set_int("forumPostsPerPage", 15); + + $config->set_int("forumMaxCharsPerPost", 512); + + log_info("forum", "extension installed"); + } + if ($config->get_int("forum_version") < 2) { + $database->execute("ALTER TABLE forum_threads ADD FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT"); + $database->execute("ALTER TABLE forum_posts ADD FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT"); + $config->set_int("forum_version", 2); + } } public function onSetupBuilding(SetupBuildingEvent $event) { From 9f4c5c1d938581b7cd1bf7ce4a4812aaf3b2cee1 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 02:09:33 +0000 Subject: [PATCH 11/16] artists FKs --- contrib/artists/main.php | 85 +++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/contrib/artists/main.php b/contrib/artists/main.php index 1717ec27..a4b3d6c3 100644 --- a/contrib/artists/main.php +++ b/contrib/artists/main.php @@ -54,47 +54,50 @@ class Artists extends Extension { public function try_install() { global $config, $database; - if ($config->get_int("ext_artists_version") < 1) - { - $database->create_table("artists", - "id SCORE_AIPK - , user_id INTEGER NOT NULL - , name VARCHAR(255) NOT NULL - , created DATETIME NOT NULL - , updated DATETIME NOT NULL - , notes TEXT - , INDEX(id) - "); - $database->create_table("artist_members", - "id SCORE_AIPK - , artist_id INTEGER NOT NULL - , user_id INTEGER NOT NULL - , name VARCHAR(255) NOT NULL - , created DATETIME NOT NULL - , updated DATETIME NOT NULL - , INDEX (id) - , FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE - "); - $database->create_table("artist_alias", - "id SCORE_AIPK - , artist_id INTEGER NOT NULL - , user_id INTEGER NOT NULL - , created DATETIME - , updated DATETIME - , alias VARCHAR(255) - , INDEX (id) - , FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE - "); - $database->create_table("artist_urls", - "id SCORE_AIPK - , artist_id INTEGER NOT NULL - , user_id INTEGER NOT NULL - , created DATETIME NOT NULL - , updated DATETIME NOT NULL - , url VARCHAR(1000) NOT NULL - , INDEX (id) - , FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE - "); + if ($config->get_int("ext_artists_version") < 1) { + $database->create_table("artists", " + id SCORE_AIPK, + user_id INTEGER NOT NULL, + name VARCHAR(255) NOT NULL, + created DATETIME NOT NULL, + updated DATETIME NOT NULL, + notes TEXT, + INDEX(id), + FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE + "); + $database->create_table("artist_members", " + id SCORE_AIPK, + artist_id INTEGER NOT NULL, + user_id INTEGER NOT NULL, + name VARCHAR(255) NOT NULL, + created DATETIME NOT NULL, + updated DATETIME NOT NULL, + INDEX (id), + FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE + "); + $database->create_table("artist_alias", " + id SCORE_AIPK, + artist_id INTEGER NOT NULL, + user_id INTEGER NOT NULL, + created DATETIME, + updated DATETIME, + alias VARCHAR(255), + INDEX (id), + FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE + "); + $database->create_table("artist_urls", " + id SCORE_AIPK, + artist_id INTEGER NOT NULL, + user_id INTEGER NOT NULL, + created DATETIME NOT NULL, + updated DATETIME NOT NULL, + url VARCHAR(1000) NOT NULL, + INDEX (id), + FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE + "); $database->execute("ALTER TABLE images ADD COLUMN author VARCHAR(255) NULL", array()); $config->set_int("artistsPerPage", 20); From 8b69e056b405b709a6de883c5fb9cbbdbdef3199 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 02:13:18 +0000 Subject: [PATCH 12/16] notes FKs --- contrib/notes/main.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/notes/main.php b/contrib/notes/main.php index aa960c1d..5bc09ef6 100644 --- a/contrib/notes/main.php +++ b/contrib/notes/main.php @@ -27,6 +27,7 @@ class Notes extends Extension { width INTEGER NOT NULL, note TEXT NOT NULL, INDEX (image_id), + FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE "); @@ -36,6 +37,7 @@ class Notes extends Extension { user_id INTEGER NOT NULL, date DATETIME NOT NULL, INDEX (image_id), + FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE "); @@ -54,6 +56,7 @@ class Notes extends Extension { width INTEGER NOT NULL, note TEXT NOT NULL, INDEX (image_id), + FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE "); From 390759cd0bef34114d2650ea02e59a1bdd802af3 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 02:13:25 +0000 Subject: [PATCH 13/16] pools FKs --- contrib/pools/main.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/contrib/pools/main.php b/contrib/pools/main.php index 585fd3ad..05080042 100644 --- a/contrib/pools/main.php +++ b/contrib/pools/main.php @@ -35,12 +35,15 @@ class Pools extends Extension { description TEXT, date DATETIME NOT NULL, posts INTEGER NOT NULL DEFAULT 0, - INDEX (id) + INDEX (id), + FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE "); $database->create_table("pool_images", " pool_id INTEGER NOT NULL, image_id INTEGER NOT NULL, - image_order INTEGER NOT NULL DEFAULT 0 + image_order INTEGER NOT NULL DEFAULT 0, + FOREIGN KEY (pool_id) REFERENCES pools(id) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE "); $database->create_table("pool_history", " id SCORE_AIPK, @@ -50,7 +53,9 @@ class Pools extends Extension { images TEXT, count INTEGER NOT NULL DEFAULT 0, date DATETIME NOT NULL, - INDEX (id) + INDEX (id), + FOREIGN KEY (pool_id) REFERENCES pools(id) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE "); // Set the defaults for the pools extension From 733ffe4ca903da8d4d26f5c5bb0a83a267a8dad2 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 02:17:16 +0000 Subject: [PATCH 14/16] use the right pool FK --- contrib/pools/main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/pools/main.php b/contrib/pools/main.php index 05080042..b161e8bb 100644 --- a/contrib/pools/main.php +++ b/contrib/pools/main.php @@ -43,7 +43,7 @@ class Pools extends Extension { image_id INTEGER NOT NULL, image_order INTEGER NOT NULL DEFAULT 0, FOREIGN KEY (pool_id) REFERENCES pools(id) ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE + FOREIGN KEY (image_id) REFERENCES images(id) ON UPDATE CASCADE ON DELETE CASCADE "); $database->create_table("pool_history", " id SCORE_AIPK, From f0a05164d1941d1d632357e9efa7371ea2f8667c Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 02:27:16 +0000 Subject: [PATCH 15/16] 'Warning:' is picked up by simpletest --- contrib/shimmie_api/main.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/shimmie_api/main.php b/contrib/shimmie_api/main.php index decacbfa..e7ddc59e 100644 --- a/contrib/shimmie_api/main.php +++ b/contrib/shimmie_api/main.php @@ -4,8 +4,8 @@ * Author: Shish * Description: A JSON interface to shimmie data [WARNING] * Documentation: - * Admin Warning: this exposes private data, eg IP addresses - *

Developer Warning: the API is unstable; notably, private data may get hidden + * Admin Warning - this exposes private data, eg IP addresses + *

Developer Warning - the API is unstable; notably, private data may get hidden *

Usage: *

get_tags - List of all tags. (May contain unused tags) *

    tags - Optional - Search for more specific tags (Searchs TAG*)
From cf907237c6cf73b4919d22fec3e1ddf92274f8d6 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 04:33:24 +0000 Subject: [PATCH 16/16] with 5.2.1, we have an accurate, peak memory use --- README.txt | 2 +- core/util.inc.php | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/README.txt b/README.txt index 84f62cbc..26e403b2 100644 --- a/README.txt +++ b/README.txt @@ -26,7 +26,7 @@ because the feature doesn't work yet :P Requirements ~~~~~~~~~~~~ MySQL 5.1+ (with experimental support for PostgreSQL 8+ and SQLite 3) -PHP 5.2+ +PHP 5.2.6+ GD or ImageMagick diff --git a/core/util.inc.php b/core/util.inc.php index a01c52b2..e9a8583d 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -907,12 +907,7 @@ $_load_start = microtime(true); function get_debug_info() { global $config, $_event_count, $database, $_execs, $_load_start; - if(function_exists('memory_get_usage')) { - $i_mem = sprintf("%5.2f", ((memory_get_usage()+512)/1024)/1024); - } - else { - $i_mem = "???"; - } + $i_mem = sprintf("%5.2f", ((memory_get_peak_usage(true)+512)/1024)/1024); if($config->get_string("commit_hash", "unknown") == "unknown"){ $commit = "";