Exemplo n.º 1
0
 static function onMediaWikiPerformAction($output, $article, $title, $user, $request, $wiki)
 {
     global $wgCookiePrefix;
     global $qp_enable_showresults;
     // deprecated since v0.6.5
     global $qp_AnonForwardedFor;
     // deprecated since v0.6.5
     global $wgUser;
     self::$output = $output;
     self::$article = $article;
     self::$title = $title;
     # in MW v1.15 / v1.16 user object was stub;
     # in MW v1.19 it seems to be real object.
     # Unstub for the versions where it is stubbed.
     # Borrowed from Title::getUserPermissionsErrors() MW v1.16
     if (!StubObject::isRealObject($user)) {
         // Since StubObject is always used on globals, we can unstub $wgUser here and set $user = $wgUser
         global $wgUser;
         $wgUser->_unstub('', 5);
         $user = $wgUser;
     }
     self::$user = $user;
     self::$request = $request;
     if (isset($qp_AnonForwardedFor)) {
         self::$anon_forwarded_for = $qp_AnonForwardedFor;
     }
     # setup proper integer global showresults level
     if (isset($qp_enable_showresults)) {
         self::$global_showresults = $qp_enable_showresults;
     }
     if (!is_int(self::$global_showresults)) {
         # convert from older v0.5 boolean value
         self::$global_showresults = (int) (bool) self::$global_showresults;
     }
     if (self::$global_showresults < 0) {
         self::$global_showresults = 0;
     } elseif (self::$global_showresults > 2) {
         self::$global_showresults = 2;
     }
     if (isset($_COOKIE["{$wgCookiePrefix}QPoll"])) {
         $request->response()->setCookie('QPoll', '', time() - 86400);
         // clear cookie
         self::clearCache();
     } elseif ($request->getVal('pollId') !== null) {
         self::clearCache();
     }
     self::$propAttrs = new qp_PropAttrs();
     return true;
 }