OKAPI Project update (r424).

The major difference in this version of OKAPI is that it properly hides caches with statuses > 3. However, this required a complex update process. I'm not 100% sure if this update process will succeed in all scenarios, but I think it should.

Note, that first cronjobs fired after this update MAY take even 20 minutes to run.
This commit is contained in:
Wojciech Rygielski
2012-08-23 10:51:12 +02:00
parent b7ae9cc1f0
commit bdc794952e
16 changed files with 599 additions and 60 deletions

View File

@ -705,7 +705,7 @@ class Okapi
{
public static $data_store;
public static $server;
public static $revision = 413; # This gets replaced in automatically deployed packages
public static $revision = 424; # This gets replaced in automatically deployed packages
private static $okapi_vars = null;
/** Get a variable stored in okapi_vars. If variable not found, return $default. */
@ -1332,11 +1332,30 @@ class Okapi
}
private static $cache_types = array(
# Primary types
'Traditional' => 2, 'Multi' => 3, 'Quiz' => 7, 'Virtual' => 4,
# Additional types - these should include ALL types used in
# ANY of the opencaching installations. Contact me if you want to modify this.
'Event' => 6, 'Webcam' => 5, 'Moving' => 8, 'Own' => 9, 'Other' => 1,
#
# OKAPI does not expose type IDs. Instead, it uses the following
# "code words". Only the "primary" cache types are documented.
# This means that all other types may (in theory) be altered.
# Cache type may become "primary" ONLY when *all* OC servers recognize
# that type.
#
# Changing this may introduce nasty bugs (e.g. in the replicate module).
# CONTACT ME BEFORE YOU MODIFY THIS!
#
'oc.pl' => array(
# Primary types (documented, cannot change)
'Traditional' => 2, 'Multi' => 3, 'Quiz' => 7, 'Virtual' => 4,
# Additional types (may get changed)
'Other' => 1, 'Webcam' => 5, 'Event' => 6,
'Moving' => 8, 'Own' => 9,
),
'oc.de' => array(
# Primary types (documented, cannot change)
'Traditional' => 2, 'Multi' => 3, 'Quiz' => 7, 'Virtual' => 4,
# Additional types (might get changed)
'Other' => 1, 'Webcam' => 5, 'Event' => 6,
'Math/Physics-Cache' => 8, 'Moving' => 9, 'Drive-In' => 10,
)
);
private static $cache_statuses = array(
@ -1346,8 +1365,9 @@ class Okapi
/** E.g. 'Traditional' => 2. For unknown names throw an Exception. */
public static function cache_type_name2id($name)
{
if (isset(self::$cache_types[$name]))
return self::$cache_types[$name];
$ref = &self::$cache_types[Settings::get('OC_BRANCH')];
if (isset($ref[$name]))
return $ref[$name];
throw new Exception("Method cache_type_name2id called with unsupported cache ".
"type name '$name'. You should not allow users to submit caches ".
"of non-primary type.");
@ -1360,7 +1380,7 @@ class Okapi
if ($reversed == null)
{
$reversed = array();
foreach (self::$cache_types as $key => $value)
foreach (self::$cache_types[Settings::get('OC_BRANCH')] as $key => $value)
$reversed[$value] = $key;
}
if (isset($reversed[$id]))

View File

@ -0,0 +1,310 @@
msgid ""
msgstr ""
"Project-Id-Version: OKAPI\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-08-22 21:18+0100\n"
"PO-Revision-Date: 2012-08-22 21:18+0100\n"
"Last-Translator: \n"
"Language-Team: following <following-okapi@online.de>\n"
"Language: German\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: _;gettext;gettext_noop\n"
"X-Poedit-Basepath: c:\\source\\oc\\server-3.0\\htdocs\\okapi\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-SearchPath-0: c:\\source\\oc\\server-3.0\\htdocs\\okapi\n"
#: c:\source\oc\server-3.0\htdocs\okapi/services/caches/geocaches.php:640
msgid "Stage"
msgstr "Station"
#: c:\source\oc\server-3.0\htdocs\okapi/services/caches/formatters/gpxfile.tpl.php:27
#: c:\source\oc\server-3.0\htdocs\okapi/services/caches/formatters/gpxfile.tpl.php:44
msgid "hidden by"
msgstr "versteckt von"
#: c:\source\oc\server-3.0\htdocs\okapi/services/caches/formatters/gpxfile.tpl.php:46
#, php-format
msgid "%d recommendation"
msgid_plural "%d recommendations"
msgstr[0] "%d Empfehlung"
msgstr[1] "%d Empfehlungen"
#: c:\source\oc\server-3.0\htdocs\okapi/services/caches/formatters/gpxfile.tpl.php:47
#, php-format
msgid "found %d time"
msgid_plural "found %d times"
msgstr[0] "%d mal gefunden"
msgstr[1] "%d mal gefunden"
#: c:\source\oc\server-3.0\htdocs\okapi/services/caches/formatters/gpxfile.tpl.php:50
#, php-format
msgid "%d trackable"
msgid_plural "%d trackables"
msgstr[0] "%d Geokret"
msgstr[1] "%d Geokrets"
#: c:\source\oc\server-3.0\htdocs\okapi/services/caches/formatters/gpxfile.tpl.php:54
msgid "Personal notes"
msgstr "Persönliche Notizen"
#: c:\source\oc\server-3.0\htdocs\okapi/services/caches/formatters/gpxfile.tpl.php:58
msgid "Attributes"
msgstr "Attribute"
#: c:\source\oc\server-3.0\htdocs\okapi/services/caches/formatters/gpxfile.tpl.php:62
msgid "Trackables"
msgstr "Geokrets"
#: c:\source\oc\server-3.0\htdocs\okapi/services/caches/formatters/gpxfile.tpl.php:80
msgid "Images"
msgstr "Bilder"
#: c:\source\oc\server-3.0\htdocs\okapi/services/caches/formatters/gpxfile.tpl.php:87
msgid "Spoilers"
msgstr "Spoiler"
#: c:\source\oc\server-3.0\htdocs\okapi/services/caches/formatters/gpxfile.tpl.php:95
msgid "Image descriptions"
msgstr "Bildbeschreibungen"
#: c:\source\oc\server-3.0\htdocs\okapi/services/logs/submit.php:62
msgid ""
"You are trying to publish a log entry with a date in future. Cache log "
"entries are allowed to be published in the past, but NOT in the future."
msgstr ""
"Das Datum deines Logeintrags liegt in der Zukunft. Cache-Logs können nur für "
"die Vergangenheit oder für heute eingetragen werden."
#: c:\source\oc\server-3.0\htdocs\okapi/services/logs/submit.php:82
#, php-format
msgid ""
"However, your cache rating was ignored, because %s does not have a rating "
"system."
msgstr ""
"Deine Cachewertung wurde jedoch ignoriert, weil %s kein Bewertungssystem hat."
#: c:\source\oc\server-3.0\htdocs\okapi/services/logs/submit.php:92
msgid "Recommending is allowed only for 'Found it' logtypes."
msgstr "Empfehlungen sind nur bei 'Gefunden'-Logs erlaubt."
#: c:\source\oc\server-3.0\htdocs\okapi/services/logs/submit.php:101
#, php-format
msgid ""
"However, your \"needs maintenance\" flag was ignored, because %s does not "
"support this feature."
msgstr ""
"Deine Angabe \"benötigt Wartung\" wurde jedoch ignoriert, weil es diese "
"Funktion bei %s nicht gibt."
#: c:\source\oc\server-3.0\htdocs\okapi/services/logs/submit.php:124
msgid ""
"This cache is archived. Only admins and the owner are allowed to add a log "
"entry."
msgstr ""
"Dieser Cache ist archiviert. Nur OC-Admins und der Besitzer können "
"Logeinträge machen."
#: c:\source\oc\server-3.0\htdocs\okapi/services/logs/submit.php:128
msgid ""
"This cache is an Event cache. You cannot \"Find it\"! (But - you may "
"\"Comment\" on it.)"
msgstr ""
"Dies ist ein Event-Cache. Du kannst ihn nicht \"finden\" (aber du kannst "
"einen Hinweis loggen)."
#: c:\source\oc\server-3.0\htdocs\okapi/services/logs/submit.php:130
msgid "Your have to supply some text for your comment."
msgstr "Du musst einen Text für dein Hinweislog eingeben!"
#: c:\source\oc\server-3.0\htdocs\okapi/services/logs/submit.php:143
msgid "This cache requires a password. You didn't provide one!"
msgstr ""
"Dieser Cache kann nur mit Kennwort geloggt werden, aber du hast keines "
"angegeben."
#: c:\source\oc\server-3.0\htdocs\okapi/services/logs/submit.php:145
msgid "Invalid password!"
msgstr "Ungültiges Kennwort!"
#: c:\source\oc\server-3.0\htdocs\okapi/services/logs/submit.php:194
msgid "You have already submitted a log entry with exactly the same contents."
msgstr ""
"Du hast bereits einen Logeintrag mit genau dem gleichen Inhalt gemacht."
#: c:\source\oc\server-3.0\htdocs\okapi/services/logs/submit.php:213
msgid ""
"You have already submitted a \"Found it\" log entry once. Now you may submit "
"\"Comments\" only!"
msgstr ""
"Du hast diesen Cache bereits als gefunden geloggt. Ein zweites Fundlog ist "
"nicht möglich, aber du kannst stattdessen einen Hinweis loggen."
#: c:\source\oc\server-3.0\htdocs\okapi/services/logs/submit.php:215
msgid "You are the owner of this cache. You may submit \"Comments\" only!"
msgstr ""
"Als Besitzer des Caches kannst du nur Hinweise loggen, keine Funde oder "
"Nichtfunde."
#: c:\source\oc\server-3.0\htdocs\okapi/services/logs/submit.php:233
msgid "You have already rated this cache once. Your rating cannot be changed."
msgstr ""
"Du hast diesen Cache bereits bewertet. Deine Bewertung ist nicht änderbar."
#: c:\source\oc\server-3.0\htdocs\okapi/services/logs/submit.php:250
msgid "You have already recommended this cache once."
msgstr "Du hast diesen Cache bereits empfohlen."
#: c:\source\oc\server-3.0\htdocs\okapi/services/logs/submit.php:257
msgid "You don't have any recommendations to give. Find more caches first!"
msgstr ""
"Du musst mehr Caches finden, um eine weitere Bewertung abgeben zu können!"
#: c:\source\oc\server-3.0\htdocs\okapi/services/logs/submit.php:409
msgid "Your cache log entry was posted successfully."
msgstr "Dein Log wurde veröffentlicht."
#: c:\source\oc\server-3.0\htdocs\okapi/views/apps/authorize.tpl.php:5
msgid "Authorization Form"
msgstr "Authorisierungs-Formular"
#: c:\source\oc\server-3.0\htdocs\okapi/views/apps/authorize.tpl.php:46
msgid "Expired request"
msgstr "Anfrage abgelaufen"
#: c:\source\oc\server-3.0\htdocs\okapi/views/apps/authorize.tpl.php:47
msgid "Unfortunately, the request has expired. Please try again."
msgstr ""
"Die Anfrage ist wegen Zeitüberschreitung abgelaufen. Bitte versuche es noch "
"einmal."
#: c:\source\oc\server-3.0\htdocs\okapi/views/apps/authorize.tpl.php:49
msgid "External application is requesting access..."
msgstr "Eine externe Anwendung wünscht Zugriff ..."
#: c:\source\oc\server-3.0\htdocs\okapi/views/apps/authorize.tpl.php:50
#, php-format
msgid ""
"<b>%s</b> wants to access your <b>%s</b> account. Do you agree to grant "
"access to this application?"
msgstr ""
"<b>%s</b> möchte auf dein <b>%s</b>-Benutzerkonto zugreifen. Möchtest du "
"dieser Anwendung Zugriff gewähren?"
#: c:\source\oc\server-3.0\htdocs\okapi/views/apps/authorize.tpl.php:53
msgid "I agree"
msgstr "Ja"
#: c:\source\oc\server-3.0\htdocs\okapi/views/apps/authorize.tpl.php:54
msgid "Decline"
msgstr "Nein"
#: c:\source\oc\server-3.0\htdocs\okapi/views/apps/authorize.tpl.php:56
#, php-format
msgid ""
"\n"
"\t\t\t\t\t<p>Once permission is granted it is valid until its withdrawal on\n"
"\t\t\t\t\tthe <a href='%s'>applications management</a> page.</p>\n"
"\t\t\t\t\t<p>The application will access your acount via <a href='%s'>the "
"OKAPI Framework</a>.\n"
"\t\t\t\t\tIf you allow this request application will be able to access all "
"methods delivered\n"
"\t\t\t\t\tby the OKAPI Framework, i.e. post log entries on geocaches in your "
"name.\n"
"\t\t\t\t\tYou can revoke this permission at any moment.</p>\n"
"\t\t\t\t"
msgstr ""
"\n"
"\t\t\t\t\t<p>Wenn die Erlaubnis erteilt wurde, ist sie so lange gültig, bis "
"sie auf\n"
"\t\t\t\t\tder <a href='%s'>Anwendungs-Verwaltungsseite</a> widerrufen wird.</"
"p>\n"
"\t\t\t\t\t<p>Die Anwendung wird über die <a href='%s'>OKAPI-Schnittstelle</"
"a> auf dein Benutzerkonto zugreifen</a>.\n"
"\t\t\t\t\tWenn du diesen Zugriff erlaubst, kann die Anwendung alle OKAPI-"
"Funktionen verwenden,\n"
"\t\t\t\t\tz.B. Logeinträge unter deinem Namen veröffentlichen.\n"
"\t\t\t\t\tDu kannst diese Erlaubnis jederzeit widerrufen.</p>\n"
"\t\t\t\t"
#: c:\source\oc\server-3.0\htdocs\okapi/views/apps/authorized.tpl.php:5
msgid "Authorization Succeeded"
msgstr "Authorisierung erfolgreich"
#: c:\source\oc\server-3.0\htdocs\okapi/views/apps/authorized.tpl.php:28
msgid "Access successfully granted"
msgstr "Zugang wurde gewährt"
#: c:\source\oc\server-3.0\htdocs\okapi/views/apps/authorized.tpl.php:29
#, php-format
msgid ""
"\n"
"\t\t\t\t<p><b>You've just granted %s application access to your %s account.</"
"b>\n"
"\t\t\t\tTo complete the operation, go back to %s and enter the following PIN "
"code:</p>\n"
"\t\t\t"
msgstr ""
"\n"
"\t\t\t\t<p><b>Du hast der Anwendung \"%s\" Zugriff auf dein %s-Benutzerkonto "
"gewährt.</b>\n"
"\t\t\t\tUm den Vorgang abzuschließen, gehe zurück nach %s und gib folgenden "
"PIN-Code ein:</p>\n"
"\t\t\t"
#: c:\source\oc\server-3.0\htdocs\okapi/views/apps/index.tpl.php:5
msgid "My Apps"
msgstr "Meine Apps"
#: c:\source\oc\server-3.0\htdocs\okapi/views/apps/index.tpl.php:29
msgid "Your external applications"
msgstr "Deine externe Anwendung"
#: c:\source\oc\server-3.0\htdocs\okapi/views/apps/index.tpl.php:31
#, php-format
msgid ""
"\n"
"\t\t\t\t\t<p>This is the list of applications which you granted access to "
"your <b>%s</b> account.\n"
"\t\t\t\t\tThis page gives you the abbility to revoke all previously granted "
"privileges.\n"
"\t\t\t\t\tOnce you click \"remove\" the application will no longer be able "
"to perform any\n"
"\t\t\t\t\tactions on your behalf.</p>\n"
"\t\t\t\t"
msgstr ""
"\n"
"\t\t\t\t\t<p>Dies ist eine Liste der Anwendungen, denen du Zugriff auf dein "
"<b>%s</b>-Benutzerkonto gewährt hast.\n"
"\t\t\t\t\tHier hast du die Möglichkeit, alle bisher vergebenen "
"Zugriffsrechte zu widerrufen.\n"
"\t\t\t\t\tWenn du auf \"entfernen\" klickst, wird die Anwendung keine "
"Aktionen mehr unter deinem \t\t\t\t\tBenutzername ausführen können.</p>\n"
"\t\t\t\t"
#: c:\source\oc\server-3.0\htdocs\okapi/views/apps/index.tpl.php:45
msgid "remove"
msgstr "entfernen"
#: c:\source\oc\server-3.0\htdocs\okapi/views/apps/index.tpl.php:50
#, php-format
msgid ""
"\n"
"\t\t\t\t\t<p>Thanks to the <a href='%s'>OKAPI Framework</a> you can grant "
"external applications\n"
"\t\t\t\t\taccess to your <b>%s</b> account. Currently no applications are "
"authorized to act\n"
"\t\t\t\t\ton your behalf. Once you start using external OpenCaching "
"applications, they will appear here.</p>\n"
"\t\t\t\t"
msgstr ""
"\n"
"\t\t\t\t\t<p>Die <a href='%s'>OKAPI-Schnittstelle</a> ermöglichst es dir, "
"externen Anwendungen\n"
"\t\t\t\t\tZugriff auf dein <b>%s</b>-Benutzerkonto zu geben. Zurzeit sind "
"keine Anwendungen\n"
"\t\t\t\t\tdazu ermächtigt. Sobald du externe Opencaching-Anwendungen "
"aktivierst, werden diese hier erscheinen.</p>\n"
"\t\t\t\t"

View File

@ -8,6 +8,7 @@ class Locales
'pl' => array('lang' => 'pl', 'locale' => 'pl_PL.utf8', 'name' => 'Polish'),
'en' => array('lang' => 'en', 'locale' => 'en_US.utf8', 'name' => 'English'),
'nl' => array('lang' => 'nl', 'locale' => 'nl_NL.utf8', 'name' => 'Dutch'),
'de' => array('lang' => 'de', 'locale' => 'de_DE.utf8', 'name' => 'German'),
);
/**

View File

@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: OKAPI\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-06-14 12:07+0100\n"
"PO-Revision-Date: 2012-06-14 12:07+0100\n"
"POT-Creation-Date: 2012-08-23 10:20+0100\n"
"PO-Revision-Date: 2012-08-23 10:27+0100\n"
"Last-Translator: Wojciech Rygielski <rygielski@mimuw.edu.pl>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@ -17,7 +17,7 @@ msgstr ""
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-SearchPath-0: .\n"
#: services/caches/geocaches.php:634
#: services/caches/geocaches.php:642
msgid "Stage"
msgstr "Etap"
@ -74,56 +74,72 @@ msgstr "Spoilery"
msgid "Image descriptions"
msgstr "Opisy obrazków"
#: services/logs/submit.php:63
#: services/logs/submit.php:62
msgid "You are trying to publish a log entry with a date in future. Cache log entries are allowed to be published in the past, but NOT in the future."
msgstr "Próbujesz opublikować wpis do logbooka używając daty w przyszłości. Wpisy mogą być publikowane z datą w przeszłości, ale NIE w przyszłości."
#: services/logs/submit.php:83
#: services/logs/submit.php:377
msgid "Your cache log entry was posted successfully."
msgstr "Twój wpis do logbooka został opublikowany pomyślnie."
#: services/logs/submit.php:84
#: services/logs/submit.php:82
#, php-format
msgid "However, your cache rating was ignored, because %s does not have a rating system."
msgstr "Niestety Twoja ocena skrzynki nie została zapisana, ponieważ %s nie prowadzi oceny skrzynek."
#: services/logs/submit.php:107
#: services/logs/submit.php:92
msgid "Recommending is allowed only for 'Found it' logtypes."
msgstr "Rekomendacje są dozwolone jedynie z wpisem \"Znaleziona\"."
#: services/logs/submit.php:101
#, php-format
msgid "However, your \"needs maintenance\" flag was ignored, because %s does not support this feature."
msgstr "Niestety, wpis \"potrzebny serwis\" został zignorowany, ponieważ %s nie wspiera tej funkcjonalności."
#: services/logs/submit.php:124
msgid "This cache is archived. Only admins and the owner are allowed to add a log entry."
msgstr "Ta skrzynka jest zarchiwizowana. Jedynie administratorzy oraz właściciel mogą dodawać komentarze."
#: services/logs/submit.php:111
#: services/logs/submit.php:128
msgid "This cache is an Event cache. You cannot \"Find it\"! (But - you may \"Comment\" on it.)"
msgstr "Ta skrzynka jest typu Wydarzenie. Nie możesz jej \"znaleźć\"! (Ale - możesz dodać wpis typu \"Komentarz\".)"
#: services/logs/submit.php:113
#: services/logs/submit.php:130
msgid "Your have to supply some text for your comment."
msgstr "Wpis typu \"Komentarz\" wymaga wpisania komentarza."
#: services/logs/submit.php:126
#: services/logs/submit.php:143
msgid "This cache requires a password. You didn't provide one!"
msgstr "Ta skrzynka wymaga podania hasła. Nie wpisałeś go."
#: services/logs/submit.php:128
#: services/logs/submit.php:145
msgid "Invalid password!"
msgstr "Niepoprawne hasło!"
#: services/logs/submit.php:172
#: services/logs/submit.php:194
msgid "You have already submitted a log entry with exactly the same contents."
msgstr "Już opublikowałeś wcześniej wpis z dokładnie taką samą treścią."
#: services/logs/submit.php:191
#: services/logs/submit.php:213
msgid "You have already submitted a \"Found it\" log entry once. Now you may submit \"Comments\" only!"
msgstr "Już opublikowałeś jeden wpis typu \"Znaleziona\" dla tej skrzynki. Teraz możesz dodawać jedynie \"Komentarze\"!"
#: services/logs/submit.php:193
msgid "You are the owner of this cache. You cannot \"Find it\"."
msgstr "Jesteś właścicielem tej skrzynki. Nie możesz jej \"Znaleźć\"."
#: services/logs/submit.php:215
msgid "You are the owner of this cache. You may submit \"Comments\" only!"
msgstr "Jesteś właścicielem tej skrzynki. Możesz przesyłać jedynie \"Komentarze\"."
#: services/logs/submit.php:211
#: services/logs/submit.php:233
msgid "You have already rated this cache once. Your rating cannot be changed."
msgstr "Już oceniłeś tę skrzynkę. Ocena nie może być zmieniona."
#: services/logs/submit.php:250
msgid "You have already recommended this cache once."
msgstr "Już raz zarekomendowałeś tę skrzynkę."
#: services/logs/submit.php:257
msgid "You don't have any recommendations to give. Find more caches first!"
msgstr "Aktualnie nie możesz wystawić kolejnej rekomendacji. Znajdź najpierw więcej skrzynek!"
#: services/logs/submit.php:409
msgid "Your cache log entry was posted successfully."
msgstr "Twój wpis do logbooka został opublikowany pomyślnie."
#: views/apps/authorize.tpl.php:5
msgid "Authorization Form"
msgstr "Formularz autoryzacyjny"

View File

@ -22,7 +22,7 @@
<li><b>code</b> - unique code of the geocache,</li>
<li><b>name</b> - name of the geocache,</li>
<li><b>names</b> - a dictionary (language code => plain-text string) of
names of the geocache (at this time, there will be only one language,)
names of the geocache (at this time, there will be only one language,
but this may change in future),</li>
<li><b>location</b> - location of the cache in the "lat|lon" format
(<i>lat</i> and <i>lon</i> are in full degrees with a dot as a decimal point),</li>

View File

@ -135,6 +135,7 @@ class WebService
left join stat_caches as sc on c.cache_id = sc.cache_id
where
binary wp_oc in ('".implode("','", array_map('mysql_real_escape_string', $cache_codes))."')
and status in (1,2,3)
");
}
elseif (Settings::get('OC_BRANCH') == 'oc.pl')
@ -161,6 +162,7 @@ class WebService
where
binary wp_oc in ('".implode("','", array_map('mysql_real_escape_string', $cache_codes))."')
and c.user_id = u.user_id
and c.status in (1,2,3)
");
}

View File

@ -112,7 +112,9 @@ class WebService
$rs = Db::query("
select cache_id, wp_oc
from caches
where cache_id in ('".implode("','", array_map('mysql_real_escape_string', $internal_ids))."')
where
cache_id in ('".implode("','", array_map('mysql_real_escape_string', $internal_ids))."')
and status in (1,2,3)
");
$dict = array();
while ($row = mysql_fetch_assoc($rs))
@ -134,7 +136,9 @@ class WebService
$rs = Db::query("
select uuid, wp_oc
from caches
where uuid in ('".implode("','", array_map('mysql_real_escape_string', $uuids))."')
where
uuid in ('".implode("','", array_map('mysql_real_escape_string', $uuids))."')
and status in (1,2,3)
");
$dict = array();
while ($row = mysql_fetch_assoc($rs))

View File

@ -56,6 +56,7 @@ class WebService
and ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "cl.deleted = 0" : "true")."
and cl.user_id = u.user_id
and c.cache_id = cl.cache_id
and c.status in (1,2,3)
");
$results = array();
while ($row = mysql_fetch_assoc($rs))

View File

@ -54,7 +54,7 @@ class WebService
where
cl.user_id = '".mysql_real_escape_string($user['internal_id'])."'
and ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "cl.deleted = 0" : "true")."
and c.status not in (4,5,6)
and c.status in (1,2,3)
and cl.cache_id = c.cache_id
order by cl.date desc
limit $offset, $limit

View File

@ -50,7 +50,7 @@ class ReplicateCommon
*/
private static function get_diff($old, $new)
{
if ($old === null)
if (!$old)
return $new;
$changed_keys = array();
foreach ($new as $key => $value)
@ -82,6 +82,9 @@ class ReplicateCommon
ignore_user_abort(true);
# Get the list of modified cache codes. Split it into groups of N cache codes.
# Note that we should include ALL cache codes in this particular query, not
# only "status in (1,2,3)". This way, when the cache changes its status, e.g.
# from 3 to 6, changelog will include a proper "delete" statement.
$cache_codes = Db::select_column("
select wp_oc
@ -107,7 +110,7 @@ class ReplicateCommon
$log_uuids = Db::select_column("
select uuid
from cache_logs
where last_modified > '".mysql_real_escape_string($last_update)."'
where okapi_syncbase > '".mysql_real_escape_string($last_update)."'
limit $offset, 10000;
");
if (count($log_uuids) == 0)
@ -131,7 +134,7 @@ class ReplicateCommon
$DELETED_uuids = Db::select_column("
select uuid
from cache_logs_archived
where last_modified > '".mysql_real_escape_string($last_update)."'
where okapi_syncbase > '".mysql_real_escape_string($last_update)."'
");
self::generate_changelog_entries('services/logs/entries', 'log', 'log_uuids',
'uuid', $DELETED_uuids, self::$logged_log_entry_fields, false, true, 3600);
@ -179,11 +182,15 @@ class ReplicateCommon
{
if ($object !== null)
{
# Currently, the object exists.
if ($use_cache)
{
$diff = self::get_diff($cached_values['clog#'.$object_type.'#'.$key], $object);
if (count($diff) == 0)
{
# No field has changed since the object was last replaced.
continue;
}
}
$entries[] = array(
'object_type' => $object_type,
@ -192,17 +199,29 @@ class ReplicateCommon
'data' => ($use_cache ? $diff : $object),
);
if ($use_cache)
{
# Save the last-published state of the object, for future comparison.
$cached_values['clog#'.$object_type.'#'.$key] = $object;
}
}
else
{
# Currently, the object does not exist.
if ($use_cache && ($cached_values['clog#'.$object_type.'#'.$key] === false))
{
# No need to delete, we have already published its deletion.
continue;
}
$entries[] = array(
'object_type' => $object_type,
'object_key' => array($key_name => $key),
'change_type' => 'delete',
);
if ($use_cache)
$cached_values['clog#'.$object_type.'#'.$key] = null;
{
# Cache the fact, that the object was deleted.
$cached_values['clog#'.$object_type.'#'.$key] = false;
}
}
}

View File

@ -105,12 +105,15 @@ class WebService
$rs = Db::query("
select
user_id,
found as founds_count,
notfound as notfounds_count,
hidden as hidden_count
from stat_user
where user_id in ('".implode("','", array_map('mysql_real_escape_string', array_keys($id2uuid)))."')
u.user_id,
ifnull(su.found, 0) as founds_count,
ifnull(su.notfound, 0) as notfounds_count,
ifnull(su.hidden, 0) as hidden_count
from
user u
left join stat_user su
on su.user_id = u.user_id
where u.user_id in ('".implode("','", array_map('mysql_real_escape_string', array_keys($id2uuid)))."')
");
}

View File

@ -24,5 +24,6 @@ class OkapiUrls
'^cron5$' => 'cron5',
'^devel/attrlist$' => 'devel/attrlist',
'^devel/dbstruct$' => 'devel/dbstruct',
'^devel/cronreport$' => 'devel/cronreport',
);
}

View File

@ -0,0 +1,79 @@
<?php
namespace okapi\views\devel\cronreport;
use Exception;
use okapi\Okapi;
use okapi\Cache;
use okapi\Db;
use okapi\OkapiRequest;
use okapi\OkapiRedirectResponse;
use okapi\OkapiHttpResponse;
use okapi\ParamMissing;
use okapi\InvalidParam;
use okapi\OkapiServiceRunner;
use okapi\OkapiInternalRequest;
use okapi\cronjobs\CronJobController;
class View
{
public static function call()
{
# This is a hidden page for OKAPI developers. It will output a cronjobs
# report. This is useful for debugging.
$response = new OkapiHttpResponse();
$response->content_type = "text/plain; charset=utf-8";
ob_start();
require_once 'cronjobs.php';
$schedule = Cache::get("cron_schedule");
if ($schedule == null)
$schedule = array();
print "Nearest event: ";
if (Okapi::get_var('cron_nearest_event'))
print "in ".(Okapi::get_var('cron_nearest_event') - time())." seconds.\n\n";
else
print "NOT SET\n\n";
$cronjobs = CronJobController::get_enabled_cronjobs();
usort($cronjobs, function($a, $b) {
$cmp = function($a, $b) { return ($a < $b) ? -1 : (($a > $b) ? 1 : 0); };
$by_type = $cmp($a->get_type(), $b->get_type());
if ($by_type != 0)
return $by_type;
return $cmp($a->get_name(), $b->get_name());
});
print str_pad("TYPE", 11)." ".str_pad("NAME", 35)." SCHEDULE\n";
print str_pad("----", 11)." ".str_pad("----", 35)." --------\n";
foreach ($cronjobs as $cronjob)
{
$type = $cronjob->get_type();
$name = $cronjob->get_name();
print str_pad($type, 11)." ".str_pad($name, 35)." ";
if (!isset($schedule[$name]))
print "NOT YET SCHEDULED\n";
elseif ($schedule[$name] <= time())
print "PAST: should be run ".(time() - $schedule[$name])." seconds ago\n";
else
print "scheduled to run in ".str_pad($schedule[$name] - time(), 6, " ", STR_PAD_LEFT)." seconds\n";
}
print "\n";
print "Crontab last ping: ";
if (Cache::get('crontab_last_ping'))
print (time() - Cache::get('crontab_last_ping'))." seconds ago";
else
print "NEVER";
print " (crontab_check_counter: ".Cache::get('crontab_check_counter').").\n";
print "clog_revisions_daily: ";
if (Cache::get('clog_revisions_daily'))
{
foreach (Cache::get('clog_revisions_daily') as $time => $rev)
print "$rev ";
print "\n";
} else {
print "NULL\n";
}
$response->body = ob_get_clean();
return $response;
}
}

View File

@ -139,7 +139,7 @@ class View
print "please contact me - rygielski@mimuw.edu.pl.\n\n";
print "-- \n";
print "Wojciech Rygielski, OKAPI developer";
Okapi::mail_admins("Database modification notice: cache_logs.last_modified", ob_get_clean());
Okapi::mail_admins("Starting OKAPI installation", ob_get_clean());
Db::execute("
CREATE TABLE okapi_vars (
@ -416,34 +416,117 @@ class View
private static function ver51()
{
Db::execute("alter table cache_logs modify column last_modified timestamp not null;");
ob_start();
print "Hi!\n\n";
print "OKAPI just modified 'last_modified' field in your 'cache_logs' table.\n";
print "Its type was changed to 'timestamp'. It is required by OKAPI's 'replicate'\n";
print "module to function properly.\n\n";
self::print_common_db_alteration_info();
print "-- \n";
print "OKAPI Team";
Okapi::mail_admins("Database modification notice: cache_logs.last_modified", ob_get_clean());
# Before revision 417, OKAPI used to make the following change:
# - Db::execute("alter table cache_logs modify column last_modified timestamp not null;");
# It doesn't do that anymore. Instead, it adds a separate column for itself (okapi_syncbase).
}
private static function ver52()
{
# Before revision 417, OKAPI used to make the following change (on OCDE branch):
# - Db::execute("alter table cache_logs_archived modify column last_modified timestamp not null;");
# It doesn't do that anymore. Instead, it adds a separate column for itself (okapi_syncbase).
}
private static function ver53() { Db::execute("alter table cache_logs add column okapi_syncbase timestamp not null after last_modified;"); }
private static function ver54() { Db::execute("update cache_logs set okapi_syncbase=last_modified;"); }
private static function ver55()
{
if (Settings::get('OC_BRANCH') == 'oc.pl')
{
# OCPL does not have cache_logs_archived table.
return;
}
Db::execute("alter table cache_logs_archived modify column last_modified timestamp not null;");
Db::execute("alter table cache_logs_archived add column okapi_syncbase timestamp not null after last_modified;");
}
private static function ver56()
{
if (Settings::get('OC_BRANCH') == 'oc.pl')
{
# OCPL does not have cache_logs_archived table.
return;
}
Db::execute("update cache_logs_archived set okapi_syncbase=last_modified;");
}
private static function ver57()
{
ob_start();
print "Hi!\n\n";
print "OKAPI just modified 'last_modified' field in your 'cache_logs_archived' table.\n";
print "Its type was changed to 'timestamp'. It is required by OKAPI's 'replicate'\n";
print "module to function properly.\n\n";
print "OKAPI just added additional field (along with an index) 'okapi_syncbase'\n";
print "on your 'cache_logs' AND 'cache_logs_archived' tables. It is required by\n";
print "OKAPI's 'replicate' module to function properly.\n\n";
self::print_common_db_alteration_info();
print "-- \n";
print "OKAPI Team";
Okapi::mail_admins("Database modification notice: cache_logs_archived.last_modified", ob_get_clean());
Okapi::mail_admins("Database modification notice: caches.okapi_syncbase", ob_get_clean());
}
private static function ver58()
{
#
# Starting with revision 417, OKAPI hides all caches with statuses > 3.
# Hence, we need such caches to be removed from external databases replicated
# via the "replicate" module. By reseting the "okapi_syncbase" timestamp,
# we force changelog generator cronjob to issue proper "delete" statements
# to the changelog.
#
Db::execute("
update caches
set okapi_syncbase = now()
where status > 3
");
}
private static function ver59()
{
# As above.
Db::execute("
update
cache_logs cl,
caches c
set cl.okapi_syncbase = now()
where
cl.cache_id = c.cache_id
and c.status > 3
");
}
private static function ver60()
{
# Turns out there can be only one valid TIMESTAMP field in one table!
# Fields added ver53-ver59 don't work properly *if* ver51-ver52 had been run.
#
# We'll check if ver51-ver52 had been run and try to withdraw it AND
# *rerun* missing ver53-ver59 updates.
#
$row = Db::select_row("show create table cache_logs");
$stmt = $row["Create Table"];
if (strpos($stmt, "timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'") > 0)
{
Db::execute("alter table cache_logs modify column last_modified datetime not null;");
Db::execute("alter table cache_logs modify column okapi_syncbase timestamp not null;");
Db::execute("update cache_logs set okapi_syncbase=now() where okapi_syncbase='0000-00-00 00:00:00';");
if (Settings::get('OC_BRANCH') == 'oc.de')
{
Db::execute("alter table cache_logs_archived modify column last_modified datetime not null;");
Db::execute("alter table cache_logs_archived modify column okapi_syncbase timestamp not null;");
Db::execute("update cache_logs_archived set okapi_syncbase=now() where okapi_syncbase='0000-00-00 00:00:00';");
}
}
}
private static function ver61() { Db::execute("alter table cache_logs add key okapi_syncbase (okapi_syncbase);"); }
private static function ver62()
{
if (Settings::get('OC_BRANCH') == 'oc.pl')
{
# OCPL does not have cache_logs_archived table.
return;
}
Db::execute("alter table cache_logs_archived add key okapi_syncbase (okapi_syncbase);");
}
}