Commit Graph

74 Commits

Author SHA1 Message Date
Alexei Sorokin bee3dea9c2 [DATABASE] Add explicit indices for all foreign keys
This adds a requirement for all definitions that have foreign keys to also
require indices for all source (local) attributes mentioned in foreign keys.

MariaDB/MySQL creates indices for source attributes automatically, so this
serves as a way to get rid of those automatic indices and create clean explicit
ones instead.

In PostgreSQL, most of the time, indices on the source are necessary to
decrease performance penalty of foreign keys (like in MariaDB), but they aren't
created automatically, so this serves to remove that difference between
PostgreSQL and MariaDB.
2021-07-16 19:44:38 +01:00
Alexei Sorokin b1b1d2af93 [DATABASE] Update "modified" in Managed_DataObject instead of a DBMS trigger
Instead of relying on the MariaDB's ON UPDATE CURRENT_TIMESTAMP trigger update
"modified" attributes in Managed_DataObject. Every raw query that needs
adjusting is adjusted, as they won't update "modified" automatically anymore.

The main goal behind this change is to fix "modified" updates on PostgreSQL.
2021-07-16 19:44:37 +01:00
Alexei Sorokin 26115482ef [SCHEMA] Improve timestamp storage
Avoid the use of deprecated MariaDB "zero dates" globally. If they're present
as attribute defaults somewhere, they will be replaced with NULL implicitly.
The existing "zero dates" in MariaDB storage will be left intact and this
should not present any issues.

The "timestamp" type in table definitions now corresponds to DATETIME in
MariaDB with "DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", which
should be close enough to the original behaviour for compatibility purposes.
It is now the recommended type for "modified" attributes, because of the
update trigger on MariaDB. But there is no such trigger implemented on
PostgreSQL as of this moment.
2021-07-16 19:44:37 +01:00
Alexei Sorokin 16b5ddd230 [DATABASE] Re-introduce PostgreSQL support 2021-07-16 19:44:35 +01:00
Alexei Sorokin 2b0251213f [DATABASE] Various table schema related fixes 2021-07-16 19:44:35 +01:00
Alexei Sorokin d26aac77b3 [DATABASE] Always quote identifiers
The code used to operate under the assumption that MariaDB doesn't support
quoting identifiers. Not only is that not exactly true, but MariaDB has
reserved keywords that cannot be used as table or column names unquoted.
2021-07-16 19:44:35 +01:00
Diogo Cordeiro f67a93eddc [CORE] Bump Database requirement to MariaDB 10.3+ 2019-08-03 17:47:23 +01:00
Mikael Nordfeldth 979c525124 I like to throw exceptions instead of using if statements. 2017-05-02 09:07:39 +02:00
Mikael Nordfeldth c48508d590 use getByID (also bad variable reference) 2016-04-18 15:08:47 +02:00
mmn 722ff4d9c0 Merge branch 'foolproof_file_redirection_branch' into 'nightly'
Foolproof file redirection

This solves an issue when our internal /attachment/{file_id} links are shortened with an remote shorteners (which caused the /attachment/{file_id} links to be saved to the File table and a thumbnail of a thumbnail being generated)

See merge request !98
2016-02-26 12:49:10 +00:00
hannes 501d081d3b getKV doesn't throw exception 2016-02-16 19:16:05 +00:00
Mikael Nordfeldth e903bd0bc3 Hacky support for geo URI detection
Won't work with common_purify yet because there is no geo uri scheme for it
2016-02-03 14:19:08 +01:00
Mikael Nordfeldth 6a4aa34b0c Don't process further in redirection if HEAD gives 400 Bad request 2016-02-03 00:34:49 +01:00
hannes efd2326a29 the last url in the redirection chain can actually also be a redirection (e.g. if it's one of our /attachment/{file_id} links) 2016-01-29 00:34:32 +00:00
hannes 48e1a2431b save File and File_redirection records in File_redirection::where(), because then we will have to run where() over and over again 2016-01-25 18:55:48 +00:00
Mikael Nordfeldth a9d18a077e Harmonize, clarify, categorize URL schemes
Regular expression + avoid-redirection list now match each other.
2016-01-24 12:47:31 +01:00
Mikael Nordfeldth 1cec627d72 Allow bitcoin scheme to URLs 2016-01-24 12:44:28 +01:00
Mikael Nordfeldth e75472f460 Use the upstream function to get effectiveUrl 2016-01-13 14:00:05 +01:00
hannes 1c25cffbd8 add $redir->redir_url to use in common_linkify() 2016-01-05 23:07:24 +00:00
Mikael Nordfeldth 4bc0b374bc File_redirection should get URLs properly 2015-12-27 21:36:23 +01:00
Mikael Nordfeldth ef4c11d262 Better checks for defined array indexes 2015-12-15 11:50:57 +01:00
Mikael Nordfeldth 441e2c8d34 redir_info only has data if we ran discovery 2015-12-08 11:42:09 +01:00
Stephen Paul Weber a9b1b60a97 Refactor on File::processNew
The code was so involved there was even a comment asking for a refactor.

Now, File_redirection::where always returns a nice File_redirection
object instead of an array or string or nothing.  The object is
either one which already existed or else a new, unsaved object.

Instead of duplicating "does it exist" checks everywhere, do it in
File_redirection::where.  You either get what exists or something to save.

An unsaved File_redirection may be paired with an unsaved File.
You will want to save the File first (using ->saveFile()) and put the
id in File_redirection#file_id before saving.
2015-11-02 05:15:08 +00:00
Mikael Nordfeldth 4b69ef41e2 Bad variable name in File_redirection 2015-10-13 22:57:45 +02:00
Mikael Nordfeldth 77957372ab File_redirection static fixes and simplifying 2015-07-07 20:16:05 +02:00
Mikael Nordfeldth d0458b824a File_redirection minor coding layout fix 2015-07-07 19:59:43 +02:00
Mikael Nordfeldth 45ee2060fa File_redirection is called statically 2015-07-07 19:48:18 +02:00
Mikael Nordfeldth 8a002e98bc File-related functions not declared static 2015-06-07 10:01:28 +02:00
Mikael Nordfeldth cafab14f2b Modernize File_redirection to use Managed_DataObject functions 2015-06-04 22:33:36 +02:00
Mikael Nordfeldth d010c5a581 magnet URL linkify support 2015-05-09 15:54:09 +02:00
Mikael Nordfeldth 0e6c83e521 Had to avoid using indexes in the migration phase
File and File_redirection still had their indexes in the temporary migration table definition.
2015-02-19 22:06:43 +01:00
Mikael Nordfeldth b54710950f unique keys and indexes must be NOT NULL or MySQL fucks up
If this merge throws exception on scripts/upgrade.php and you recently
tried a nightly (i.e. during 2015-02-19) then just go back a commit or two
and try again.

Or delete the duplicate entries. Find the entries like this:

SELECT COUNT(*), urlhash FROM file_redirection
    GROUP BY urlhash
    HAVING COUNT(*) > 1;

then for each urlhash (or come up with a smart SQL query) do:
DELETE FROM file_redirection WHERE urlhash='hashfrompreviousquery' LIMIT 1;

You'll have to remove duplicates more than once if you have >2 identical
urlhash entries. LIMIT -1 might do that for you. I'm not sure.
2015-02-19 21:21:39 +01:00
Mikael Nordfeldth 5471c65c9a less newlines for the scripts/upgrade.php output 2015-02-19 19:40:36 +01:00
Mikael Nordfeldth 45dc76de26 File and File_redirection adhoc storage methods updated for urlhash 2015-02-19 19:05:24 +01:00
Mikael Nordfeldth 27480d8e8e File_redirection also got urlhash column 2015-02-19 18:34:48 +01:00
Mikael Nordfeldth 1776c90cb9 Moved oEmbed stuff out to a plugin (Oembed). 2014-05-06 23:32:13 +02:00
Mikael Nordfeldth 73fe8a81b7 Slight cleanup in typing and syntax of File and File_* classes 2013-11-10 14:33:45 +01:00
Mikael Nordfeldth 2a4dc77a63 The overloaded DB_DataObject function staticGet is now called getKV
I used this hacky sed-command (run it from your GNU Social root, or change the first grep's path to where it actually lies) to do a rough fix on all ::staticGet calls and rename them to ::getKV

   sed -i -s -e '/DataObject::staticGet/I!s/::staticGet/::getKV/Ig' $(grep -R ::staticGet `pwd`/* | grep -v -e '^extlib' | grep -v DataObject:: |grep -v "function staticGet"|cut -d: -f1 |sort |uniq)

If you're applying this, remember to change the Managed_DataObject and Memcached_DataObject function definitions of staticGet to getKV!

This might of course take some getting used to, or modification fo StatusNet plugins, but the result is that all the static calls (to staticGet) are now properly made without breaking PHP Strict Standards. Standards are there to be followed (and they caused some very bad confusion when used with get_called_class)

Reasonably any plugin or code that tests for the definition of 'GNUSOCIAL' or similar will take this change into consideration.
2013-08-18 13:13:56 +02:00
Mikael Nordfeldth 1a9a8ea730 staticGet for sub-Managed_DataObject classes now calls parent
The parent class for our database objects, Managed_DataObject, has a
dynamically assigned class in staticGet which objects get put into,
leaving us with less code to do the same thing.

We will probably have to move away from the DB_DataObject 'staticGet'
call as it is nowadays deprecated.
2013-08-12 19:46:44 +02:00
Mikael Nordfeldth 56cfd2bf22 comparing a url scheme should be done case insensitively 2013-08-12 12:52:50 +02:00
Evan Prodromou 9ca3c3d1c3 move core schema to class files 2011-08-22 17:52:02 -04:00
Evan Prodromou b85c4923a2 Remove unused and non-standard USER_AGENT constant from File_redirection 2011-04-06 10:25:59 -04:00
Brion Vibber 9df856e667 Merge branch '0.9.x' into merge
Conflicts:
	README
	actions/hostmeta.php
	classes/File_redirection.php
	lib/common.php
	lib/designsettings.php
	lib/router.php
	lib/util.php
	lib/xmppmanager.php
	plugins/OStatus/OStatusPlugin.php
2010-12-07 10:50:05 -08:00
Brion Vibber aa96c3c1d9 Fix for tickets #2917, #2262: user URL shortening options not being applied in non-web channels
common_shorten_links() can only access the web session's logged-in user, so never properly took user options into effect for posting via XMPP, API, mail, etc.

Adds an optional $user parameter on common_shorten_links(), and a $user->shortenLinks() as a clearer interface for that.
Tweaked some lower-level functions so $user gets passed down -- making the $notice_id param previously there for saving URLs at notice save time generalized a little.

Note also ticket #2919: there's a lot of duplicate code calling the shortening, checking the length, and reporting near-identical error messages. These should be consolidated to aid in code and translation maintenance.
2010-12-02 13:41:56 -08:00
Brion Vibber 197b56778a Add $config['attachments']['process_links'] to allow disabling processing of mentioned URL links for attachment info (oEmbed lookups) and dereferencing of redirects that we didn't have shortened ourselves.
This option may be useful for intranet sites that don't have direct access to the internet, as they may be unable to successfully fetch those resources.
2010-11-17 13:03:59 -08:00
Brion Vibber 1c90d09ec8 Workaround for yfrog.com photo attachments: fudge File_redirection::lookupWhere()'s HTTP handling -- when we get a 204 on a HEAD, double-check it by re-running as a GET. yfrog.com returns a 204 incorrectly for this case. 2010-11-15 11:01:00 -08:00
Brion Vibber 59119482ca Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 1.0.x
Conflicts:
	actions/hostmeta.php
	actions/imsettings.php
	classes/User.php
	lib/adminpanelaction.php
	lib/channel.php
	lib/default.php
	lib/router.php
	lib/util.php
2010-10-04 12:54:36 -07:00
Siebrand Mazeland b03ece26eb * i18n/L10n and translator documentation updates.
* whitespace and indentation updates
2010-09-28 23:21:09 +02:00
Evan Prodromou 7183175429 Merge branch 'master' into 1.0.x 2010-08-13 14:33:41 -07:00
Brion Vibber f7d599f8ea Fix for ticket 2513: "Can't linkify" error when some links are shortened
When bogus SSL sites etc were hit through a shortening redirect, sometimes link resolution kinda blew up and the user would get a "Can't linkify" error, aborting their post.
Now catching this case and just passing through the URL without attempting to resolve it. Could benefit from an overall scrubbing of the freaky link/attachment code though...! :)

http://status.net/open-source/issues/2513
2010-08-12 15:25:32 -07:00