Posts: 15
Threads: 4
Joined: Nov 2022
On my site, the page's URL address is determined by its place in the available list of pages.
Recently, I've added a couple of pages at the beginning of the list, and it turns out it now kinda broke the URLs used for permalinks to the comments on these pages (both in the frontend interface and in things like e-mail notifications) - they still use old URLs, and following them gets you to a different page (Thankfully it didn't broke the comment threads themselves, since I used factual static ID of the page from the database as identifier).
Looks like Commentics looks for the URL of the thread only once, when it creates it, correct?
I was wondering if it is possible to regenerate those URLs somehow? Or I'm stuck with the majority of my threads having wrong permalink URLs now?
Posts: 2,904
Threads: 59
Joined: Jun 2010
Yes if you open /system/library/page.php, after this:
Code:
$this->form_enabled = $page['is_form_enabled'];
Add this:
Code:
if (!$this->request->isAjax()) {
$this->db->query("UPDATE `" . CMTX_DB_PREFIX . "pages` SET `url` = '" . $this->db->escape($this->url->getPageUrl()) . "' WHERE `id` = '" . (int) $page['id'] . "'");
}
Have
you completed
the interview?
Posts: 2,904
Threads: 59
Joined: Jun 2010
The reason it doesn't keep the URLs up-to-date is because it would make the URLs open to abuse.
For example someone could add arbitrary parameters to the URL (which everyone would see when receiving an email).
Have
you completed
the interview?
Posts: 15
Threads: 4
Joined: Nov 2022
(13-Mar-2025, 04:25 PM)Steven Wrote: The reason it doesn't keep the URLs up-to-date is because it would make the URLs open to abuse.
For example someone could add arbitrary parameters to the URL (which everyone would see when receiving an email).
Ah, thanks! So, I make changes, visit each page, and then undo the changes back, yes?
...Hm, I think the fix for that URL abuse can be made by adding the same condition to that if statement that checks that I'm the admin? Then only Admins visiting would trigger an update of URL.
Posts: 15
Threads: 4
Joined: Nov 2022
Would this work?
Code:
if (!$this->request->isAjax() && isset($this->session->data['cmtx_admin_id'])) {
$this->db->query("UPDATE `" . CMTX_DB_PREFIX . "pages` SET `url` = '" . $this->db->escape($this->url->getPageUrl()) . "' WHERE `id` = '" . (int) $page['id'] . "'");
}
Posts: 15
Threads: 4
Joined: Nov 2022
The "edit reply" button is gone again...
...So I was pulling my hairs as to why on some pages the edited section chose to blatantly ignore the
$cmtx_url variable and write a wrong URL into the DB, until I noticed that
$this->page_url gets
owerwritten right before the edit in the OG code (
$this->url->getPageUrl() didn't respect
$cmtx_url either), for some reason, so I had to preserve the URL I
want into a
new variable.
This is the code I ended up with, if anybody's interested, and yeah, using the admin cookie works.:
Code:
if ($page) {
$this->id = $page['id'];
$neededURL = $this->page_url;
$this->page_url = $page['url'];
$this->form_enabled = $page['is_form_enabled'];
if (!$this->request->isAjax() && isset($this->session->data['cmtx_admin_id'])) {
$cleanURL = $this->db->escape($neededURL);
$this->db->query("UPDATE `" . CMTX_DB_PREFIX . "pages` SET `url` = '" . $cleanURL . "' WHERE `id` = '" . (int) $page['id'] . "'");
}
}