UPDATEDATABASE

Update the database as required

version 1
package wikindx4\core\startup
author Mark Grimshaw

 Methods

UPDATEDATABASE

__construct() 

To get total counts right in list operations, certain tables, having their ID columns the same as resource.resourceId, must have the same number of rows as the resource table.

addMissingRows() 

Intercept for initial configuration of database by admin and, if necessary, display admin configuration interface.

checkConfigTable() 

We know we have a database as, if we've reached this stage, we're able to connect to it.

checkDatabase() 

Here, 1/ we check we have tables, if not, populate the database with tables and set defaults in database_summary and category table and 2/ populate the config table displaying configuration interface if necessary If no admins yet exist, ask for admin configuration to force the input of at least one admin username/password.

Check and print status of update scripts

checkStatus(string $stage) 

Parameters

$stage

string

Special CLOSE function for pre v4.0 databases

close(string $pString) 

Parameters

$pString

string

Only the superadmin may update the database -- ask for login

confirmUpdateDisplay() 

Continue execution of upgrade after a pause

continueExecution() 

Fix bad UTF8

fixUTF8() 

If required to pause execution, store current position and any $tableArray arrays in session and present continution form to user

pauseExecution(string $function, string $finished, string $table) 

Parameters

$function

string

$finished

string

$table

string

Default is FALSE

At first initialization of wikindx database, populate the summary table and category table

populateTables() 

recreate the 4.0 cache

recreate40Cache() 

rewrite bibliographies

rewriteBibliographiesGroups() 

Rewrite resource_category table

rewriteResourceCategory() 

Rewrite resource_creator tables

rewriteResourceCreator() 

In v4, we no longer use MySQL's FIND_IN_SET and therefore no longer want comma-delimited field values such as creator1, creator2 etc. in the resource_creator table. Write a new resource_creator table that has a row comprising: resourceId references resource table), creatorId (references creator table), role (creator1, creator2 etc.) and order (1,2, 3 etc. for first author, second author, third author etc.) resourcecreatorCreatorMain is the creatorId that is the main creator for that resource used when ordering lists.

Rewrite resource_keyword table

rewriteResourceKeyword() 

Fix quote, paraphrase, musing counts per resource.

rewriteResourceSummary() 

Check if the config table has been initialized.

rowExists() 

Row must be returned as evidence of prior configuration.

Ensure all tables are set to UTF8 collation

setToUtf8() 

Stage 1

stage4_1__1() 

stage 10

stage4_1__10() 

stage 11

stage4_1__11() 

stage 12

stage4_1__12() 

stage 13

stage4_1__13() 

convert bbcode to html for use with tinymce and correct transTitle errors

stage 14

stage4_1__14() 

stage 15

stage4_1__15() 

Stage 2

stage4_1__2() 

Stage 3

stage4_1__3() 

stage 4

stage4_1__4() 

stage 5

stage4_1__5() 

stage 6

stage4_1__6() 

stage 7

stage4_1__7() 

stage 8

stage4_1__8() 

stage 9

stage4_1__9() 

Upgrade 4.1 to 4.2 -- Stage 1

stage4_2__1() 

v4.1 switches the numPages data for books and theses from resourceField6 to resourcemiscField6

swapNumPages() 

Update the database if required

updateDatabase(boolean $confirm) : boolean

Parameters

$confirm

boolean

Returns

boolean

Check for valid UTF-8.

upgrade40CheckForValidUtf8(string $basicTable, array $fields) 

If invalid code found, store value in array for updating to database after UTF8 upgrade

Parameters

$basicTable

string

$fields

array

Check for valid UTF-8.

upgrade40CheckForValidUtf8Old(string $basicTable, array $fields) 

If invalid code found, store value in array for updating to database after UTF8 upgrade NOT USED

Parameters

$basicTable

string

$fields

array

v3.3 corrected additional backslashes that had crept in but forgot to deal with the resource_note table

upgrade40CorrectBackSlash() 

Create new table resource_attachments and transfer attachments fields to it.

upgrade40CreateResourceAttachments() 

Delete attachment rows if attachments don't exist.

Create new table resource_text and transfer resource_note and resource_abstract fields to it

upgrade40CreateResourceText() 

Create new table subcategory

upgrade40CreateSubcategory() 

Create new tables user_tags and resource_user_tags

upgrade40CreateUsertags() 

Remove user's sessions and caches

upgrade40Nulls() 

Remove duplicate collections

upgrade40RemoveDupCollections() 

pre v4.0 versions have a bug whereby creators may be duplicated in the database -- find these and fix.

upgrade40RemoveDupCreators() 

Rename fields in tables for v4.0 upgrade

upgrade40Rename() 

Store function in MySQL to check for invalid UTF8 code in latin1 database

upgrade40StoreProcedure() 

NOT USED

Upgrade tables to UTF-8 then reverse field type change for some tables from binary back to var

upgrade40Tables(string $tableContinue) 

Parameters

$tableContinue

string

Default is FALSE

Update VARCHARS to account for increased size of UTF8 fields (3* space required) and then temp and change char types to binary types on some tables

upgrade40charToBin(string $table) 

Parameters

$table

string

Default is FALSE

Upgrade database to v4.1.

upgrade41() 

Start with stage1();

Create a new column on the resource table that holds the title-subtitle without {}, ' or " in order to facilitate fast sorting

upgradeResourceTitle() 

 Properties

 

$config 
 

$db 
 

$email 
 

$errors 
 

$html 
 

$messages 
 

$numStages 
 

$oldTime 
 

$session 
 

$stageInterruptMessage 
 

$statusString 
 

$tables 
 

$utf8