X-Git-Url: https://git.stricted.de/?p=GitHub%2FWoltLab%2Fwoltlab.github.io.git;a=blobdiff_plain;f=5.4%2Fmigration%2Fwsc53%2Fphp%2Findex.html;h=b0a5597a26b3b08ecfe2cd151e08ed5108b865f5;hp=02a62be82841b128580cd03c4acafea0d1449e3a;hb=704cbc4a08ba7a57c23e951255ffc41a21c31a7f;hpb=716a4ab6d247e50b770ecb39804a2d0a12e8e3bd diff --git a/5.4/migration/wsc53/php/index.html b/5.4/migration/wsc53/php/index.html index 02a62be8..b0a5597a 100644 --- a/5.4/migration/wsc53/php/index.html +++ b/5.4/migration/wsc53/php/index.html @@ -2111,21 +2111,28 @@ Leveraging this API is easily done.

  1. Register an object type for the definition com.woltlab.wcf.floodControl: com.example.foo.myContent.
  2. Whenever the active user creates content of this type, call -
    FloodControl::getInstance()->registerContent('com.example.foo.myContent');
    +    
    1
    FloodControl::getInstance()->registerContent('com.example.foo.myContent');
     
    +
    You should only call this method if the user creates the content themselves. If the content is automatically created by the system, for example when copying / duplicating existing content, no activity should be registered.
  3. To check the last time when the active user created content of the relevant type, use -

    FloodControl::getInstance()->getLastTime('com.example.foo.myContent');
    +    
    1
    FloodControl::getInstance()->getLastTime('com.example.foo.myContent');
     
    +
    If you want to limit the number of content items created within a certain period of time, for example within one day, use -
    $data = FloodControl::getInstance()->countContent('com.example.foo.myContent', new \DateInterval('P1D'));
    +    
    1
    +2
    +3
    +4
    +5
    $data = FloodControl::getInstance()->countContent('com.example.foo.myContent', new \DateInterval('P1D'));
     // number of content items created within the last day
     $count = $data['count'];
     // timestamp when the earliest content item was created within the last day
     $earliestTime = $data['earliestTime'];
     
    +
    The method also returns earliestTime so that you can tell the user in the error message when they are able again to create new content of the relevant type.

    Flood control entries are only stored for 31 days and older entries are cleaned up daily.

    @@ -2145,12 +2152,17 @@ The script is expected to return an array of DatabaseTable objects The PHP file must be located in the acp/database/ directory for the devtools sync function to recognize the file.

    PHP Database API#

    The PHP API to add and change database tables during package installations and updates in the wcf\system\database\table namespace now also supports renaming existing table columns with the new IDatabaseTableColumn::renameTo() method:

    -
    PartialDatabaseTable::create('wcf1_test')
    +
    1
    +2
    +3
    +4
    +5
    PartialDatabaseTable::create('wcf1_test')
             ->columns([
                     NotNullInt10DatabaseTableColumn::create('oldName')
                             ->renameTo('newName')
             ]);
     
    +

    Like with every change to existing database tables, packages can only rename columns that they installed.