...
 
Commits (43)
  • Luke081515's avatar
    Bump version to v2.2 alpha · ba58d8a6
    Luke081515 authored
    Summary: * v2.1 ist jetzt in der Beta vorhanden, alle weiter Commits kommen jetzt in v2.2, sofern sie nicht per cherry-pick auch in 2.1 eingeschlossen werden
    
    Reviewers: O1 Luke081515Bot, MGChecker, Luke
    
    Reviewed By: O1 Luke081515Bot, Luke
    
    Subscribers: MGChecker
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D421
    ba58d8a6
  • MGChecker's avatar
    Vorbereitung auf neue Einstellungsarchitektur · 14397fec
    MGChecker authored
    Summary:
    * settings.json und dbsettings.json als zukünftige Einstelluingsdateien hinzugefügt
    * Password.php und DBPassword.php verbleiben fürs Erste, um versehentliches Hcochladen von Passwörtern in der Umstellungszeit zu verhindern
    * Ermöglicht, völlig unabhängig Patches für BotCore und DBCore parallel zu entwickeln
    
    Reviewers: Luke, O1 Luke081515Bot
    
    Reviewed By: Luke, O1 Luke081515Bot
    
    Subscribers: Luke, Morten_Haan
    
    Differential Revision: https://rcm-2.wmflabs.org/D417
    14397fec
  • Luke081515's avatar
    Behebe Formatierungsprobleme · fbc46e96
    Luke081515 authored
    Summary: * Formatierung mit Leerzeichen durch Tabs ersetzt
    
    Reviewers: O1 Luke081515Bot, MGChecker
    
    Reviewed By: O1 Luke081515Bot, MGChecker
    
    Subscribers: MGChecker
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D424
    fbc46e96
  • Luke081515's avatar
    Add deletePage() · f04868fe
    Luke081515 authored
    Summary:
    * Methode um Seiten zu löschen
    * Seitenname und Grund als Parameter anwählbar
    * Gibt success oder den Fehlercode der API zurück
    * Basierend auf JSON
    * Basiert auf MassDeletion.php aus dem Luke081515Bot
    Fixes T884
    
    Reviewers: O1 Luke081515Bot, MGChecker, Morten_Haan
    
    Reviewed By: O1 Luke081515Bot, MGChecker, Morten_Haan
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Maniphest Tasks: T884
    
    Differential Revision: https://rcm-2.wmflabs.org/D425
    f04868fe
  • Luke081515's avatar
    Add blockUser() · b5ef40a8
    Luke081515 authored
    Summary:
    * Adds a function to block users
    * Blocking and reblocking is supported
    * All API-Params are supported and need to be set
    Fixes T885
    Depends on D425
    
    Reviewers: O1 Luke081515Bot, MGChecker, Morten_Haan
    
    Reviewed By: O1 Luke081515Bot, MGChecker, Morten_Haan
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Maniphest Tasks: T885
    
    Differential Revision: https://rcm-2.wmflabs.org/D428
    b5ef40a8
  • Luke081515's avatar
    Add unblockUser() · 1cf7980f
    Luke081515 authored
    Summary:
    * Adds a function for unblocking a user
    * Unblocking using the username is supported
    Fixes T894
    Depends on D428
    
    Reviewers: O1 Luke081515Bot, MGChecker, Morten_Haan
    
    Reviewed By: O1 Luke081515Bot, MGChecker, Morten_Haan
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Maniphest Tasks: T894
    
    Differential Revision: https://rcm-2.wmflabs.org/D429
    1cf7980f
  • Luke081515's avatar
    Add protectPage() · 2d970860
    Luke081515 authored
    Summary:
    * Supports protecting a page, or modifying the protection
    * Fixed two comments from D429
    Fixes T886
    Depends on D429
    
    Reviewers: O1 Luke081515Bot, MGChecker, Morten_Haan
    
    Reviewed By: O1 Luke081515Bot, MGChecker, Morten_Haan
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Maniphest Tasks: T886
    
    Differential Revision: https://rcm-2.wmflabs.org/D430
    2d970860
  • MGChecker's avatar
    DBCore neugeschrieben · c277ab19
    MGChecker authored
    Summary:
    * Entsprechend des gewöhnlichen Verfahrens wird pro Query eine Connection geöffnet
    * Analyse des Ergebnisses eines Querys direkt in DBCore.php
    * Einlesen der DB-Einstellungen parallel zu BotCore.php
    * Kürzerer Name für real_escape_string (jetzt escape)
    * Ausgelagerte Funktion connect zur Verbindung zur Datenbank
    * Dokumentation hinzugefügt
    
    Ref T869
    
    Reviewers: Luke, O1 Luke081515Bot, Morten_Haan
    
    Reviewed By: Luke, O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Luke, Morten_Haan
    
    Tags: #cygnus
    
    Maniphest Tasks: T869
    
    Differential Revision: https://rcm-2.wmflabs.org/D423
    c277ab19
  • MGChecker's avatar
    Umstellung der Klassenarchitektur und der Einstellungen auf JSON · 1f070179
    MGChecker authored
    Summary:
    Klassenarchitektur
    * Sichtbarkeit der Klassenattribute eingeschränkt, teilweise durch Getter und Setter weiterhin zugänglich gemacht
    * Statische Funktionen als solche markiert
    * Sichtbarkeit von httpRequest erweitert, das im Rahmen von MultiCore instanziert benötigt werden wird
    * Sichtbarkeit von login eingeschränkt, da es nur von initCurl aufgerufen werden soll
    * Finalisierung der beiden zentralen Funktionen httpRequest und initcurl, um Überschreiben zu verhindern
    * __construct als Alias zu initcurl für spätere Instanzierung im Rahmen von MultiCore
    
    Einstellungen via JSON
    * Einstellungen werden nun aus einem besser lesbaren JSON-File extrahiert, was neben den Login-Daten auch weitere Daten enthält, weswegen einige Parameter hinsichtlich https usw. entfallen
    * E-Mail jetzt nicht mehr per Account, sondern per Cygnus-Framework global
    * Kein Zwang, so die Benutzerdaten einzulesen, Kindklassen können andere Methoden verwenden
    
    Entfernen obsoleter Funktionen
    * addMail und sendMail erfüllen keinen Mehrwert gegenüber der internen Funktion mail()
    * initCurlArgs ist eine Funktion, die den Standards von Cygnus nicht mehr entspricht
    * setSite, setUsername, setPassword sind obsolet
    
    Sonstiges
    * Rückgabewerte von serialisierten Arrays auf direkt weiter verarbeitbare Arrays umgestellt (Ausnahme movePage)
    * Funktionen, die entweder einen bestimmten Wert (String, Array, Integer) oder den boolschen Wert false zurückgeben stattdessen auf null umgestellt, da dieser Wert intuitiver ist und die Kompatibilität mit PHP 7.1 erhöht
    * Kleinere Korrekturen
    
    Ref T823, T841, T872, T875
    
    Reviewers: Luke, O1 Luke081515Bot, Morten_Haan
    
    Reviewed By: Luke, O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Luke, Morten_Haan
    
    Tags: #cygnus
    
    Maniphest Tasks: T875, T872, T841, T823
    
    Differential Revision: https://rcm-2.wmflabs.org/D422
    1f070179
  • Luke081515's avatar
    Verbesserung von Fehlerbehandlung und Tokengenerierung · 6b57ce79
    Luke081515 authored
    Summary:
    * Ermitteln von Tokens in eigene Methode requireToken ausgelagert, die später im Sinne von T813 aufgerüstet werden kann
    * httpRequest versucht im Fehlerfall nun 3 Minuten lang, eine Verbindung zum Server aufzubauen. Dadurch sollen kurzzeitige Serverausfälle abgefangen werden
    * Unsinnige try-catch-Anweisungen und überflüssige else entfernt
    * Gedankenstriche durch unproblematische Minus ausgetauscht
    * requires extensions gefixt
    
    Ref T882, T888, T895
    Depends on D422
    
    Reviewers: O1 Luke081515Bot, Morten_Haan, MGChecker, Luke
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan, Luke
    
    Subscribers: Luke, Morten_Haan
    
    Tags: #cygnus
    
    Maniphest Tasks: T895, T888, T882
    
    Differential Revision: https://rcm-2.wmflabs.org/D432
    6b57ce79
  • Luke081515's avatar
    Fix typo · 465b5959
    Luke081515 authored
    Summary: * wuth => with
    
    Reviewers: O1 Luke081515Bot, Morten_Haan
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D441
    465b5959
  • Luke081515's avatar
    Fix typo at requireToken() · dbeb6874
    Luke081515 authored
    Summary: * If the requests fails, it is not always an login token who could not get requested.
    
    Reviewers: O1 Luke081515Bot, Morten_Haan
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D442
    dbeb6874
  • Luke081515's avatar
    Use requireToken() at all places · db856d76
    Luke081515 authored
    Summary: * Replaced the long versions of get token with the designated method
    
    Reviewers: O1 Luke081515Bot, Morten_Haan
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D438
    db856d76
  • Luke081515's avatar
    Fix params · c9e2b1a2
    Luke081515 authored
    Summary: * Per coding definition, variables should start with lowercase-letters.
    
    Reviewers: O1 Luke081515Bot, Morten_Haan, Doc_Taxon
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan, Doc_Taxon
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D444
    c9e2b1a2
  • Luke081515's avatar
    Allow to configure maxlag globally · 52dffb54
    Luke081515 authored
    Summary:
    * Maxlag should be used, the default value is set to 5, this is recommended
    * Maxlag was added to all functions performing write actions
    * Maxlag will get added to all remaining methods in a follow-up
    * Three functions are still using &maxlag=5, this will get replaced by a patch replacing this my $this->requireToken()
    
    Reviewers: O1 Luke081515Bot, Morten_Haan, MGChecker
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan, MGChecker
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D439
    52dffb54
  • Luke081515's avatar
    Use maxlag at all places · fe07547b
    Luke081515 authored
    Summary:
    * Uses maxlag at all API requests, except at three places, these are handeled by D438
    Depends on D439
    
    Reviewers: O1 Luke081515Bot, Morten_Haan, Freddy2001, MGChecker
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan, Freddy2001, MGChecker
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D440
    fe07547b
  • Luke081515's avatar
    Add getMWVersion() · f72d5772
    Luke081515 authored
    Summary:
    * Retuns the current used mediawiki-version as String.
    Ref T906
    
    Reviewers: O1 Luke081515Bot, Morten_Haan, MGChecker
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan, MGChecker
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Maniphest Tasks: T906
    
    Differential Revision: https://rcm-2.wmflabs.org/D436
    f72d5772
  • MGChecker's avatar
    initcurl nur noch einmal ausführbar · 40f3ecb9
    MGChecker authored
    Summary:
    * Ob initcurl bereits ausgeführt wurde wird nun überprüft
    * allowBots und getVersion gefixt
    
    Ref T899, T908
    
    Reviewers: Luke, O1 Luke081515Bot, Freddy2001, Morten_Haan
    
    Reviewed By: Luke, O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Luke, Morten_Haan
    
    Tags: #cygnus
    
    Maniphest Tasks: T908, T899
    
    Differential Revision: https://rcm-2.wmflabs.org/D446
    40f3ecb9
  • Luke081515's avatar
    movePage: Check if the API returns an error · ad5ea1fe
    Luke081515 authored
    Summary:
    * The function checks now, if the API call was successful, or returned an error-code.
    Ref T880
    
    Reviewers: O1 Luke081515Bot, Morten_Haan, Doc_Taxon, MGChecker
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan, Doc_Taxon, MGChecker
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Maniphest Tasks: T880
    
    Differential Revision: https://rcm-2.wmflabs.org/D445
    ad5ea1fe
  • Luke081515's avatar
    Add review() · a3875935
    Luke081515 authored
    Summary:
    * Allows to review a revision
    * Since configured without depth, works only on dewiki like configured wikis
    * Allows to provide a comment or to unapprove
    Ref T910
    
    Reviewers: O1 Luke081515Bot, Morten_Haan, MGChecker
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan, MGChecker
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Maniphest Tasks: T910
    
    Differential Revision: https://rcm-2.wmflabs.org/D443
    a3875935
  • Luke081515's avatar
    Fix: json decode · 658962b1
    Luke081515 authored
    Summary: * Added missing json decode
    
    Reviewers: O1 Luke081515Bot, MGChecker
    
    Reviewed By: O1 Luke081515Bot, MGChecker
    
    Subscribers: MGChecker
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D451
    658962b1
  • MGChecker's avatar
    apiRetry eingeführt · d4e8b0d4
    MGChecker authored
    Summary:
    * gemeinsame Funktion apiRetry für die Fehlerbehandlung von Api-Antworten, zunächst nur an zwei Funktion demonstriert
    ** editPageEngine als Hauptfunktion
    ** login, da sich sonst die Schleifen multiplizieren können
    * nach 18 mal retry wird die Schleife unterbrochen, frei konfigurierbar
    ** stellt sicher, dass Serverausfälle von bis zu 3 Minuten Länge abgefangen werden
    * Fehlercodes eingepflegt; checkResult überarbeitet
    * Exceptionhandling: Wo unklar, woher der Fehler kommt, nicht nur Nachricht, sondern auch ursprünglichen Backtrace angehängt.
    * Requirements ergänzt: Ohne Curl läuft gar nichts; Array-Kurzsyntax und Lambda-Funcktionen wollen PHP 5.4
    
    Ref T887, T889
    
    Reviewers: Luke, Freddy2001, Morten_Haan, O1 Luke081515Bot
    
    Reviewed By: Luke, Morten_Haan, O1 Luke081515Bot
    
    Subscribers: Luke, Morten_Haan
    
    Tags: #cygnus
    
    Maniphest Tasks: T889, T887
    
    Differential Revision: https://rcm-2.wmflabs.org/D447
    d4e8b0d4
  • Luke081515's avatar
    Cleanup: Break · ee4a63ce
    Luke081515 authored
    Summary: * Replace break1; through break;
    
    Reviewers: O1 Luke081515Bot, Morten_Haan, MGChecker
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan, MGChecker
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D452
    ee4a63ce
  • MGChecker's avatar
    Dokumentiere Typen in DBCore · 33cd9b10
    MGChecker authored
    Summary:
    * Ergänze Parameterdeklarationen in der Doku
    * Ergänze Rückgabewertdeklarationen an der Stelle (noch als Kommentare), wo sie auch in PHP 7 zu finden sein werden
    
    Ref T897
    
    Reviewers: Luke, O1 Luke081515Bot, Morten_Haan, Freddy2001
    
    Reviewed By: Luke, O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Freddy2001, Luke, Morten_Haan
    
    Tags: #cygnus
    
    Maniphest Tasks: T897
    
    Differential Revision: https://rcm-2.wmflabs.org/D434
    33cd9b10
  • MGChecker's avatar
    Ermögliche API-Requests mit Arrays · 9a01a59e
    MGChecker authored
    Summary:
    * httpRequest kann jetzt Strings und Arrays verarbeiten
    * Standardwerte für maxlag und assert, da globale Variablen
    * Standardwerte für action und format, da praktisch und analog zum Verhalten von JavaScript
    * Doku von httpRequest übersetzt
    * neue Methode an read* demonstriert
    
    Reviewers: O1 Luke081515Bot, Freddy2001, Morten_Haan, Luke
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan, Luke
    
    Subscribers: Luke, Morten_Haan
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D448
    9a01a59e
  • Luke081515's avatar
    Add stabilize() · 26c26074
    Luke081515 authored
    Summary:
    * Allows to change the settings of a page concerning which version gets shown, or who is allowed to review
    Ref T911
    
    Reviewers: O1 Luke081515Bot, Morten_Haan, MGChecker
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan, MGChecker
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Maniphest Tasks: T911
    
    Differential Revision: https://rcm-2.wmflabs.org/D437
    26c26074
  • Luke081515's avatar
    Cleanup: Doku · de02f76a
    Luke081515 authored
    Summary: * Einheitliches Format benutzt
    
    Reviewers: O1 Luke081515Bot, MGChecker, Morten_Haan
    
    Reviewed By: O1 Luke081515Bot, MGChecker, Morten_Haan
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D450
    de02f76a
  • Luke081515's avatar
    Add getLinksToPage() · 6d70b782
    Luke081515 authored
    Summary:
    * Returns all links who are pointing to a page
    * Allows to show only redirects, non-redirects or both
    * You can get a list with only specific namespaces
    Fixes T902
    
    Reviewers: O1 Luke081515Bot, MGChecker, Morten_Haan, Doc_Taxon
    
    Reviewed By: O1 Luke081515Bot, MGChecker, Morten_Haan, Doc_Taxon
    
    Subscribers: Doc_Taxon, Morten_Haan, Freddy2001, MGChecker
    
    Tags: #cygnus
    
    Maniphest Tasks: T902
    
    Differential Revision: https://rcm-2.wmflabs.org/D435
    6d70b782
  • MGChecker's avatar
    Cleanup: Funktionen, Anführungszeichen · 320a0841
    MGChecker authored
    Summary:
    * Einfache Anführungszeichen im Code
    * Finalisierung und Zugriffsselektoren besser verteilt
    * [Breaking Change] Parameter $job wegen Sinnlosigkeit aus httpRequest entfernt
    
    Reviewers: Luke, O1 Luke081515Bot, Freddy2001, Morten_Haan
    
    Reviewed By: Luke, O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Luke, Morten_Haan
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D453
    320a0841
  • MGChecker's avatar
    Cleanup: Funktionen sortiert · 8fd5857e
    MGChecker authored
    Summary:
    * Funktionen in verschiedene Kategorien sortiert
    * Konstruktor dokumentiert, weiteres blocked by D449
    
    Reviewers: Luke, O1 Luke081515Bot, Freddy2001, Morten_Haan
    
    Reviewed By: Luke, O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Luke, Morten_Haan
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D454
    8fd5857e
  • MGChecker's avatar
    initCurl auf Mehrmethodik umgestellt · 21c6e080
    MGChecker authored
    Summary:
    * loadSettings durch ?String-Parameter ersetzt
    * Erlaubt verschiedene Möglichkeiten zur Eingabe der Logindaten (Bisher cli und settings)
    * Alternativ auch null als Parameterwert möglich, um anderweitig Logindaten einzugeben
    
    Reviewers: O1 Luke081515Bot, Freddy2001, Morten_Haan, Luke
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan, Luke
    
    Subscribers: Luke, Morten_Haan
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D449
    21c6e080
  • Luke081515's avatar
    add ParseWikilinks() · 09d9bc62
    Luke081515 authored
    Summary:
    * Parses WikiLinks
    * Allows to normalize links
    Ref T914
    
    Reviewers: O1 Luke081515Bot, Morten_Haan, Freddy2001, MGChecker
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan, MGChecker
    
    Subscribers: MGChecker
    
    Tags: #cygnus
    
    Maniphest Tasks: T914
    
    Differential Revision: https://rcm-2.wmflabs.org/D455
    09d9bc62
  • MGChecker's avatar
    apiRetry überarbeitet · ea7f166a
    MGChecker authored
    Summary:
    * Keine callables mehr, apiRetry kann den Request jetzt direkt verarbeiten
    * editPageEngine, login und requireToken auf neuen apiRetry-Mechanismus angepasst
    * 2 neue Funktionen, apiRetryGet und apiRetryPostWithToken, quasi httpRequest++
    * Depreaction-Mechanismus, der nicht überlistet werden kann, eingebaut
    * Um httpRequest eine Existenzberechtigung zu geben, $path eingebaut
    
    Ref T887, T896, T916
    
    Reviewers: Luke, O1 Luke081515Bot, Freddy2001, Morten_Haan
    
    Reviewed By: Luke, O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Luke, Morten_Haan
    
    Tags: #cygnus
    
    Maniphest Tasks: T916, T896, T887
    
    Differential Revision: https://rcm-2.wmflabs.org/D456
    ea7f166a
  • Luke081515's avatar
    Make the params of initCurl usable · 1a3342d8
    Luke081515 authored
    Summary: * Makes them available by inserting them into the constructor
    
    Reviewers: O1 Luke081515Bot, Morten_Haan, MGChecker
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan, MGChecker
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D458
    1a3342d8
  • MGChecker's avatar
    Post-Anfragen auf apiRetryPostWithToken umgestellt · 5e6d3c92
    MGChecker authored
    Summary:
    * Umstellung vorgenommen
    * Fehler korrigiert, die auf dem Weg aufgefallen sind
    * Dokumentation der betroffenen Funktionen an neue Richtlinien angepasst
    
    Ref T897, T896, T916
    
    Reviewers: Luke, O1 Luke081515Bot, Freddy2001, Morten_Haan
    
    Reviewed By: Luke, O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Luke, Morten_Haan
    
    Tags: #cygnus
    
    Maniphest Tasks: T916, T897, T896
    
    Differential Revision: https://rcm-2.wmflabs.org/D457
    5e6d3c92
  • MGChecker's avatar
    apiGet eingeführt · 888826aa
    MGChecker authored
    Summary:
    apiGet eingeführt
    
    * Abfrageformat aller Funktionen außer getCatMembers auf array umgestellt
    * Dokumentation aller Funktionen außer getCatMembers umgestellt und übersetzt
    ** alle außer diese und edit*  ans aktuelle Format angepasst
    * Formatabweichungen normalisiert
    * Bugfixes:
    ** debug_print_backtrace kann nicht in einer echo-Anweisung stehen
    ** liegengebliebene $this->job entfernt
    
    Ref T933,  T897, T605, T896
    
    Reviewers: Luke, O1 Luke081515Bot, Freddy2001, Morten_Haan
    
    Reviewed By: Luke, O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Luke, Morten_Haan
    
    Tags: #cygnus
    
    Maniphest Tasks: T933, T897, T896, T605
    
    Differential Revision: https://rcm-2.wmflabs.org/D459
    888826aa
  • Luke081515's avatar
    Add support for GitLab CI · f7d2200d
    Luke081515 authored
    Summary:
    * Phabricator creates a mirror of Cygnus at GitLab
    * GitLab can run different checks against Cygnus
    * Configured php-lint for PHP 5.4, PHP 5.6 and PHP 7.0
    * We make sure that all PHP versions are still working
    
    Reviewers: O1 Luke081515Bot, Morten_Haan
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D464
    f7d2200d
  • Luke081515's avatar
    YAML fix · d7f78b42
    Luke081515 authored
    Reviewers: O1 Luke081515Bot, Morten_Haan
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D465
    d7f78b42
  • MGChecker's avatar
    Fehlerkorrekturen und Vorbereitungen für objektorientierten Ansatz · 3fda3a52
    MGChecker authored
    Summary:
    * provisorische gemeinsame Klasse für gemeinsames Verhalten aller Skripte
    * Namespaces eingeführt
    * Invaliden Whitespace entfernt
    * BotCore
    ** Letzte Übersetzungen vorgenommen
    ** Diverse Fehler korrigiert
    
    Depends on D459
    Ref T938, T605
    
    Reviewers: Luke, O1 Luke081515Bot, Freddy2001, Morten_Haan
    
    Reviewed By: Luke, O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Hgzh, Luke, Morten_Haan
    
    Tags: #cygnus
    
    Maniphest Tasks: T932, T605, T938
    
    Differential Revision: https://rcm-2.wmflabs.org/D461
    3fda3a52
  • Luke081515's avatar
    Rename getAllEmbeddings · 7542ab65
    Luke081515 authored
    Summary:
    * Renamed to the correct spelling
    * Added a note that the method needs a rename
    * Added to changelog.
    Ref T934
    
    Reviewers: O1 Luke081515Bot, Morten_Haan
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Maniphest Tasks: T934
    
    Differential Revision: https://rcm-2.wmflabs.org/D463
    7542ab65
  • Luke081515's avatar
    Add phpcs to CI · b3fff288
    Luke081515 authored
    Summary:
    * Added phpcs support
    * Applied phpcbf to BotCore and CygUtiliy
    * Fix remaining phpcs errors
    Ref T862
    
    Reviewers: O1 Luke081515Bot, Morten_Haan
    
    Reviewed By: O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Maniphest Tasks: T862
    
    Differential Revision: https://rcm-2.wmflabs.org/D467
    b3fff288
  • MGChecker's avatar
    Bugfixes · e1751753
    MGChecker authored
    Summary:
    * readSection, apiRetryEngine gefixt
    * Zur Vorbereitung auf Dependency Imncetion Abschnitt füt Object properties eingeführt
    * Das hätte auch ein Task getan
    
    Fixes T970, T971
    
    Introduced apiResult
    
    Reviewers: Luke, O1 Luke081515Bot, Freddy2001, Morten_Haan
    
    Reviewed By: Luke, O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Luke, Morten_Haan
    
    Tags: #cygnus
    
    Maniphest Tasks: T971, T970
    
    Differential Revision: https://rcm-2.wmflabs.org/D468
    e1751753
  • Freddy's avatar
    typo in BotCore.php · c0984200
    Freddy authored
    Summary: Fixed a typo in BotCore.php
    
    Reviewers: Luke, O1 Luke081515Bot, MGChecker, Morten_Haan
    
    Reviewed By: Luke, O1 Luke081515Bot, Morten_Haan
    
    Subscribers: Luke, Morten_Haan, MGChecker
    
    Tags: #cygnus
    
    Differential Revision: https://rcm-2.wmflabs.org/D477
    c0984200
settings.json
dbsettings.json
Password.php
DBPassword.php
stages:
- lint
- codesniffer
lint:lint-php5.4:
stage: lint
image: php:5.4
before_script:
- bash ci/docker_install.sh > /dev/null
script:
- bash ci/phplint.sh ./
lint:lint-php5.6:
stage: lint
image: php:5.6
before_script:
- bash ci/docker_install.sh > /dev/null
script:
- bash ci/phplint.sh ./
lint:lint-php7.0:
stage: lint
image: php:7.0
before_script:
- bash ci/docker_install.sh > /dev/null
script:
- bash ci/phplint.sh ./
codesniffer:
stage: codesniffer
image: php:5.6
before_script:
- bash ci/docker_install.sh > /dev/null
script:
- bash ci/phpcs.sh
This diff is collapsed.
Changelog for Cygnus V2.2
# New features
# Bugfixes
# Upgrading instructions
`getAllEmbedings()` was misspelled, and was renamed to `getAllEmbeddings()`. Please rename the method at your code, params etc did not changed.
<?php
/** CygUtility.php
* base file of Cygnus
* defines functions important for the functionality of every single file
* can't be instantiated directly because that wouldn't make any sense.
* don't rely on this file in your own code
* it's just a workaround during migration to a more object-oriented approach
* only the autoloader will remain here
*/
namespace Cygnus;
spl_autoload_register('CygUtility::classLoader');
class CygUitility {
/** classLoader
* loads needed classes into BotCore automaticly
* note it follows the PSR-4 standard
* with the exception it also takes files with .beta before filename ending
* @author MGChecker
* @param $class - the class (including namespace prefix) you're trying to load
* @returns void
*/
public static function classLoader($class) {
$path = __DIR__ . '/';
$filename = $path . str_replace('\\', '/', $class);
if (file_exists($filename . '.php')) {
include $filename . '.php';
} else {
$filename .= $class . 'beta.php';
if (file_exists($filename)) {
echo 'Class ' . $class . ' is in beta status. It might not work as expected.';
include $filename;
} else
throw new \Exception('Required class ' . $class . ' couldn\'t be loaded.');
}
}
/** loadJson
* loads json files with given filename relative to the Cygnus base folder
* @author MGChecker
* @param string $filename [optional: 'settings.json'] - The filepath you want to load
* @returns void
*/
public static function loadJson($filename = 'settings.json') {
try {
$json = json_decode(file_get_contents(__DIR__ . '/' . $filename), true);
return $json;
} catch (\Exception $e) {
throw new \Exception($filename . ' file doesn\'t exist: ' . $e->getMessage());
}
if (json_last_error() !== JSON_ERROR_NONE)
throw new \Exception($filename . 'isn\'t properly formated: ' . json_last_error_msg());
}
/** printWarning
* echos a warning with a stacktrace
* @param string $msg [optional: ''] - the message of the warning
* @author MGChecker
*/
public static function printWarning($msg = '') {
echo '\n' . $msg . '\nStack trace:\n';
debug_print_backtrace();
}
}
<?php
include "DBPassword.php";
class DBCore extends DBPassword {
protected $DBusername;
protected $DBpassword;
protected $database;
protected $DB;
/** DBCore.php
* Allows querying of databases using mysqli
* @author Freddy2001 <freddy2001@wikipedia.de>, Luke081515 <luke081515@tools.wmflabs.org>, MGChecker <hgasuser@gmail.com>
*/
namespace Cygnus;
//TODO Write documentation
function __construct($Accountdata, $Database) {
$a=0;
$Found = false;
$this->init();
$LoginName = unserialize($this->getLoginName ());
$LoginAccount = unserialize($this->getLoginAccount());
$LoginDBpassword = unserialize($this->getLoginDBpassword());
$LoginHost = unserialize($this->getLoginHost());
while (isset($LoginName [$a]) === true) {
if ($LoginName [$a] === $Accountdata) {
$this->DBusername = $LoginAccount [$a];
$this->DBpassword = $LoginDBpassword [$a];
$this->LoginHost = $LoginHost [$a];
$Found = true;
}
$a++;
}
if (!$Found) {
throw new Exception('Keine passenden DB-Anmeldeinformationen vorhanden.');
die(1); // exit with error
class DBCore {
private $dbHost;
private $dbUsername;
private $dbPassword;
private $dbName;
/** __construct
* Reads authentification data from dbsettings.json
* @author MGChecker
* @param string $account - name of account in dbsettings.json
* @param string $database - name of database
*/
public function __construct($account, $database) {
try {
$accData = json_decode(file_get_contents('./dbsettings.json'), true);
$this->dbHost = $accData['accounts'][$account]['pwd'];
$this->dbUsername = $accData['accounts'][$account]['user'];
$this->dbPassword = $accData['accounts'][$account]['pwd'];
$this->dbName = $database;
} catch (\Exception $e) {
throw new \Exception('Error: No proper database login information given: ' . $e->getMessage());
}
$this->DB = new mysqli($this->LoginHost, $this->DBusername, $this->DBpassword, $Database);
if ($this->DB->connect_errno) {
echo "Error: Failed to make a MySQL connection, here is why: \n";
echo "Errno: " . $mysqli->connect_errno . "\n";
echo "Error: " . $mysqli->connect_error . "\n";
}
/** connect
* Builds a connection to the database
* Used by other functions that need database connection to work
* @author Luke081515 / MGChecker
* @returns mysqli - object that represents a MySQL server
*/
protected function connect() {
$db = new mysqli($this->dbHost, $this->dbUsername, $this->dbPassword, $this->dbName);
if ($db->connect_errno) {
echo 'Error: Failed to make a MySQL connection, here is why: \n';
echo 'Errno: ' . $db->connect_errno . '\n';
echo 'Error: ' . $db->connect_error . '\n';
die (1);
}
return $db;
}
public function query($sql, $sensitive = false) {
if(!$result = $this->DB->query($sql)) {
if ($sensitive === false)
die('There was an error running the query [' . $this->DB->error . ']');
else
echo ('\nThere was an error running the query [' . $this->DB->error . ']');
} else if ($result->num_rows === 0) {
return 0;
/** queryEngine
* Performs a sql/dml query to a database
* @author MGChecker
* @param string $sql - the sql/dml query
* @param bool $sensitive - [optional: false] if the program should exit if an query error occurs
* @param bool $modify - if the query modifys or reads the database
* @returns mixed - depending on $modify array or bool, see query and modify for further information
*/
private function queryEngine($sql, $sensitive, $modify) {
if ($modify === true)
$query = 'command';
else
$query = 'query';
$db = connect();
$result = $db->query($sql);
$db->close();
if (!$result) {
if ($sensitive === false) {
die('There was an error running the ' . $query . ' [' . $this->db->error . ']');
} else {
echo 'There was an error running the ' . $query . ' [' . $this->db->error . ']';
if ($modify === true)
return false;
else
return;
}
}
if ($modify === true) {
return true;
} else {
return $result;
$r['num_rows'] = $result->num_rows();
$r['rows'] = false;
for ($i = 0; $i < $r['num_rows']; $i++) {
$r['rows'][$i] = $result->fetch_array();
}
$result->free();
return $r;
}
}
public function modify ($sql, $sensitive = false) {
if (!$result = $this->DB->query($sql)) {
if ($sensitive === false)
die('There was an error running the command [' . $this->DB->error . ']');
else
echo ('\nThere was an error running the command [' . $this->DB->error . ']');
} else
return $result;
}
public function real_escape_string($string) {
return $this->DB->real_escape_string($string);
/** query
* Performs a sql query by calling queryEngine
* @author MGChecker
* @param string $sql - the sql query
* @param bool $sensitive - [optional: false] if the program should go on if a query error occurs
* @returns ?array - contains
* 'num_rows' - the count of rows of the result
* 'rows' - an array with the data of every row as an both associative and numeric array
* or null if $sensitive is false and an error occured
*/
public function query($sql, $sensitive = false) {
return queryEngine($sql, $sensitive, false);
}
public function close() {
mysqli_close($this->DB);
/** modify
* Performs a dml command by calling queryEngine
* @author MGChecker
* @param string $dml - the dml query
* @param bool $sensitive - [optional: false] if the program should go on if a query error occurs
* @returns bool - true if modification succeeded, false if $sensitive is false and an error occured
*/
public function modify($dml, $sensitive = false) {
return queryEngine($dml, $sensitive, true);
}
function __destruct() {
mysqli_close($this->DB);
/** escape
* esapes a string to avoid database damage
* @author Freddy2001 / MGChecker
* @param string $string - the string to be escaped
* @returns string - the espaced string
*/
public function escape($string) {
$db = connect;
$string = $db->real_escape_string($string);
close();
return $string;
}
}
?>
<?php
class DBpassword {
/** Dies ist eine Example-Datei
* Damit das Programm funktioniert, muessen die Daten angepasst werden!
*/
private $LoginName;
private $LoginHost;
private $LoginAccount;
private $LoginPassword;
protected function init() {
$this->LoginName = array( // Empfohlen: Username@wiki
'root@localhost',
);
# Bitte beachten, Accounts müssen in der selben Reihenfolge genannt werden, wie bei LoginName! #
$this->LoginHost = array( // Internetdomain
'127.0.0.1',
);
$this->LoginAccount = array( // Name das Accounts
'root',
);
$this->LoginPassword = array( // Passwort des Accounts
'Password',
);
}
protected function getLoginName() {
return serialize ($this->LoginName);
}
protected function getLoginHost() {
return serialize ($this->LoginHost);
}
protected function getLoginAccount() {
return serialize ($this->LoginAccount);
}
protected function getLoginDBpassword() {
return serialize ($this->LoginPassword);
}
}
?>
<?php
namespace Cygnus;
class Database extends mysqli {
public function replicaConnect($database) {
$mycnf = parse_ini_file("./replica.my.cnf");
......
<?php
class Password {
/** This is just an example!
* For running any Job properly, the data needs to be adapted!
* Do not forget chmod 0600!
*/
private $LoginName;
private $LoginHost;
private $LoginAccount;
private $LoginPassword;
private $MailAddress;
public function Password() {}
protected function init() {
$this->LoginName = array( // Recommended: Username@wiki
'User@dewiki',
'Bot@dewikisource',
);
// Please note, that the following settings need to be made in the same order as LoginName!
$this->LoginHost = array( // Domain of the Wiki
'de.wikipedia.org',
'de.wikisource.org',
);
$this->LoginAccount = array( // Name of the account
'User',
'Bot',
);
$this->LoginPassword = array( // Password of the account
'Userpassword',
'Botpassword',
);
$this->MailAddress = array( // The script sends triggered mails to this address
'hello@example.org',
'support@example.org',
);
}
protected function getLoginName() {
return serialize ($this->LoginName);
}
protected function getLoginHost() {
return serialize ($this->LoginHost);
}
protected function getLoginAccount() {
return serialize ($this->LoginAccount);
}
protected function getLoginPassword() {
return serialize ($this->LoginPassword);
}
protected function getMail() {
return serialize ($this->MailAddress);
}
}
?>
#!/bin/bash
# We need to install dependencies only for Docker
[[ ! -e /.dockerenv ]] && exit 0
set -xe
# Install git (the php image doesn't have it) which is required by composer
apt-get update -yqq
apt-get install git -yqq
pear install PHP_CodeSniffer
phpcs ./ -p --colors
#!/bin/bash
#Usage: `phplint.sh /path/to/dir` or `phplint.sh /path/to/file.php`
error=false
while test $# -gt 0; do
current=$1
shift
if [ ! -d $current ] && [ ! -f $current ] ; then
echo "Invalid directory or file: $current"
error=true
continue
fi
for file in `find $current -type f -name "*.php"` ; do
RESULTS=`php -l $file`
if [ "$RESULTS" != "No syntax errors detected in $file" ] ; then
echo $RESULTS
error=true
fi
done
done
if [ "$error" = true ] ; then
exit 1
else
exit 0
fi
{
"accounts": {
"root@localhost": {
"host": "127.0.0.1",
"user": "root",
"pwd": "rootpassword"
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Cygnus">
<description>Codestyling rules for Cygnus.
</description>
<rule ref="Generic.Classes.DuplicateClassName"/>
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<rule ref="Generic.Commenting.Fixme"/>
<rule ref="Generic.Files.ByteOrderMark"/>
<rule ref="Generic.Files.LineEndings"/>
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="300"/>
<property name="absoluteLineLimit" value="400"/>
</properties>
</rule>
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
<rule ref="Generic.Formatting.NoSpaceAfterCast"/>
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
<rule ref="Generic.NamingConventions.ConstructorName">
<properties>
<property name="error" value="false"/>
</properties>
</rule>
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Generic.PHP.ForbiddenFunctions"/>
<rule ref="Generic.PHP.LowerCaseConstant"/>
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
<rule ref="MySource.PHP.EvalObjectFactory"/>
<rule ref="PEAR.Commenting.InlineComment"/>
<rule ref="PEAR.Files.IncludingFile"/>
<rule ref="PEAR.Formatting.MultiLineAssignment"/>
<rule ref="PEAR.Functions.ValidDefaultValue"/>
<rule ref="PEAR.NamingConventions.ValidClassName"/>
<rule ref="Squiz.PHP.DisallowMultipleAssignments"/>
<rule ref="Squiz.PHP.DiscouragedFunctions"/>
<rule ref="Squiz.PHP.EmbeddedPhp"/>
<rule ref="Squiz.PHP.Eval"/>
<rule ref="Squiz.PHP.ForbiddenFunctions"/>
<rule ref="Squiz.PHP.GlobalKeyword"/>
<rule ref="Squiz.PHP.Heredoc"/>
<rule ref="Squiz.PHP.InnerFunctions"/>
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<rule ref="Squiz.PHP.NonExecutableCode"/>
<rule ref="Squiz.Scope.MethodScope"/>
<rule ref="Squiz.Scope.StaticThisUsage"/>
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing"/>
<rule ref="Squiz.WhiteSpace.OperatorSpacing"/>
<rule ref="Squiz.WhiteSpace.PropertyLabelSpacing"/>
<rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/>
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
</ruleset>
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Cygnus">
<arg name="tab-width" value="4" />
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="tabIndent" value="true"/>
</properties>
</rule>
</ruleset>
{
"email": "hello@example.org",
"accountdefaults": {
"host": "de.wikipedia.org",
"https": true,
"path": "w/api.php"
},
"accounts": {
"User@dewiki": {
"user": "User",
"pwd": "Userpassword"
},
"Bot@dewikisource": {
"host": "de.wikisource.org",
"user": "Bot",
"pwd": "Botpassword"
},
"User2@pokewiki": {
"host": "pokewiki.de",
"user": "User2",
"pwd": "User2password",
"path": "api.php"
}
}
}