The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
I have a technical question:
how the vBulletin app prevents the overwriting records in the datastore table? for example, two admins are both adding new forums at the same time, as I know, it involves to read forumcache string from datastore table;unserialize it to php object; update this php object; serialize this object back to forumcache string and update datastore table with new forumcache string. During this process, what if one process read out the forumcache string from DB, another process also read out this string from DB before the first process update this string in DB, in this case, second process will overwrite the first process's update on forumcache string, is it? if vBulletin code will prevent this case from happening, could anybody point out which part of code doing this prevention? Thanks, a PHP newib who starting php programming 1.5 month ago |
#2
|
||||
|
||||
![]()
It is incredibly hard to find this happening - and thus, vBulletin does not have any timestamp checks or the like on that cache.
|
#3
|
|||
|
|||
![]()
Thanks, Dismounted, I have another related question, when a user is trying to delete his post, I noticed that forumcache string and usergroupcache string both get saved to datastore table.
95 Query REPLACE INTO datastore (title, data, unserialize) VALUES ('usergroupcache', 'a:10:.................) 95 Query REPLACE INTO datastore (title, data, unserialize) VALUES ('forumcache', 'a:17:{.................) then how can we deal with two users deleting their posts at the same time. it maybe a concurrent issue, is it? Thanks, |
#4
|
|||
|
|||
![]() Quote:
In short that should never happen unless there was some odd bugs in MySQL. Edit: Also just to add a tid-bit; no two requests will ever come in at exactly the same time. Without going into details I'll just say that networks (including the internet of course) just work that way. Sure two requests may come in within microseconds of each other but one will always be processed before the other. |
#5
|
||||
|
||||
![]() Quote:
|
#6
|
|||
|
|||
![]()
Thanks, Brad and Dismounted for clear explaination.
I only have Java/J2EE programming background and just started php programming 2 month ago. I do have some doubts regarding how requests coming in. In Java world, each request will be served as a thread, and there will be concurrent issue java developer should deal with in the design. maybe PHP world is different. i,e, server can't serve two requests at the same time? back to my question, here is another example: code: line 1: read forumcache string from datastore. ....................(change this string) line 1000: write forumcache string back to datastore. one process/thread that is serving request 1 is executing the code on line 200, then another processes/thread that is serving request 2 start executing code line 1, you can see in this case, the forumcache change on processes 2 will overwrite changes wrote by process 1. so if I understand your reply correctly, this will never happen, because server can only serve one request at a time? or the table is locked from line 1 until line 1000? bear with me if I'm asking dumb question... |
#7
|
|||
|
|||
![]()
This might be helpful to you; http://static.zend.com/topics/0200-T...ons-in-PHP.pdf
The table is locked during writes, not reads. So in your example the table would only be locked at line 1000 and would be unlocked as soon as that SQL query was processed. The main thing to keep in mind about PHP and programming for the web in general is the fact that web servers are stateless. This is why the way data is read/written/used may seem odd to you at first. The methods are different because everything is generated at runtime and destroyed at the end of script execution. A web server can handle more than one request at a time. What I was trying to get at is requests are put into a queue and processed in order based on time. Processes can also claim exclusive access to a resource (like session data or MySQL tables in the case of writes) and all other requests will be forced to wait before working with that resource in some cases (example; I can read data from a table you're writing to but I can't write to that table until you finish.) Also remember that we are talking about microseconds-milliseconds here. Also you should keep in mind that what you're getting at is not a very big deal because all the client has to do is load another page on our forum to get the most recent copy of the cache (or any other data stored in the database). Did that answer your question? I kinda feel like I'm dancing around it or not begin clear. I'm personally moving in the opposite direction you are..I started my programming voyage on the web and now I'm moving into C, C++ and a few assembly languages. I know as well as you do how confusing it can be learning a new programming language even if you have experience in another. You should pick up on PHP quickly though if you stick with it. Just try to roll with things and not get so hung up on the many ways PHP is not like Java. ![]() Oh one more quick thing. If you're new to PHP and are learning it with vBulletin a word of advice; Don't assume vBulletin is how PHP applications should be coded. vBulletin has a few growing pains and the source really shows it. If you're interested in learning PHP in general and using it outside of vBulletin I recommend going over to Sitepoint (and there are many other good sites) and reading about PHP5 and the OOP features. Here is a link to Sitepoint's PHP tutorial section; http://www.sitepoint.com/subcat/php-tutorials There are also many good books on PHP if you're like me and link things in print. If you need any more help just let me know. - Brad |
#8
|
|||
|
|||
![]()
Hey, Brad,
Thank you very much for long, detailed explanation and advice, it did help me a lot. I did think vBulletin is the model of PHP programming, so I pretty much dug deep and tried to customize it. will check those sites for PHP reference. |
#9
|
|||
|
|||
![]() Quote:
BTW I hope you didn't take my comment about vBulletin to mean it has "bad code" in the source. vBulletin just suffers from the same problem a lot of php applications have; It was originally put together when php was just becoming popular and because Jelsoft has a large customer base certain things in the source code have always been done a certain way to avoid breaking backwards compatibility and existing sites that use the software. Version 4 will come out at some point and it's supposed to be a total re-write of the source. It will also be the first version of the source code that does not have support for php version 4. Meaning the new version of vBulletin will be able to take full advantage of the new OOP features in php 5 (php 4 had OOP features but it was far from true OOP). |
#10
|
||||
|
||||
![]()
The developers have said the vBulletin 4 will follow the MVC (Model-View-Controller) pattern - so you might want to have a look at that.
![]() |
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|