From c260f707fda8fc537c87900999689f6c144a59d1 Mon Sep 17 00:00:00 2001 From: Shish Date: Thu, 8 Mar 2012 04:07:46 +0000 Subject: [PATCH 01/25] only retroactively create history when the image has old tags and no log - if it is a new image (no old tags) then don't double-log it --- contrib/tag_history/main.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/tag_history/main.php b/contrib/tag_history/main.php index 02f42948..6b38c3c5 100644 --- a/contrib/tag_history/main.php +++ b/contrib/tag_history/main.php @@ -344,13 +344,13 @@ class Tag_History extends Extension { // if the image has no history, make one with the old tags $entries = $database->get_one("SELECT COUNT(*) FROM tag_histories WHERE image_id = ?", array($image->id)); - if($entries == 0){ - /* We have no tag history for this image, so we will use the new_tags as the starting tags for this image. */ + if($entries == 0 && !empty($old_tags)) { + /* We have no tag history for this image, so we will use the old_tags as the starting tags for this image. */ /* these two queries could probably be combined */ $database->execute(" INSERT INTO tag_histories(image_id, tags, user_id, user_ip, date_set) VALUES (?, ?, ?, ?, now())", - array($image->id, $new_tags, 1, '127.0.0.1')); // TODO: Pick appropriate user id + array($image->id, $old_tags, 1, '127.0.0.1')); // TODO: Pick appropriate user id $entries++; } From c7e2ef74f8b2e6cb3614c8a626ab68f05bec9c66 Mon Sep 17 00:00:00 2001 From: Shish Date: Thu, 8 Mar 2012 04:35:52 +0000 Subject: [PATCH 02/25] if username or password are blank, exit early (saves logging the failed attempt) --- ext/user/main.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ext/user/main.php b/ext/user/main.php index 27e59e01..c926184b 100644 --- a/ext/user/main.php +++ b/ext/user/main.php @@ -287,6 +287,11 @@ class UserPage extends Extension { $pass = $_POST['pass']; $hash = md5(strtolower($name) . $pass); + if(empty($name) || empty($pass)) { + $this->theme->display_error(400, "Error", "Username or password left blank"); + return; + } + $duser = User::by_name_and_hash($name, $hash); if(!is_null($duser)) { $user = $duser; From 97eb52771440d4ff8eb6f6d9e6c3fc9f2ac63b31 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 10 Mar 2012 19:38:50 +0000 Subject: [PATCH 03/25] 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 04/25] 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 05/25] 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 06/25] 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 07/25] 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 08/25] 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 09/25] 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 10/25] 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 11/25] 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 12/25] 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 13/25] 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 14/25] 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 15/25] 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 16/25] 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 17/25] '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 18/25] 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 = ""; From 358f191be2da4d3d03e7da4d41cfbaa4927d5a03 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 04:50:44 +0000 Subject: [PATCH 19/25] view/edit for author --- contrib/artists/theme.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/contrib/artists/theme.php b/contrib/artists/theme.php index 17fc9496..1bb9e2ed 100644 --- a/contrib/artists/theme.php +++ b/contrib/artists/theme.php @@ -3,7 +3,15 @@ class ArtistsTheme extends Themelet { public function get_author_editor_html(/*string*/ $author) { $h_author = html_escape($author); - return "Author"; + return " + + Author + + $h_author + + + + "; } public function display_artists(){ @@ -11,7 +19,7 @@ class ArtistsTheme extends Themelet { $page->set_title("Artists"); $page->set_heading("Artists"); - $page->add_block(new Block("Artists", $html, "main", 10)); + $page->add_block(new Block("Artists", $html, "main", 10)); //$this->display_paginator($page, "artist/list", null, $pageNumber, $totalPages); } From 47bb844acc5177be8c7deda1e26280b2619e289b Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 14:02:00 +0000 Subject: [PATCH 20/25] admin tweaks --- contrib/admin/main.php | 10 ++++++++-- contrib/admin/test.php | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/contrib/admin/main.php b/contrib/admin/main.php index 5fe7cc41..a7a45e2d 100644 --- a/contrib/admin/main.php +++ b/contrib/admin/main.php @@ -139,7 +139,7 @@ class AdminPage extends Extension { return true; } - private function dump_database() { + private function database_dump() { global $page; $matches = array(); @@ -150,11 +150,17 @@ class AdminPage extends Extension { $hostname = $matches['host']; $database = $matches['dbname']; - // TODO: Support more than just MySQL.. switch($software) { case 'mysql': $cmd = "mysqldump -h$hostname -u$username -p$password $database"; break; + case 'pgsql': + putenv("PGPASSWORD=$password"); + $cmd = "pg_dump -h $hostname -U $username $database"; + break; + case 'sqlite': + $cmd = "sqlite3 $database .dump"; + break; } $page->set_mode("data"); diff --git a/contrib/admin/test.php b/contrib/admin/test.php index f9d15995..caa75ad8 100644 --- a/contrib/admin/test.php +++ b/contrib/admin/test.php @@ -54,6 +54,27 @@ class AdminPageTest extends ShimmieWebTestCase { $this->get_page('admin'); $this->assert_title("Admin Tools"); $this->click("Download database contents"); + $this->assert_response(200); + $this->log_out(); + } + + function testDBQ() { + $this->log_in_as_user(); + $image_id_1 = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "test"); + $image_id_2 = $this->post_image("ext/simpletest/data/bedroom_workshop.jpg", "test2"); + $image_id_3 = $this->post_image("ext/simpletest/data/favicon.png", "test"); + + $this->get_page("post/list/test/1"); + $this->click("Delete All These Images"); + + $this->get_page("post/view/$image_id_1"); + $this->assert_response(404); + $this->get_page("post/view/$image_id_2"); + $this->assert_response(200); + $this->get_page("post/view/$image_id_3"); + $this->assert_response(404); + + $this->delete_image($image_id_2); $this->log_out(); } } From fb4870e4da36e29f1570df97f8653f6aee3898f8 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 14:28:18 +0000 Subject: [PATCH 21/25] stub artists test --- contrib/artists/test.php | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 contrib/artists/test.php diff --git a/contrib/artists/test.php b/contrib/artists/test.php new file mode 100644 index 00000000..7f794343 --- /dev/null +++ b/contrib/artists/test.php @@ -0,0 +1,8 @@ +get_page("post/list/author=bob/1"); + } +} +?> From 752597385e74251660b69a3cbc68530944209ec4 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 14:28:29 +0000 Subject: [PATCH 22/25] start of danbooru API tests --- contrib/danbooru_api/test.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 contrib/danbooru_api/test.php diff --git a/contrib/danbooru_api/test.php b/contrib/danbooru_api/test.php new file mode 100644 index 00000000..bbc4c2d6 --- /dev/null +++ b/contrib/danbooru_api/test.php @@ -0,0 +1,26 @@ +log_in_as_admin(); + + $image_id = $this->post_image("ext/simpletest/data/bedroom_workshop.jpg", "data"); + + $this->get_page("post/list/md5:17fc89f372ed3636e28bd25cc7f3bac1/1"); + $this->assert_title(new PatternExpectation("/^Image \d+: data/")); + $this->click("Delete"); + + $this->get_page("api/danbooru/find_posts"); + $this->get_page("api/danbooru/find_posts?id=$image_id"); + $this->get_page("api/danbooru/find_posts?md5=17fc89f372ed3636e28bd25cc7f3bac1"); + + $this->get_page("api/danbooru/find_tags"); + $this->get_page("api/danbooru/find_tags?id=1"); + $this->get_page("api/danbooru/find_tags?name=data"); + + $this->get_page("api/danbooru/post/show/$image_id"); + $this->assert_response(302); + + $this->log_out(); + } +} +?> From e10cc4fa99d70dd6294c4186a61a2184c66c0917 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 14:33:49 +0000 Subject: [PATCH 23/25] test searches --- contrib/log_db/test.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/log_db/test.php b/contrib/log_db/test.php index a111c2e1..f2e9b8dd 100644 --- a/contrib/log_db/test.php +++ b/contrib/log_db/test.php @@ -3,6 +3,10 @@ class LogDatabaseTest extends SCoreWebTestCase { function testLog() { $this->log_in_as_admin(); $this->get_page("log/view"); + $this->get_page("log/view?module=core-image"); + $this->get_page("log/view?time=2012-03-01"); + $this->get_page("log/view?user=demo"); + $this->get_page("log/view?priority=10"); $this->log_out(); } } From f04704e3e95ecd547d1aceef7816e4ba37f196b1 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 14:37:04 +0000 Subject: [PATCH 24/25] 'tags' might not exist yet, use get_tag_array() --- contrib/not_a_tag/main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/not_a_tag/main.php b/contrib/not_a_tag/main.php index ba18c04b..d2696da3 100644 --- a/contrib/not_a_tag/main.php +++ b/contrib/not_a_tag/main.php @@ -10,7 +10,7 @@ class NotATag extends Extension { public function get_priority() {return 30;} // before ImageUploadEvent and tag_history public function onImageAddition(ImageAdditionEvent $event) { - $this->scan($event->image->tags); + $this->scan($event->image->get_tag_array()); } public function onTagSet(TagSetEvent $event) { From 652984adc122e17f50fd7dd35e03431d631eebfb Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 11 Mar 2012 14:54:14 +0000 Subject: [PATCH 25/25] trim comma from tags as well as whitespace --- core/imageboard.pack.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index f7e27121..bf1c7662 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -967,10 +967,9 @@ class Tag { // do nothing //} - $tags = array_map("trim", $tags); - $tag_array = array(); foreach($tags as $tag) { + $tag = trim($tag, ", \t\n\r\0\x0B"); if(is_string($tag) && !empty($tag)) { $tag_array[] = $tag; }