From fd5dcc9cfa321e6077eca9c911dd4cb3ec8bb7cf Mon Sep 17 00:00:00 2001 From: Bertrand Gorge Date: Thu, 24 Oct 2019 17:41:12 +0200 Subject: [PATCH 1/6] Delete the avatar files as well as the user meta when deleting a user Fixes issue #779 --- qa-include/db/users.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qa-include/db/users.php b/qa-include/db/users.php index a8ddcd8fe..f2300a4af 100644 --- a/qa-include/db/users.php +++ b/qa-include/db/users.php @@ -83,6 +83,14 @@ function qa_db_user_delete($userid) { qa_db_query_sub('UPDATE ^posts SET lastuserid=NULL WHERE lastuserid=$', $userid); qa_db_query_sub('DELETE FROM ^userpoints WHERE userid=$', $userid); + + // Delete blobs including the files: + require_once QA_INCLUDE_DIR . 'app/blobs.php'; + + $blobIds = qa_db_read_all_values(qa_db_query_sub('SELECT avatarblobid FROM ^users WHERE userid=$', $userid)); + foreach ($blobIds as $blobid) + qa_delete_blob($blobid); + qa_db_query_sub('DELETE FROM ^blobs WHERE blobid=(SELECT avatarblobid FROM ^users WHERE userid=$)', $userid); qa_db_query_sub('DELETE FROM ^users WHERE userid=$', $userid); @@ -92,6 +100,7 @@ function qa_db_user_delete($userid) qa_db_query_sub('UPDATE ^posts SET userid=NULL WHERE userid=$', $userid); qa_db_query_sub('DELETE FROM ^userlogins WHERE userid=$', $userid); qa_db_query_sub('DELETE FROM ^userprofile WHERE userid=$', $userid); + qa_db_query_sub('DELETE FROM ^usermetas WHERE userid=$', $userid); qa_db_query_sub('DELETE FROM ^userfavorites WHERE userid=$', $userid); qa_db_query_sub('DELETE FROM ^userevents WHERE userid=$', $userid); qa_db_query_sub('DELETE FROM ^uservotes WHERE userid=$', $userid); From 692335d011e39c1edfdb84f7c1de60b474fe298d Mon Sep 17 00:00:00 2001 From: Bertrand Gorge Date: Thu, 6 Feb 2020 13:39:19 +0100 Subject: [PATCH 2/6] Fixed the discovery of plugins and themes when using Docker on Windows with symbolic links Symbolic links are simulated on docker, and apparently php has a hard time traversing them when using glob. @see https://github.com/drud/ddev/issues/1283 --- qa-include/Q2A/Plugin/PluginManager.php | 7 ++++++- qa-include/app/admin.php | 6 +++++- qa-plugin/QA-Google-Analytics-Plugin | 5 +++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 qa-plugin/QA-Google-Analytics-Plugin diff --git a/qa-include/Q2A/Plugin/PluginManager.php b/qa-include/Q2A/Plugin/PluginManager.php index ebf7ce21b..dd6f2a1e0 100644 --- a/qa-include/Q2A/Plugin/PluginManager.php +++ b/qa-include/Q2A/Plugin/PluginManager.php @@ -136,7 +136,12 @@ public function getFilesystemPlugins($fullPath = false) { $result = array(); - $fileSystemPluginFiles = glob(QA_PLUGIN_DIR . '*/qa-plugin.php'); + $plugins = glob(QA_PLUGIN_DIR . '*'); + foreach ($plugins as $aPlugin) + { + if (file_exists($aPlugin . '/qa-plugin.php')) + $fileSystemPluginFiles[] = $aPlugin . '/qa-plugin.php' . "\n"; + } foreach ($fileSystemPluginFiles as $pluginFile) { $directory = dirname($pluginFile) . '/'; diff --git a/qa-include/app/admin.php b/qa-include/app/admin.php index bd998edcb..3757a21a3 100644 --- a/qa-include/app/admin.php +++ b/qa-include/app/admin.php @@ -148,7 +148,11 @@ function qa_admin_theme_options() if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } $metadataUtil = new Q2A_Util_Metadata(); - foreach (glob(QA_THEME_DIR . '*', GLOB_ONLYDIR) as $directory) { + foreach (glob(QA_THEME_DIR . '*') as $directory) { + + if (!file_exists($directory . '/qa-theme.php')) + continue; + $theme = basename($directory); $metadata = $metadataUtil->fetchFromAddonPath($directory); if (empty($metadata)) { diff --git a/qa-plugin/QA-Google-Analytics-Plugin b/qa-plugin/QA-Google-Analytics-Plugin new file mode 100644 index 000000000..b1b3ba787 --- /dev/null +++ b/qa-plugin/QA-Google-Analytics-Plugin @@ -0,0 +1,5 @@ +XSym +0050 +afe5f18ead938ea5d08e3d1a860e7f9d +/var/www/q2a-thirdparty/QA-Google-Analytics-Plugin + \ No newline at end of file From 99650a2d417595872a7431c7772099b9433f22fa Mon Sep 17 00:00:00 2001 From: Bertrand Gorge Date: Mon, 17 Feb 2020 14:47:59 +0100 Subject: [PATCH 3/6] When checking for blob's existance, also checks for the file --- .gitignore | 3 ++- qa-include/app/blobs.php | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 7aa315be2..3d2dbd28c 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ ehthumbs.db Thumbs.db .idea/ -/nbproject/private/ \ No newline at end of file +/nbproject/private/ +data_files/ diff --git a/qa-include/app/blobs.php b/qa-include/app/blobs.php index 41a64ad6c..5b2f23edd 100644 --- a/qa-include/app/blobs.php +++ b/qa-include/app/blobs.php @@ -213,5 +213,18 @@ function qa_blob_exists($blobid) require_once QA_INCLUDE_DIR . 'db/blobs.php'; - return qa_db_blob_exists($blobid); + $db_blob_exists = qa_db_blob_exists($blobid); + + if (!$db_blob_exists) + return false; + + if (!defined('QA_BLOBS_DIRECTORY')) + return true; + else + { + $blob = qa_db_blob_read($blobid); + + $filename = qa_get_blob_filename($blobid, $blob['format']); + return is_readable($filename); + } } From 64448ae70a3afaa7e4f0c78b025e96bfa4f92104 Mon Sep 17 00:00:00 2001 From: Bertrand Gorge Date: Mon, 17 Feb 2020 14:48:59 +0100 Subject: [PATCH 4/6] Added plugins to ignore file --- .gitignore | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index 3d2dbd28c..6ac0e1822 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,15 @@ Thumbs.db .idea/ /nbproject/private/ data_files/ +qa-plugin/ajax-images +qa-plugin/api +qa-plugin/Donut-admin +qa-lang/fr +qa-plugin/neayi +qa-plugin/q2a-ask-with-tags-list +qa-plugin/q2a-breadcrumbs +qa-plugin/q2a-email-notification +qa-plugin/q2a-markdown-editor +qa-plugin/q2a-open-login +qa-plugin/q2a-social-share +qa-theme/Donut-theme From 28b60c19ee561d527fafdd4409262c1197e86f45 Mon Sep 17 00:00:00 2001 From: Bertrand Gorge Date: Tue, 18 Feb 2020 16:11:17 +0100 Subject: [PATCH 5/6] Delete QA-Google-Analytics-Plugin --- qa-plugin/QA-Google-Analytics-Plugin | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 qa-plugin/QA-Google-Analytics-Plugin diff --git a/qa-plugin/QA-Google-Analytics-Plugin b/qa-plugin/QA-Google-Analytics-Plugin deleted file mode 100644 index b1b3ba787..000000000 --- a/qa-plugin/QA-Google-Analytics-Plugin +++ /dev/null @@ -1,5 +0,0 @@ -XSym -0050 -afe5f18ead938ea5d08e3d1a860e7f9d -/var/www/q2a-thirdparty/QA-Google-Analytics-Plugin - \ No newline at end of file From a16c6c3d00be679ee08ad82cb5efaded86ae2a7d Mon Sep 17 00:00:00 2001 From: Bertrand Gorge Date: Tue, 18 Feb 2020 16:44:32 +0100 Subject: [PATCH 6/6] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6ac0e1822..40d900a2f 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ qa-plugin/q2a-markdown-editor qa-plugin/q2a-open-login qa-plugin/q2a-social-share qa-theme/Donut-theme +qa-plugin/QA-Google-Analytics-Plugin