Hi,
I have been planning and starting to implement a few of my own extensions. Having read through relevant manuals and documentation located at mediawiki.org, wanted to clarify a two things:
1. When using startAtomic()/endAtomic() or begin()/commit() pairs, I understand that these will commit changes but does that automatically close the connection to the wiki database *$dbr = wfGetDB();* or am I required to close that connection with $dbr->close()?
2. Is it recommended to use foreign keys to the existing User table instead of creating a new table column? Concerned that Extensions AbuseFilter/RenameUser/UserMerge, could corrupt or cause failure.
Thanks,
Kevin
So commit() or endAtomic() will not close the db connection. However mediawiki will manage the db connections itself and will reuse already open connections. You should not close() the connection.
Db transactions/atomic sections are used when you have stuff you need to ensure is consistent (it either fully works or fully fails and if some sort of error happens the db is reverted back to a known good state). It is not required just to make write actions to the database, as you can still make those outside of transactions/atomic sections (technically writes inside a request but outside an explicit transaction all get wrapped in an implicit transaction which is committed at the end of request for a web request or immediatly in a cli request)
I would reccomend creating a new table with a foreign key rather than trying to add columns to an existing core table. Generally its assumed that mw core controls the fields present in tables defined by mw core.
RenameUser has a hook to allow extensions to tell it about your custom extension table if neccesary (should be unnessary if you just have a foreign key to the actor table)
-- Brian
On Thursday, June 13, 2019, Kevin Zhang msuzhangke8@gmail.com wrote:
Hi,
I have been planning and starting to implement a few of my own extensions. Having read through relevant manuals and documentation located at mediawiki.org, wanted to clarify a two things:
- When using startAtomic()/endAtomic() or begin()/commit() pairs, I
understand that these will commit changes but does that automatically close the connection to the wiki database *$dbr = wfGetDB();* or am I required to close that connection with $dbr->close()?
- Is it recommended to use foreign keys to the existing User table instead
of creating a new table column? Concerned that Extensions AbuseFilter/RenameUser/UserMerge, could corrupt or cause failure.
Thanks,
Kevin _______________________________________________ MediaWiki-l mailing list To unsubscribe, go to: https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org