@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Task; |
| 4 | 4 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * @inheritDoc |
| 20 | 20 | */ |
| 21 | - public function run() : TaskResult { |
|
| 21 | + public function run () : TaskResult { |
|
| 22 | 22 | $this->getLogger()->info( 'Starting task UpdateList' ); |
| 23 | 23 | $this->actualList = $this->getActualAdmins(); |
| 24 | 24 | $this->botList = $this->getList(); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * @return array |
| 55 | 55 | */ |
| 56 | - protected function getActualAdmins() : array { |
|
| 56 | + protected function getActualAdmins () : array { |
|
| 57 | 57 | $this->getLogger()->debug( 'Retrieving admins - API' ); |
| 58 | 58 | $params = [ |
| 59 | 59 | 'action' => 'query', |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | * @param \stdClass $data |
| 72 | 72 | * @return array |
| 73 | 73 | */ |
| 74 | - protected function extractAdmins( \stdClass $data ) : array { |
|
| 75 | - $ret = []; |
|
| 74 | + protected function extractAdmins ( \stdClass $data ) : array { |
|
| 75 | + $ret = [ ]; |
|
| 76 | 76 | $blacklist = $this->getConfig()->get( 'exclude-admins' ); |
| 77 | 77 | foreach ( $data->query->allusers as $u ) { |
| 78 | 78 | if ( in_array( $u->name, $blacklist ) ) { |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | /** |
| 88 | 88 | * @return array |
| 89 | 89 | */ |
| 90 | - protected function getList() : array { |
|
| 90 | + protected function getList () : array { |
|
| 91 | 91 | $this->getLogger()->debug( 'Retrieving admins - JSON list' ); |
| 92 | 92 | $content = $this->getController()->getPageContent( $this->getConfig()->get( 'list-title' ) ); |
| 93 | 93 | |
@@ -99,22 +99,22 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @return array[] |
| 101 | 101 | */ |
| 102 | - protected function getMissingGroups() : array { |
|
| 103 | - $missing = []; |
|
| 102 | + protected function getMissingGroups () : array { |
|
| 103 | + $missing = [ ]; |
|
| 104 | 104 | foreach ( $this->actualList as $adm => $groups ) { |
| 105 | - $groupsList = []; |
|
| 105 | + $groupsList = [ ]; |
|
| 106 | 106 | if ( !isset( $this->botList[ $adm ] ) ) { |
| 107 | 107 | $groupsList = $groups; |
| 108 | - } elseif ( count( $groups ) > count( $this->botList[$adm] ) ) { |
|
| 108 | + } elseif ( count( $groups ) > count( $this->botList[ $adm ] ) ) { |
|
| 109 | 109 | // Only some groups are missing |
| 110 | - $groupsList = array_diff_key( $groups, $this->botList[$adm] ); |
|
| 110 | + $groupsList = array_diff_key( $groups, $this->botList[ $adm ] ); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | foreach ( $groupsList as $group ) { |
| 114 | 114 | try { |
| 115 | 115 | $missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group ); |
| 116 | 116 | } catch ( TaskException $e ) { |
| 117 | - $this->errors[] = $e->getMessage(); |
|
| 117 | + $this->errors[ ] = $e->getMessage(); |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @return string |
| 130 | 130 | * @throws TaskException |
| 131 | 131 | */ |
| 132 | - protected function getFlagDate( string $admin, string $group ) : string { |
|
| 132 | + protected function getFlagDate ( string $admin, string $group ) : string { |
|
| 133 | 133 | $this->getLogger()->info( "Retrieving $group flag date for $admin" ); |
| 134 | 134 | |
| 135 | 135 | if ( $group === 'checkuser' ) { |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @param string $group |
| 170 | 170 | * @return string|null |
| 171 | 171 | */ |
| 172 | - private function extractTimestamp( \stdClass $data, string $group ) : ?string { |
|
| 172 | + private function extractTimestamp ( \stdClass $data, string $group ) : ?string { |
|
| 173 | 173 | $ts = null; |
| 174 | 174 | foreach ( $data->query->logevents as $entry ) { |
| 175 | 175 | if ( !isset( $entry->params ) ) { |
@@ -191,8 +191,8 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @return array[] |
| 193 | 193 | */ |
| 194 | - protected function getExtraGroups() : array { |
|
| 195 | - $extra = []; |
|
| 194 | + protected function getExtraGroups () : array { |
|
| 195 | + $extra = [ ]; |
|
| 196 | 196 | foreach ( $this->botList as $name => $groups ) { |
| 197 | 197 | if ( !isset( $this->actualList[ $name ] ) ) { |
| 198 | 198 | $extra[ $name ] = $groups; |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * |
| 209 | 209 | * @param array $newContent |
| 210 | 210 | */ |
| 211 | - protected function doUpdateList( array $newContent ) { |
|
| 211 | + protected function doUpdateList ( array $newContent ) { |
|
| 212 | 212 | $this->getLogger()->info( 'Updating admin list' ); |
| 213 | 213 | |
| 214 | 214 | $params = [ |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | * @param array[] $extra |
| 228 | 228 | * @return array[] |
| 229 | 229 | */ |
| 230 | - protected function getNewContent( array $missing, array $extra ) : array { |
|
| 230 | + protected function getNewContent ( array $missing, array $extra ) : array { |
|
| 231 | 231 | $newContent = $this->botList; |
| 232 | 232 | foreach ( $newContent as $user => $groups ) { |
| 233 | 233 | if ( isset( $missing[ $user ] ) ) { |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Task; |
| 4 | 4 | |
@@ -11,13 +11,13 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @inheritDoc |
| 13 | 13 | */ |
| 14 | - public function run() : TaskResult { |
|
| 14 | + public function run () : TaskResult { |
|
| 15 | 15 | $this->getLogger()->info( 'Starting task UserNotice' ); |
| 16 | 16 | |
| 17 | 17 | $pages = $this->getDataProvider()->getCreatedPages(); |
| 18 | 18 | $users = $this->getDataProvider()->getUsersToProcess(); |
| 19 | 19 | if ( $pages && $users ) { |
| 20 | - $ricNums = []; |
|
| 20 | + $ricNums = [ ]; |
|
| 21 | 21 | foreach ( $pages as $page ) { |
| 22 | 22 | $bits = explode( '/', $page ); |
| 23 | 23 | $num = intval( array_pop( $bits ) ); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param string $user |
| 42 | 42 | * @param int $ricNum |
| 43 | 43 | */ |
| 44 | - protected function addMsg( string $user, int $ricNum ) { |
|
| 44 | + protected function addMsg ( string $user, int $ricNum ) { |
|
| 45 | 45 | $this->getLogger()->info( "Leaving msg to $user" ); |
| 46 | 46 | $msg = str_replace( '$num', "$ricNum", $this->getConfig()->get( 'user-notice-msg' ) ); |
| 47 | 47 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Task; |
| 4 | 4 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @inheritDoc |
| 15 | 15 | */ |
| 16 | - public function run() : TaskResult { |
|
| 16 | + public function run () : TaskResult { |
|
| 17 | 17 | $this->getLogger()->info( 'Starting task CreatePages' ); |
| 18 | 18 | $users = $this->getDataProvider()->getUsersToProcess(); |
| 19 | 19 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param string $user |
| 36 | 36 | * @param array $groups |
| 37 | 37 | */ |
| 38 | - protected function processUser( string $user, array $groups ) { |
|
| 38 | + protected function processUser ( string $user, array $groups ) { |
|
| 39 | 39 | try { |
| 40 | 40 | $num = $this->getLastPageNum( $user ) + 1; |
| 41 | 41 | } catch ( TaskException $e ) { |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | * @return int |
| 66 | 66 | * @throws TaskException |
| 67 | 67 | */ |
| 68 | - protected function getLastPageNum( string $user ) : int { |
|
| 68 | + protected function getLastPageNum ( string $user ) : int { |
|
| 69 | 69 | $this->getLogger()->debug( "Retrieving previous pages for $user" ); |
| 70 | - $unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[1]; |
|
| 70 | + $unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[ 1 ]; |
|
| 71 | 71 | $params = [ |
| 72 | 72 | 'action' => 'query', |
| 73 | 73 | 'list' => 'allpages', |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | * @param string $user |
| 103 | 103 | * @param array $groups |
| 104 | 104 | */ |
| 105 | - protected function createPage( string $title, string $user, array $groups ) { |
|
| 105 | + protected function createPage ( string $title, string $user, array $groups ) { |
|
| 106 | 106 | $this->getLogger()->info( "Creating page $title" ); |
| 107 | 107 | $text = $this->getConfig()->get( 'ric-page-text' ); |
| 108 | 108 | $textParams = [ |
| 109 | 109 | '$user' => $user, |
| 110 | - '$date' => $groups['sysop'], |
|
| 111 | - '$burocrate' => $groups['bureaucrat'] ?? '', |
|
| 112 | - '$checkuser' => $groups['checkuser'] ?? '' |
|
| 110 | + '$date' => $groups[ 'sysop' ], |
|
| 111 | + '$burocrate' => $groups[ 'bureaucrat' ] ?? '', |
|
| 112 | + '$checkuser' => $groups[ 'checkuser' ] ?? '' |
|
| 113 | 113 | ]; |
| 114 | 114 | $text = strtr( $text, $textParams ); |
| 115 | 115 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param string $title |
| 129 | 129 | * @param string $newText |
| 130 | 130 | */ |
| 131 | - protected function createBasePage( string $title, string $newText ) { |
|
| 131 | + protected function createBasePage ( string $title, string $newText ) { |
|
| 132 | 132 | $this->getLogger()->info( "Creating base page $title" ); |
| 133 | 133 | |
| 134 | 134 | $params = [ |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @param string $title |
| 146 | 146 | * @param string $newText |
| 147 | 147 | */ |
| 148 | - protected function updateBasePage( string $title, string $newText ) { |
|
| 148 | + protected function updateBasePage ( string $title, string $newText ) { |
|
| 149 | 149 | $this->getLogger()->info( "Updating base page $title" ); |
| 150 | 150 | |
| 151 | 151 | $params = [ |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme; |
| 4 | 4 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | /** @var string[] */ |
| 20 | 20 | private $tokens; |
| 21 | 21 | |
| 22 | - public function __construct() { |
|
| 22 | + public function __construct () { |
|
| 23 | 23 | $this->logger = new Logger; |
| 24 | 24 | } |
| 25 | 25 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @return string |
| 31 | 31 | * @throws MissingPageException |
| 32 | 32 | */ |
| 33 | - public function getPageContent( string $title ) : string { |
|
| 33 | + public function getPageContent ( string $title ) : string { |
|
| 34 | 34 | $this->logger->debug( "Retrieving page $title" ); |
| 35 | 35 | $params = [ |
| 36 | 36 | 'action' => 'query', |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | throw new MissingPageException( $title ); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - return $page->revisions[0]->slots->main->{ '*' }; |
|
| 50 | + return $page->revisions[ 0 ]->slots->main->{ '*' }; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param array $params |
| 57 | 57 | * @throws EditException |
| 58 | 58 | */ |
| 59 | - public function editPage( array $params ) { |
|
| 59 | + public function editPage ( array $params ) { |
|
| 60 | 60 | $this->login(); |
| 61 | 61 | |
| 62 | 62 | $params = [ |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
| 76 | 76 | * @throws LoginException |
| 77 | 77 | */ |
| 78 | - public function login() { |
|
| 78 | + public function login () { |
|
| 79 | 79 | if ( self::$loggedIn ) { |
| 80 | 80 | $this->logger->debug( 'Already logged in' ); |
| 81 | 81 | return; |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | self::$loggedIn = true; |
| 104 | 104 | // Clear tokens cache |
| 105 | - $this->tokens = []; |
|
| 105 | + $this->tokens = [ ]; |
|
| 106 | 106 | $this->logger->info( 'Login succeeded' ); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @param string $type |
| 113 | 113 | * @return string |
| 114 | 114 | */ |
| 115 | - public function getToken( string $type ) : string { |
|
| 115 | + public function getToken ( string $type ) : string { |
|
| 116 | 116 | if ( !isset( $this->tokens[ $type ] ) ) { |
| 117 | 117 | $params = [ |
| 118 | 118 | 'action' => 'query', |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * @param string $title |
| 136 | 136 | * @return int |
| 137 | 137 | */ |
| 138 | - public function getPageCreationTS( string $title ) : int { |
|
| 138 | + public function getPageCreationTS ( string $title ) : int { |
|
| 139 | 139 | $params = [ |
| 140 | 140 | 'action' => 'query', |
| 141 | 141 | 'prop' => 'revisions', |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | $res = ( RequestBase::newFromParams( $params ) )->execute(); |
| 150 | 150 | $data = $res->query->pages; |
| 151 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
| 151 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param string $title |
| 158 | 158 | * @param string $reason |
| 159 | 159 | */ |
| 160 | - public function protectPage( string $title, string $reason ) { |
|
| 160 | + public function protectPage ( string $title, string $reason ) { |
|
| 161 | 161 | $this->logger->info( "Protecting page $title" ); |
| 162 | 162 | $this->login(); |
| 163 | 163 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Task; |
| 4 | 4 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @inheritDoc |
| 17 | 17 | */ |
| 18 | - public function run() : TaskResult { |
|
| 18 | + public function run () : TaskResult { |
|
| 19 | 19 | $this->getLogger()->info( 'Starting task ClosePages' ); |
| 20 | 20 | |
| 21 | 21 | $titles = $this->getPagesList(); |
@@ -40,13 +40,13 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return string[] |
| 42 | 42 | */ |
| 43 | - protected function getPagesList() : array { |
|
| 43 | + protected function getPagesList () : array { |
|
| 44 | 44 | $allPages = $this->getTranscludedPages(); |
| 45 | - $ret = []; |
|
| 45 | + $ret = [ ]; |
|
| 46 | 46 | foreach ( $allPages as $page ) { |
| 47 | 47 | $created = $this->getController()->getPageCreationTS( $page ); |
| 48 | 48 | if ( time() - $created <= 60 * 60 * 24 * 7 && !$this->hasOpposition( $page ) ) { |
| 49 | - $ret[] = $page; |
|
| 49 | + $ret[ ] = $page; |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | return $ret; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return string[] |
| 59 | 59 | */ |
| 60 | - protected function getTranscludedPages() : array { |
|
| 60 | + protected function getTranscludedPages () : array { |
|
| 61 | 61 | $baseTitle = $this->getConfig()->get( 'ric-main-page' ); |
| 62 | 62 | $params = [ |
| 63 | 63 | 'action' => 'query', |
@@ -69,10 +69,10 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | $res = RequestBase::newFromParams( $params )->execute(); |
| 71 | 71 | $pages = $res->query->pages; |
| 72 | - $ret = []; |
|
| 72 | + $ret = [ ]; |
|
| 73 | 73 | foreach ( reset( $pages )->templates as $page ) { |
| 74 | 74 | if ( preg_match( "!$baseTitle\/[^\/]+\/\d!", $page->title ) !== false ) { |
| 75 | - $ret[] = $page->title; |
|
| 75 | + $ret[ ] = $page->title; |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | return $ret; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param string $page |
| 83 | 83 | * @return bool |
| 84 | 84 | */ |
| 85 | - protected function hasOpposition( string $page ) : bool { |
|
| 85 | + protected function hasOpposition ( string $page ) : bool { |
|
| 86 | 86 | $params = [ |
| 87 | 87 | 'action' => 'query', |
| 88 | 88 | 'prop' => 'revisions', |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | ]; |
| 94 | 94 | $res = RequestBase::newFromParams( $params )->execute(); |
| 95 | 95 | $page = reset( $res->query->pages ); |
| 96 | - $content = $page->revisions[0]->slots->main->{ '*' }; |
|
| 96 | + $content = $page->revisions[ 0 ]->slots->main->{ '*' }; |
|
| 97 | 97 | // Let's hope that this is good enough... |
| 98 | 98 | $votes = substr_count( $content, "\n\# *(?![#*])" ); |
| 99 | 99 | return $votes >= 15; |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | * @param string[] $titles |
| 105 | 105 | * @see UpdatesAround::addToMainPage() |
| 106 | 106 | */ |
| 107 | - protected function removeFromMainPage( array $titles ) { |
|
| 107 | + protected function removeFromMainPage ( array $titles ) { |
|
| 108 | 108 | $this->getLogger()->info( 'Removing from main: ' . implode( ', ', $titles ) ); |
| 109 | 109 | |
| 110 | 110 | $mainPage = $this->getConfig()->get( 'ric-main-page' ); |
| 111 | 111 | $content = $this->getController()->getPageContent( $mainPage ); |
| 112 | - $translations = []; |
|
| 112 | + $translations = [ ]; |
|
| 113 | 113 | foreach ( $titles as $title ) { |
| 114 | 114 | $translations[ '{{' . $title . '}}' ] = ''; |
| 115 | 115 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * |
| 128 | 128 | * @param string[] $titles |
| 129 | 129 | */ |
| 130 | - protected function addToArchive( array $titles ) { |
|
| 130 | + protected function addToArchive ( array $titles ) { |
|
| 131 | 131 | $this->getLogger()->info( 'Adding to archive: ' . implode( ', ', $titles ) ); |
| 132 | 132 | |
| 133 | 133 | $archiveTitle = $this->getConfig()->get( 'close-archive-title' ); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * @param string $title |
| 152 | 152 | * @see CreatePages::updateBasePage() |
| 153 | 153 | */ |
| 154 | - protected function updateBasePage( string $title ) { |
|
| 154 | + protected function updateBasePage ( string $title ) { |
|
| 155 | 155 | $this->getLogger()->info( "Updating base page $title" ); |
| 156 | 156 | |
| 157 | 157 | // @phan-suppress-next-line PhanTypeMismatchArgumentInternal WTF Phan what's wrong w/ u? |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @param string[] $titles |
| 173 | 173 | * @see UpdatesAround::addVote() |
| 174 | 174 | */ |
| 175 | - protected function updateVote( array $titles ) { |
|
| 175 | + protected function updateVote ( array $titles ) { |
|
| 176 | 176 | $votePage = $this->getConfig()->get( 'ric-vote-page' ); |
| 177 | 177 | $content = $this->getController()->getPageContent( $votePage ); |
| 178 | 178 | |
@@ -198,19 +198,19 @@ discard block |
||
| 198 | 198 | * @throws TaskException |
| 199 | 199 | * @see UpdatesAround::addNews() |
| 200 | 200 | */ |
| 201 | - protected function updateNews( int $amount ) { |
|
| 201 | + protected function updateNews ( int $amount ) { |
|
| 202 | 202 | $this->getLogger()->info( "Decreasing the news counter by $amount" ); |
| 203 | 203 | $newsPage = $this->getConfig()->get( 'ric-news-page' ); |
| 204 | 204 | |
| 205 | 205 | $content = $this->getController()->getPageContent( $newsPage ); |
| 206 | 206 | $reg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!'; |
| 207 | 207 | |
| 208 | - $matches = []; |
|
| 208 | + $matches = [ ]; |
|
| 209 | 209 | if ( preg_match( $reg, $content, $matches ) === false ) { |
| 210 | 210 | throw new TaskException( 'Param not found in news page' ); |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - $newNum = (int)$matches[2] - $amount; |
|
| 213 | + $newNum = (int)$matches[ 2 ] - $amount; |
|
| 214 | 214 | $newContent = preg_replace( $reg, '${1}' . $newNum, $content ); |
| 215 | 215 | |
| 216 | 216 | $params = [ |
@@ -227,12 +227,12 @@ discard block |
||
| 227 | 227 | * |
| 228 | 228 | * @param string[] $titles |
| 229 | 229 | */ |
| 230 | - protected function updateAdminList( array $titles ) { |
|
| 230 | + protected function updateAdminList ( array $titles ) { |
|
| 231 | 231 | $listTitle = $this->getConfig()->get( 'admins-list' ); |
| 232 | 232 | $content = $this->getController()->getPageContent( $listTitle ); |
| 233 | 233 | $newDate = date( 'Ymd', strtotime( '+1 year' ) ); |
| 234 | 234 | foreach ( $titles as $title ) { |
| 235 | - $user = explode( '/', $title )[2]; |
|
| 235 | + $user = explode( '/', $title )[ 2 ]; |
|
| 236 | 236 | $reg = "!(\{\{Amministratore\/riga\|$user.+\| *)\d+(?= *\|(?: *pausa)? *\}\})!"; |
| 237 | 237 | $content = preg_replace( $reg, '$1' . $newDate, $content ); |
| 238 | 238 | } |