Re: [Wikitech-l] Storing some values in the DB

2020-02-08 Thread crawlspaces via Wikitech-l
What about log_search, which is intended for permanent storage of data; could 
your extension generate a log event and then use that log_id as the ls_log_id? 
https://www.mediawiki.org/wiki/Manual:Log_search_table

Maybe there could be a new type of log_type/log_action introduced, e.g. 
storedata/myextension, if your extension is called MyExtension. Each extension 
that stores data in this way would have its own log_action, and would generate 
one or more log events as needed to reserve a log_id(s) for data storage.
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] Storing some values in the DB

2020-01-29 Thread Jeroen De Dauw
Hey,

Sounds like you just want a simple key value store that.
> I don't believe mediawiki has a table or interface for this.
>

Indeed.


> Slightly relevant would be https://phabricator.wikimedia.org/T227776
> although
> that RFC will likely come up with something that is in some way bound to a
>

The ticket Kosta Harlan linked before (
https://phabricator.wikimedia.org/T128602) seems more relevant. Even though
an extension providing this functionality would not be of much help for my
use case, unless it came bundled with core. Requiring an extra extension
that needs to be installed using update.php just to avoid needing to run
update.php for my extension does not make any sense.

If you are overwhelmed with SQL or mediawiki migration system please just
> ask for help
>

Thank you Jaime but I think I can manage ;)

Cheers

--
Jeroen De Dauw | www.EntropyWins.wtf 
Professional wiki hosting and services: www.Professional.Wiki

Software Crafter | Speaker | Entrepreneur | Open Source and Wikimedia
contributor ~=[,,_,,]:3
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] Storing some values in the DB

2020-01-29 Thread Addshore
Sounds like you just want a simple key value store that.
I don't believe mediawiki has a table or interface for this.

Slightly relevant would be https://phabricator.wikimedia.org/T227776 although
that RFC will likely come up with something that is in some way bound to a
page.

On Tue, 28 Jan 2020 at 19:14, Jaime Crespo  wrote:

> > It complicates extension installation
>
> One could just copy and paste the existing migration code and just change
> the SQL to the right CREATE TABLE, and be done. If you just have to create
> a table, you will only have to do that once, no maintenance required.
> Trying to fit values into existing tables, however will create a lot of
> maintenance headaches, as Brian said.
>
> # include/Hooks.php
> $base = __DIR__ . "/../sql";
> $updater->addExtensionTable( 'extension_value', $base .
> '/ExtensionValue.sql' );
> # sql/ExtensionValue.sql
> CREATE TABLE extension_value (
> k varchar(100) PRIMARY KEY,
> v int NOT NULL,
> );
>
> If you are overwhelmed with SQL or mediawiki migration system please just
> ask for help and people here, including me, will be able to help! :-D
> Mediawiki core code can be intimidating because support of several
> databases systems and its long history of schema changes, but in your case
> adding a table should not take more than 2 files that are never touched
> again :-D. Update.php will have to be run anyway on core updates. Handling
> mysql and queries is way more difficult than creating it in the first
> place!
>
> Or maybe we are not understanding what you are trying to achieve. 0:-)
>
> On Mon, Jan 27, 2020 at 5:00 PM Jeroen De Dauw 
> wrote:
>
> > Hey,
> >
> > > Why are you so reluctant to create a table?
> >
> > It complicates extension installation and adds yet another thing to
> > maintain. Which is a bit silly for a handful of values. I was hoping
> > MediaWiki would have a generic table to put such things already.
> Page_props
> > is exactly that, just bound to specific pages.
> >
> > Cheers
> >
> > --
> > Jeroen De Dauw | www.EntropyWins.wtf 
> > Professional wiki hosting and services: www.Professional.Wiki
> > 
> > Software Crafter | Speaker | Entrepreneur | Open Source and Wikimedia
> > contributor ~=[,,_,,]:3
> > ___
> > Wikitech-l mailing list
> > Wikitech-l@lists.wikimedia.org
> > https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
>
>
> --
> Jaime Crespo
> 
> ___
> Wikitech-l mailing list
> Wikitech-l@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] Storing some values in the DB

2020-01-28 Thread Jaime Crespo
> It complicates extension installation

One could just copy and paste the existing migration code and just change
the SQL to the right CREATE TABLE, and be done. If you just have to create
a table, you will only have to do that once, no maintenance required.
Trying to fit values into existing tables, however will create a lot of
maintenance headaches, as Brian said.

# include/Hooks.php
$base = __DIR__ . "/../sql";
$updater->addExtensionTable( 'extension_value', $base .
'/ExtensionValue.sql' );
# sql/ExtensionValue.sql
CREATE TABLE extension_value (
k varchar(100) PRIMARY KEY,
v int NOT NULL,
);

If you are overwhelmed with SQL or mediawiki migration system please just
ask for help and people here, including me, will be able to help! :-D
Mediawiki core code can be intimidating because support of several
databases systems and its long history of schema changes, but in your case
adding a table should not take more than 2 files that are never touched
again :-D. Update.php will have to be run anyway on core updates. Handling
mysql and queries is way more difficult than creating it in the first place!

Or maybe we are not understanding what you are trying to achieve. 0:-)

On Mon, Jan 27, 2020 at 5:00 PM Jeroen De Dauw 
wrote:

> Hey,
>
> > Why are you so reluctant to create a table?
>
> It complicates extension installation and adds yet another thing to
> maintain. Which is a bit silly for a handful of values. I was hoping
> MediaWiki would have a generic table to put such things already. Page_props
> is exactly that, just bound to specific pages.
>
> Cheers
>
> --
> Jeroen De Dauw | www.EntropyWins.wtf 
> Professional wiki hosting and services: www.Professional.Wiki
> 
> Software Crafter | Speaker | Entrepreneur | Open Source and Wikimedia
> contributor ~=[,,_,,]:3
> ___
> Wikitech-l mailing list
> Wikitech-l@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l



-- 
Jaime Crespo

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] Storing some values in the DB

2020-01-27 Thread Thiemo Kreuz
Again. What exactly are you trying to store? How often is it suspected
to change? Who will be allowed to change it? Why not make it
configuration via LocalSettings.php? What is the problem with an extra
table?

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] Storing some values in the DB

2020-01-27 Thread Jeroen De Dauw
Hey,

> Why are you so reluctant to create a table?

It complicates extension installation and adds yet another thing to
maintain. Which is a bit silly for a handful of values. I was hoping
MediaWiki would have a generic table to put such things already. Page_props
is exactly that, just bound to specific pages.

Cheers

--
Jeroen De Dauw | www.EntropyWins.wtf 
Professional wiki hosting and services: www.Professional.Wiki

Software Crafter | Speaker | Entrepreneur | Open Source and Wikimedia
contributor ~=[,,_,,]:3
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] Storing some values in the DB

2020-01-27 Thread Thiemo Kreuz
Jeroen, can you please provide more context? What exactly are you
trying to store? Why? How often? When will it be changed? By whom?

As of now the rather vague explanation provided make it sound like
it's a configuration flag, and should go into LocalSettings.php as a
$wgYourExtensionYourConfig = 23; variable.

https://www.mediawiki.org/wiki/Manual:Database_layout provides an
overview of the database tables that come with MediaWiki.

You are free to create a new table any time you want. Even if it's
only going to store 3 rows, that should be fine. I'm not aware of a
reason to not do this. Wikibase, for example, contains a table
wb_id_counters that is not meant to store new rows, but only a
strictly limited set of rows. You can copy the update mechanism
related to that table, if you like.

Kind regards
Thiemo

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] Storing some values in the DB

2020-01-27 Thread Jeroen De Dauw
Hey Kosta,

The values in my extension are not user specific. It is really just a
handful of values for the entire wiki.

One approach I'm considering is to abuse the page props table and have the
values "linked to page" with ID 1 billion (or -1) or so. I'm not sure how
safe that is though. The data would only be stored in the database, so not
losing it due to the running of some maintenance process is important.

Cheers

--
Jeroen De Dauw | www.EntropyWins.wtf 
Professional wiki hosting and services: www.Professional.Wiki

Software Crafter | Speaker | Entrepreneur | Open Source and Wikimedia
contributor ~=[,,_,,]:3


On Mon, 27 Jan 2020 at 12:30, Kosta Harlan  wrote:

> Hi,
>
> On 1/27/20 12:13 PM, Jeroen De Dauw wrote:
> > Hey,
> >
> > I have a MediaWiki extension in which I'd like to store a handful of
> > values. Example:
> >
> > * Cats 42
> > * Ravens 23
> > * Goats 0
> >
> > The most obvious thing to do would be to add a new database table with a
> > string and an integer column. However I'd like to avoid the need to run
> > update.php to install this extension. Is there some place in the
> MediaWiki
> > DB schema where I can put a few values like these? They could even be in
> a
> > single serialized blob (though preferably can be looked up by string
> key).
>
> You want to store these values per-user, I'm assuming? This is probably
> of interest then: https://phabricator.wikimedia.org/T128602
>
> In GrowthExperiments extension we store small bits of data like that as
> serialized blobs in hidden user preferences, but this isn't great, among
> other reasons because the values are delivered on on each page load
> whether you want them or not.
>
> Kosta
>
> >
> > Cheers
> >
> > --
> > Jeroen De Dauw | www.EntropyWins.wtf 
> > Professional wiki hosting and services: www.Professional.Wiki
> > 
> > Software Crafter | Speaker | Entrepreneur | Open Source and Wikimedia
> > contributor ~=[,,_,,]:3
> > ___
> > Wikitech-l mailing list
> > Wikitech-l@lists.wikimedia.org
> > https://lists.wikimedia.org/mailman/listinfo/wikitech-l
> >
>
> ___
> Wikitech-l mailing list
> Wikitech-l@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] Storing some values in the DB

2020-01-27 Thread Kosta Harlan

Hi,

On 1/27/20 12:13 PM, Jeroen De Dauw wrote:

Hey,

I have a MediaWiki extension in which I'd like to store a handful of
values. Example:

* Cats 42
* Ravens 23
* Goats 0

The most obvious thing to do would be to add a new database table with a
string and an integer column. However I'd like to avoid the need to run
update.php to install this extension. Is there some place in the MediaWiki
DB schema where I can put a few values like these? They could even be in a
single serialized blob (though preferably can be looked up by string key).


You want to store these values per-user, I'm assuming? This is probably 
of interest then: https://phabricator.wikimedia.org/T128602


In GrowthExperiments extension we store small bits of data like that as 
serialized blobs in hidden user preferences, but this isn't great, among 
other reasons because the values are delivered on on each page load 
whether you want them or not.


Kosta



Cheers

--
Jeroen De Dauw | www.EntropyWins.wtf 
Professional wiki hosting and services: www.Professional.Wiki

Software Crafter | Speaker | Entrepreneur | Open Source and Wikimedia
contributor ~=[,,_,,]:3
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l



___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

[Wikitech-l] Storing some values in the DB

2020-01-27 Thread Jeroen De Dauw
Hey,

I have a MediaWiki extension in which I'd like to store a handful of
values. Example:

* Cats 42
* Ravens 23
* Goats 0

The most obvious thing to do would be to add a new database table with a
string and an integer column. However I'd like to avoid the need to run
update.php to install this extension. Is there some place in the MediaWiki
DB schema where I can put a few values like these? They could even be in a
single serialized blob (though preferably can be looked up by string key).

Cheers

--
Jeroen De Dauw | www.EntropyWins.wtf 
Professional wiki hosting and services: www.Professional.Wiki

Software Crafter | Speaker | Entrepreneur | Open Source and Wikimedia
contributor ~=[,,_,,]:3
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l