Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
tweak(Tinebase/Path): optimize table after purgeDeletedRecords/rebuil…
Browse files Browse the repository at this point in the history
…dPaths

- also update phpstan baseline
  • Loading branch information
pschuele committed Mar 17, 2022
1 parent 56a9852 commit 35bb91a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
17 changes: 6 additions & 11 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -772,11 +772,6 @@ parameters:
count: 1
path: tine20/Admin/Controller/EmailAccount.php

-
message: "#^Call to an undefined method Tinebase_User_Plugin_Abstract\\:\\:getEmailuser\\(\\)\\.$#"
count: 2
path: tine20/Admin/Controller/EmailAccount.php

-
message: "#^Method Tinebase_Backend_Interface\\:\\:search\\(\\) invoked with 5 parameters, 0\\-3 required\\.$#"
count: 1
Expand Down Expand Up @@ -7936,7 +7931,7 @@ parameters:

-
message: "#^Call to an undefined method Tinebase_Controller_Abstract\\:\\:get\\(\\)\\.$#"
count: 2
count: 1
path: tine20/Tinebase/Frontend/Http.php

-
Expand Down Expand Up @@ -7984,11 +7979,6 @@ parameters:
count: 4
path: tine20/Tinebase/Frontend/Http.php

-
message: "#^Variable \\$node might not be defined\\.$#"
count: 1
path: tine20/Tinebase/Frontend/Http.php

-
message: "#^Variable \\$record might not be defined\\.$#"
count: 1
Expand Down Expand Up @@ -10519,6 +10509,11 @@ parameters:
count: 1
path: tine20/Tinebase/OpenId/Provider/User/Tine20.php

-
message: "#^Access to an undefined property Zend_Db_Adapter_Abstract\\:\\:\\$table_prefix\\.$#"
count: 1
path: tine20/Tinebase/Path/Backend/Sql.php

-
message: "#^Method Tinebase_Path_Backend_Sql\\:\\:delete\\(\\) should return int but return statement is missing\\.$#"
count: 1
Expand Down
2 changes: 2 additions & 0 deletions tests/tine20/Tinebase/Frontend/CliTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ public function testPurgeDeletedRecordsAddressbook()
*/
public function testPurgeDeletedRecordsAllTables()
{
$this->_testNeedsTransaction();

$opts = $this->_getOpts();
if (Tinebase_Config::getInstance()->{Tinebase_Config::FILESYSTEM}->{Tinebase_Config::FILESYSTEM_MODLOGACTIVE}) {
$deletedFile = $this->_addAndDeleteFile();
Expand Down
2 changes: 2 additions & 0 deletions tine20/Tinebase/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,8 @@ public function rebuildPaths()
}
}

Tinebase_Path_Backend_Sql::optimizePathsTable();

return true;
}

Expand Down
3 changes: 3 additions & 0 deletions tine20/Tinebase/Frontend/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,9 @@ public function purgeDeletedRecords(Zend_Console_Getopt $_opts)

echo "\nCleaning files...";
$this->clearDeletedFiles();

echo "\nOptimizing path table...";
Tinebase_Path_Backend_Sql::optimizePathsTable();
}

echo "\n\n";
Expand Down
8 changes: 8 additions & 0 deletions tine20/Tinebase/Path/Backend/Sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -642,4 +642,12 @@ protected function _addToModelStore(Tinebase_Model_Path $_record, $_replace = fa
static::$_shadowPathMapping[$shadow_path] = $id;
static::$_idToShadowPath[$id] = $shadow_path;
}

public static function optimizePathsTable()
{
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Optimizing path table ...');
$db = Tinebase_Core::getDb();
$stmt = $db->query('OPTIMIZE TABLE ' . $db->table_prefix . 'path;');
$stmt->closeCursor();
}
}

0 comments on commit 35bb91a

Please sign in to comment.