{"id":2354,"date":"2021-03-05T00:11:32","date_gmt":"2021-03-05T08:11:32","guid":{"rendered":"http:\/\/wonghoi.humgar.com\/blog\/?p=2354"},"modified":"2021-03-05T00:11:33","modified_gmt":"2021-03-05T08:11:33","slug":"nextcloud-quirks-moving-folder-breaks-the-site","status":"publish","type":"post","link":"https:\/\/wonghoi.humgar.com\/blog\/2021\/03\/05\/nextcloud-quirks-moving-folder-breaks-the-site\/","title":{"rendered":"NextCloud quirks &#8211; moving folder breaks the site"},"content":{"rendered":"\n<p>I changed the folder of where my NextCloud files is and got this error.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"845\" height=\"312\" src=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2021\/03\/image-7.png\" alt=\"\" class=\"wp-image-2355\" srcset=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2021\/03\/image-7.png 845w, https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2021\/03\/image-7-300x111.png 300w, https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2021\/03\/image-7-768x284.png 768w\" sizes=\"auto, (max-width: 845px) 100vw, 845px\" \/><\/figure>\n\n\n\n<p>Adding the &#8220;.ocdata&#8221; dummy file there doesn&#8217;t work. The message is cryptic. I tried to run <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">occ<\/code> at the root folder (hoping it&#8217;s some sort of management tool) by running this at the command\/SSH prompt:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php .\/occ<\/code><\/pre>\n\n\n\n<p>and it spits out:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Your data directory is invalid\r\nEnsure there is a file called \".ocdata\" in the root of the data directory.\r\n\r\nAn unhandled exception has been thrown:\r\nException: Environment not properly prepared. in \n{New Folder}\/lib\/private\/Console\/Application.php:168\r\nStack trace:\r\n#0 {New Folder}\/console.php(99): ...<\/code><\/pre>\n\n\n\n<p>I replaced my actual path for the new location of the NextCloud files with {New Folder}, so you get the idea.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>I also noticed the <strong>old <\/strong>path was regenerated with just a <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">\/data<\/code> folder with two files<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"362\" height=\"120\" src=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2021\/03\/image-8.png\" alt=\"\" class=\"wp-image-2356\" srcset=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2021\/03\/image-8.png 362w, https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2021\/03\/image-8-300x99.png 300w, https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2021\/03\/image-8-360x120.png 360w\" sizes=\"auto, (max-width: 362px) 100vw, 362px\" \/><\/figure>\n\n\n\n<p>This means some programmer got lazy and hard-coded the path somewhere! <\/p>\n\n\n\n<p>Line 99 of <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">console.php<\/code> didn&#8217;t give too much hint so I looked at the code around for some sort of config-related operations before. Then I noticed this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"760\" height=\"52\" src=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2021\/03\/image-9.png\" alt=\"\" class=\"wp-image-2357\" srcset=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2021\/03\/image-9.png 760w, https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2021\/03\/image-9-300x21.png 300w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/><\/figure>\n\n\n\n<p>So I searched for <code>config.php<\/code> and found it&#8217;s located in <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">\/config\/config.php<\/code>. Bingo!<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n$CONFIG = array (\n...\n  'trusted_domains' => \n  array (\n    0 => '{Old URL}',\n  ),\n  'datadirectory' => '{Old Path}\/data',\n...\r\n  'overwrite.cli.url' => 'https:\/\/{Old URL}',\n...\n);<\/code><\/pre>\n\n\n\n<p>And to my horror the SQL password is stored in plain text in <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">config.php<\/code>! WTF! I&#8217;ll choose a password that&#8217;s dedicated to one use and not shared!<\/p>\n\n\n\n<p>I recalled a when I rename WordPress databases, I have to manually edit the changes in <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">wp-config.php<\/code>. Turns out nobody warned us about that for NextCloud! That config file also contain database settings, so I bet if I change the database names or database usernames, I&#8217;ll have to come back and edit it manually too.<\/p>\n\n\n\n<p>The site is working after I made the migration changes, all in <code>\/config\/config.php<\/code>.<\/p>\n<div class=\"pvc_clear\"><\/div><p id=\"pvc_stats_2354\" class=\"pvc_stats all  \" data-element-id=\"2354\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p><div class=\"pvc_clear\"><\/div>","protected":false},"excerpt":{"rendered":"<p>I changed the folder of where my NextCloud files is and got this error. Adding the &#8220;.ocdata&#8221; dummy file there doesn&#8217;t work. The message is cryptic. I tried to run occ at the root folder (hoping it&#8217;s some sort of &hellip; <a href=\"https:\/\/wonghoi.humgar.com\/blog\/2021\/03\/05\/nextcloud-quirks-moving-folder-breaks-the-site\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_2354\" class=\"pvc_stats all  \" data-element-id=\"2354\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[54,42],"tags":[],"class_list":["post-2354","post","type-post","status-publish","format-standard","hentry","category-linux-embedded","category-web-services"],"_links":{"self":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts\/2354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/comments?post=2354"}],"version-history":[{"count":1,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts\/2354\/revisions"}],"predecessor-version":[{"id":2359,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts\/2354\/revisions\/2359"}],"wp:attachment":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/media?parent=2354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/categories?post=2354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/tags?post=2354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}