Posts: 2,895
Threads: 59
Joined: Jun 2010
(17-Jul-2010, 10:40 PM)Static Wrote: I need help locating the place where the page id is set into the database, and the places where it's used that are important. I found the following files which seem relevant:
- App/processor.php
- Functions/processor.php
- Admin/Pages/manage_pages.php
The validate_page_id() function in comments/includes/functions/page.php is quite pertinent.
Have
you completed
the interview?
Posts: 535
Threads: 31
Joined: Jul 2010
Thanks, I'll look into it. However, the roadmap says
Code:
[Bug Fix] Removes default value for text columns in installer
[Bug Fix] Preserves URL parameters (and adjusts referrer check)
Does that mean you beat me to it? Either way, great!
I'm giving you three guesses...
Posts: 2,895
Threads: 59
Joined: Jun 2010
I haven't (yet) changed anything to do with the Page ID.
I only integrated the Preserve Query add-on and added the change in post #11.
Were you expecting something else?
Have
you completed
the interview?
Posts: 535
Threads: 31
Joined: Jul 2010
No, I wasn't really. Does the installation have anything to do with the type of the 'id' column? If so, how do I change the id type to string? If it helps, I have phpMyAdmin installed.
I'm giving you three guesses...
Posts: 2,895
Threads: 59
Joined: Jun 2010
Yes the installer sets the type of the id column in the pages table.
Go to the pages table in phpMyAdmin and click on the 'Structure' tab at the top.
On the id row, click the edit button (at the right under 'Action').
Change the 'Type' to varchar.
Set your desired maximum length (e.g. 250)
Make the 'Attributes' blank.
Deselect the auto_increment.
Click Save.
P.S. Note also that the RSS file, comments/rss.php, expects the Page ID in the URL to be a number.
P.S. Obviously you will need to re-write the Manage -> Pages page in the admin panel.
Have
you completed
the interview?
Posts: 535
Threads: 31
Joined: Jul 2010
I figured out how to change it in phpMyAdmin before you posted
. I'll fix the rss and manage pages along with the installer later, first, I'll have to make it work. I'll update when I get something to work.
I'm giving you three guesses...
Posts: 2,895
Threads: 59
Joined: Jun 2010
If it was me I would add another column to the pages table called 'page_id'.
I think it's important for the id column to autoincrement so that it's always unique.
Have
you completed
the interview?
Posts: 535
Threads: 31
Joined: Jul 2010
I just got it working with a text ID. All I modified was the following in "/includes/functions/page.php":
PHP Code:
<?php
function validate_page_id() { //validate page ID
global $mysql_table_prefix, $page_id; //globalise variables
if (!isset($page_id) || empty($page_id)) { //if no page ID
?><span class="page_id_alert"><?php echo ALERT_MESSAGE_NO_PAGE_ID;?></span><?php
die();
} else if (ctype_graph($page_id) && strlen($page_id) < 250) { //if page ID validates
if (mysql_num_rows(mysql_query("SELECT * FROM `".$mysql_table_prefix."pages` WHERE id = '$page_id'")) == 0) { //if page ID does not exist
?><span class="page_id_alert"><?php echo ALERT_MESSAGE_MISMATCHING_PAGE_ID;?></span><?php
die();
}
} else { //page ID did not validate
?><span class="page_id_alert"><?php echo ALERT_MESSAGE_INVALID_PAGE_ID;?></span><?php
die();
}
} //end of validate-page-id function
Of course, I had to modify the id through phpMyAdmin, which is trivial. How I have set it up is by setting the id in the included page to be the value of the variable that I want. Then set the id of the page (in mySQL) to be one of the variable names. Now, I'll work on making it work by just getting the last part of the url. example:
Code:
example.php?variable=value
PS: I was writing this before you posted. Having another column might be a good idea. I see it as a way to make sure each page can't have the same id so that you don't get two different comment sessions with the same ID. Not sure how it would work together though. Not letting two pages have the same ID seems easier. I'll have to think over it. By the way, I didn't know how to call the "comment sessions", so I just called them that. What should I have called them?
I'm giving you three guesses...
Posts: 2,895
Threads: 59
Joined: Jun 2010
I know what you mean when you say "comment sessions". I can't currently think of a clearer short way to say it.
Please remember to use PHP tags when posting (mostly) PHP code. I'm going to add that to the forum rules.
Have
you completed
the interview?